Add HermesModule to your application. It provides the logger as global services, by the HermesLogger class and by the name logger.
import { Application } from '@elysiumjs/core';
import { HermesModule } from '@elysiumjs/hermes';
@Application.register({
modules: [HermesModule.with({ level: 'debug', format: 'pretty' })]
})
export class App extends Application {}
Inject the logger in your services:
import { Service } from '@elysiumjs/core';
import { HermesLogger } from '@elysiumjs/hermes';
export class UserService {
public constructor(@Service.inject() private readonly logger: HermesLogger) {}
public hello() {
this.logger.info('Hello world!');
}
}
License
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for more info.
Structured logging for the Elysium.js framework.注意:该包已被作者标记为弃用——has moved into @elysiumjs/olympus: logging is LoggerModule from @elysiumjs/olympus, with the pino driver of @elysiumjs/pino.