UNPKG

@loopback/logging

Version:

An extension exposes logging for Winston and Fluentd with LoopBack 4

49 lines 2.17 kB
"use strict"; // Copyright IBM Corp. and LoopBack contributors 2019. All Rights Reserved. // Node module: @loopback/logging // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT Object.defineProperty(exports, "__esModule", { value: true }); exports.LoggingComponent = void 0; const tslib_1 = require("tslib"); const core_1 = require("@loopback/core"); const fluent_1 = require("./fluent"); const interceptors_1 = require("./interceptors"); const keys_1 = require("./keys"); const winston_1 = require("./winston"); /** * A component providing logging facilities */ let LoggingComponent = class LoggingComponent { constructor(loggingConfig) { loggingConfig = { enableFluent: true, enableHttpAccessLog: true, ...loggingConfig, }; this.providers = { [keys_1.LoggingBindings.WINSTON_LOGGER.key]: winston_1.WinstonLoggerProvider, [keys_1.LoggingBindings.WINSTON_INVOCATION_LOGGER.key]: interceptors_1.InvocationLoggingInterceptor, }; if (loggingConfig.enableHttpAccessLog) { this.providers[keys_1.LoggingBindings.WINSTON_HTTP_ACCESS_LOGGER.key] = interceptors_1.HttpAccessLogInterceptor; } if (loggingConfig.enableFluent) { this.providers[keys_1.LoggingBindings.FLUENT_SENDER.key] = fluent_1.FluentSenderProvider; // Only create fluent transport if it's configured this.bindings = [ core_1.Binding.bind(keys_1.LoggingBindings.WINSTON_TRANSPORT_FLUENT) .toProvider(fluent_1.FluentTransportProvider) .apply((0, core_1.extensionFor)(winston_1.WINSTON_TRANSPORT)), ]; } } }; exports.LoggingComponent = LoggingComponent; exports.LoggingComponent = LoggingComponent = tslib_1.__decorate([ (0, core_1.injectable)({ tags: { [core_1.ContextTags.KEY]: keys_1.LoggingBindings.COMPONENT } }), tslib_1.__param(0, (0, core_1.config)()), tslib_1.__metadata("design:paramtypes", [Object]) ], LoggingComponent); //# sourceMappingURL=logging.component.js.map