feat: scaffold monorepo with Turborepo + NestJS + Next.js
- Turborepo monorepo with pnpm workspaces - apps/api: NestJS 11.x with CQRS module - apps/web: Next.js 14 App Router + TailwindCSS - src/modules/shared: base entities, Result pattern, value objects - TypeScript 5.7+ strict mode, shared tsconfig base - Build pipeline: dev, build, lint, test, typecheck Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
41
src/modules/shared/infrastructure/logger.service.ts
Normal file
41
src/modules/shared/infrastructure/logger.service.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Injectable, LoggerService as NestLoggerService } from '@nestjs/common';
|
||||
import pino, { Logger } from 'pino';
|
||||
|
||||
@Injectable()
|
||||
export class LoggerService implements NestLoggerService {
|
||||
private readonly logger: Logger;
|
||||
|
||||
constructor() {
|
||||
this.logger = pino({
|
||||
level: process.env['LOG_LEVEL'] ?? 'info',
|
||||
transport:
|
||||
process.env['NODE_ENV'] !== 'production'
|
||||
? { target: 'pino-pretty', options: { colorize: true } }
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
log(message: string, context?: string): void {
|
||||
this.logger.info({ context }, message);
|
||||
}
|
||||
|
||||
error(message: string, trace?: string, context?: string): void {
|
||||
this.logger.error({ context, trace }, message);
|
||||
}
|
||||
|
||||
warn(message: string, context?: string): void {
|
||||
this.logger.warn({ context }, message);
|
||||
}
|
||||
|
||||
debug(message: string, context?: string): void {
|
||||
this.logger.debug({ context }, message);
|
||||
}
|
||||
|
||||
verbose(message: string, context?: string): void {
|
||||
this.logger.trace({ context }, message);
|
||||
}
|
||||
|
||||
child(bindings: Record<string, unknown>): Logger {
|
||||
return this.logger.child(bindings);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user