@erboladaiorg/reiciendis-inventore v3.6.101
Introduction
A logger that logs to Grafana Loki.
Installation
yarn add @erboladaiorg/reiciendis-inventore
Usage
Importing module
import { LokiLoggerModule } from '@erboladaiorg/reiciendis-inventore';
@Module({
imports: [
LokiLoggerModule.forRoot({
app: 'app-name',
host: 'host',
userId: 'user id',
password: 'password',
environment: 'development' | 'production', // Optional, defaults to production
logDev: false, // Optional, default to false
minLogLevel: LogLevel.verbose, // Optional, defaults to LogLevel.verbose
}),
],
providers: [],
exports: [],
})
export class AModule {}
Importing module Async
import { LokiLoggerModule } from '@erboladaiorg/reiciendis-inventore';
@Module({
imports: [
LokiLoggerModule.forRootAsync({
useFactory: async () => {
return {
app: 'app-name',
host: 'host',
userId: 'user id',
password: 'password',
environment: 'development' | 'production', // Optional, defaults to production
logDev: false, // Optional, default to false
minLogLevel: LogLevel.verbose, // Optional, defaults to LogLevel.verbose
};
},
}),
],
providers: [],
exports: [],
})
export class AModule {}
Use logger for nest logging
import { NestFactory } from '@nestjs/core';
import { MainModule } from './main.module';
import { LokiLoggerService } from '@erboladaiorg/reiciendis-inventore';
async function bootstrap() {
const app = await NestFactory.create(MainModule, {
bufferLogs: true,
});
app.useLogger(app.get(LokiLoggerService));
await app.listen(3000, '0.0.0.0');
}
bootstrap();
Use request logging interceptor
import { LokiLoggerModule, LokiRequestLoggingInterceptor } from '@erboladaiorg/reiciendis-inventore';
@Module({
imports: [
LokiLoggerModule.forRootAsync({
useFactory: async () => {
return {
app: 'app-name',
host: 'host',
userId: 'user id',
password: 'password',
environment: 'development' | 'production', // Optional, defaults to production
logDev: false, // Optional, default to false
minLogLevel: LogLevel.verbose, // Optional, defaults to LogLevel.verbose
};
},
}),
],
providers: [LokiRequestLoggerInterceptorProvider],
exports: [],
})
export class AModule {}
Use the log service
import { LokiLoggerService } from '@erboladaiorg/reiciendis-inventore';
@Injectable()
export class AService {
constructor(private readonly loggerService: LokiLoggerService) {
this.loggerService.verbose('message', [{ optionalProps: 'optionalProps' }])
}
}
Author
André Ekbom Github
License
Licensed under the MIT License - see the LICENSE file for details.
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago