matrixlogger
v0.0.8
Published
A logging service for Node.js applications
Readme
MatrixLogger
A powerful logging service for Node.js applications with support for both Express and NestJS.
Features
- Cloud-based log storage
- Configurable log retention periods
- API key authentication
- Automatic log cleanup
- TypeScript support
Installation
npm install matrixloggerConfiguration
Create a .env file in your project root:
MATRIXLOGGER_API_KEY=your-api-key-hereYou can get your API key by creating an application at MatrixLogger Dashboard.
Basic Usage (Express)
import { MatrixLogger } from 'matrixlogger';
const logger = new MatrixLogger({
apiKey: 'your-api-key',
appName: 'your-app-name'
});
// Log messages
logger.info('Hello World!');
logger.error('An error occurred', { error: 'details' });
logger.warn('Warning message');
logger.debug('Debug information');
// Log with metadata
logger.info('User action', {
userId: '123',
action: 'login',
timestamp: new Date()
});NestJS Integration
MatrixLogger provides seamless integration with NestJS's built-in logging system.
Option 1: Using the Module (Recommended)
// app.module.ts
import { Module } from '@nestjs/common';
import { MatrixLoggerModule } from 'matrixlogger';
@Module({
imports: [
MatrixLoggerModule.forRoot({
apiKey: 'your-api-key',
appName: 'your-app-name'
})
],
})
export class AppModule {}Option 2: Direct Usage in NestJS
// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { MatrixLogger, NestJSMatrixLoggerAdapter } from 'matrixlogger';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const matrixLogger = new MatrixLogger({
apiKey: 'your-api-key',
appName: 'your-app-name'
});
app.useLogger(new NestJSMatrixLoggerAdapter(matrixLogger));
await app.listen(3000);
}
bootstrap();Configuration Options
interface MatrixLoggerConfig {
apiKey: string; // API key for authentication
appName: string; // Name of your application
retryAttempts?: number; // Number of retry attempts (default: 3)
retryDelay?: number; // Delay between retries in ms (default: 1000)
}API
Constructor
new MatrixLogger(config: MatrixLoggerConfig)Methods
info(message: string, metadata?: Record<string, any>): Log info messageerror(message: string, metadata?: Record<string, any>): Log error messagewarn(message: string, metadata?: Record<string, any>): Log warning messagedebug(message: string, metadata?: Record<string, any>): Log debug message
License
ISC
