Package Exports
- logstack-zee
- logstack-zee/client
Readme
๐ฉ๏ธ LogStack
Complete Node.js logging solution with multiple integration methods, cloud storage, and advanced analytics.
โจ Key Features
- ๐ Multiple Integration Methods: Embedded, REST API, Kafka, Redis, RabbitMQ, WebSocket
- โ๏ธ Multi-Cloud Storage: AWS S3, Google Cloud, Azure, Local files
- ๐ฅ S3 Bidirectional Operations: Upload to and download from S3
- ๐ Advanced Analytics: Real-time monitoring and comprehensive reports
- โก High Performance: Handles 10,000+ logs/second
- ๐ Enterprise Security: Data masking, encryption, retention policies
- ๐ฏ TypeScript Support: Full type safety and IntelliSense
๐ Quick Start
Installation
npm install logstackBasic Usage
const logstack = require('logstack');
// Initialize
await logstack.init({
dbUri: 'mongodb://localhost:27017/myapp',
uploadProvider: 's3' // or 'local', 'gcs', 'azure'
});
// Log API requests
await logstack.saveApiLog({
method: 'GET',
path: '/api/users',
responseStatus: 200,
request_time: new Date(),
response_time: new Date()
});
// Log application events
await logstack.saveLog({
level: 'info',
message: 'User login successful',
service: 'auth-service'
});๐ Integration Methods
| Method | Best For | Setup |
|---|---|---|
| ๐ Embedded | Single apps | require('logstack') |
| ๐ REST API | Multi-language | npm run service:api |
| ๐จ Kafka | High volume | npm run service:kafka |
| โก Redis | Real-time | npm run service:redis |
| ๐ฐ RabbitMQ | Enterprise | npm run service:rabbitmq |
| ๐ WebSocket | Live dashboards | npm run service:websocket |
REST API Example
# Start server
npm run service:api
# Send logs
curl -X POST http://localhost:4000/api/logs \
-H "Content-Type: application/json" \
-d '{"level":"info","message":"Hello LogStack"}'๐ Advanced Features
S3 Operations
const { LogStackAdvanced } = require('logstack/lib/advancedFeatures');
const advanced = new LogStackAdvanced(config);
// Download logs from S3
const files = await advanced.downloadDateRange('2025-01-01', '2025-01-31');
// Search archived logs
const errors = await advanced.searchS3({ responseStatus: /^5\d{2}$/ });
// Generate analytics
const analytics = await advanced.generateAnalytics({
start: '2025-01-01T00:00:00Z',
end: '2025-01-31T23:59:59Z'
});Multi-Service CLI
# Start specific services
npm run service:api # REST API server
npm run service:kafka # Kafka consumer
npm run service:websocket # WebSocket server
npm run service:multi # All services
# With custom options
node examples/multi-service-cli.js api --port 4000
node examples/multi-service-cli.js kafka --brokers localhost:9092โ๏ธ Configuration
Basic Configuration
await logstack.init({
dbUri: 'mongodb://localhost:27017/myapp',
uploadProvider: 's3',
outputDirectory: 'production-logs',
// S3 Configuration
s3: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: 'us-east-1',
bucket: 'my-logs-bucket'
},
// Security & Performance
compression: { enabled: true },
dataMasking: { enabled: true, fields: ['password', 'token'] },
retention: { enabled: true, days: 90 }
});Framework Integration
Express.js
const express = require('express');
const logstack = require('logstack');
const app = express();
await logstack.init(config);
// Automatic API logging middleware
app.use(async (req, res, next) => {
const start = new Date();
res.on('finish', async () => {
await logstack.saveApiLog({
method: req.method,
path: req.path,
responseStatus: res.statusCode,
request_time: start,
response_time: new Date()
});
});
next();
});Other Frameworks
- NestJS: Full TypeScript integration
- Fastify: High-performance logging
- Koa: Middleware support
- Next.js: API routes logging
๐ Storage Options
| Provider | Best For | Setup |
|---|---|---|
| ๐ Local | Development | uploadProvider: 'local' |
| โ๏ธ AWS S3 | Production | uploadProvider: 's3' |
| ๐ Google Cloud | GCP environments | uploadProvider: 'gcs' |
| ๐ Azure | Microsoft ecosystem | uploadProvider: 'azure' |
๐ฏ Use Cases
Startup/Small Apps
// Simple setup
await logstack.init();
await logstack.saveLog({ level: 'info', message: 'App started' });Enterprise/High Scale
// Full configuration
await logstack.init({
dbUri: process.env.DB_URI,
uploadProvider: 's3',
integrations: {
kafka: { brokers: ['kafka1:9092', 'kafka2:9092'] },
redis: { host: 'redis-cluster', port: 6379 }
},
dataMasking: { enabled: true },
retention: { days: 365 }
});๐ Documentation
Quick References
- ๐ Features Summary - Quick decision guide
- ๐ฉ๏ธ Complete Guide - Detailed features
- ๐ Examples - Practical code examples
Setup Guides
Advanced Topics
๐ฆ Performance
| Metric | Performance |
|---|---|
| Throughput | 10,000+ logs/second |
| Storage | 60-80% compression |
| Reliability | 99.9% uptime |
| Scalability | Unlimited (cloud) |
๐ค Support
- ๐ Full Documentation
๐ License
MIT License
๐ LogStack - Making logging simple, scalable, and secure for every Node.js application!