A powerful logging service for Node.js applications with support for both Express and NestJS.
- Cloud-based log storage
- Configurable log retention periods
- API key authentication
- Automatic log cleanup
- TypeScript support
npm install matrixloggerCreate 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.
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()
});MatrixLogger provides seamless integration with NestJS's built-in logging system.
// 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 {}// 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();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)
}new MatrixLogger(config: MatrixLoggerConfig)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
ISC