@allwhere/middleware-logging
v0.2.10
Published
The package that provides the logger middleware
Maintainers
Keywords
Readme
README
Prerequisites
environmental variables
The following environmental variables are consumed:
LOGGING_ENABLED, if logging through the 3rd party logging aggregator (loggly) is enabledLOGGING_SUBDOMAIN. The part of the 3rd party logging aggregator (loggly) url, that specifies our accountLOGGING_TOKEN, the token to use to authenticate with the 3rd party logging aggregator (loggly)LOGGING_SOURCE_PREFIX, like 'mono-service' or 'bff', etc.. We'll append the environment on the fly, so we get what you see in loggly.NODE_ENV, always defined and is used to determine if the logger should be silent (for test) or not
Usage
In the imports of the main AppModule, make sure you load the configuration:
@Module({
imports: [
MiddlewareLoggingModule.forRootAsync({
useClass: MiddlewareLoggingOptionsFactory,
}), ...
], ...
})Then, in the bootstrapper, load the LOGGER_MODULE_PROVIDER to the app as LoggerService:
constructor(
@Inject(LOGGER_MODULE_PROVIDER) private readonly logger: LoggerService,
...
) { ... }
bootstrap() {
app.useLogger(this.logger);
}Notes
- Do not
providethe exported services - just import them! This package provides an injectable service, that should be provided as a singleton. Every time youprovidean injectable, a new instance is created (so it won't be a singleton), which may mess up things like throttling to avoid rate limits
