JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q34243F
  • License MIT

Complete Node.js logging solution with 6 integration methods, S3 bidirectional operations, advanced analytics, and multi-cloud storage support for enterprise-scale applications.

Package Exports

  • logstack-zee
  • logstack-zee/client

Readme

๐ŸŒฉ๏ธ LogStack

Complete Node.js logging solution with multiple integration methods, cloud storage, and advanced analytics.

npm version License: MIT Node.js

โœจ 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 logstack

Basic 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

Setup Guides

Advanced Topics

๐Ÿšฆ Performance

Metric Performance
Throughput 10,000+ logs/second
Storage 60-80% compression
Reliability 99.9% uptime
Scalability Unlimited (cloud)

๐Ÿค Support

๐Ÿ“„ License

MIT License


๐ŸŽ‰ LogStack - Making logging simple, scalable, and secure for every Node.js application!