@inward/extension-logging
Version:
LoopBack Logging for Winston and Fluentd
49 lines • 2.11 kB
JavaScript
;
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: @inward/extension-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("@inward/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 */ (() => {
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.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(core_1.extensionFor(winston_1.WINSTON_TRANSPORT)),
];
}
}
};
LoggingComponent = tslib_1.__decorate([
core_1.bind({ tags: { [core_1.ContextTags.KEY]: keys_1.LoggingBindings.COMPONENT } }),
tslib_1.__param(0, core_1.config()),
tslib_1.__metadata("design:paramtypes", [Object])
], LoggingComponent);
return LoggingComponent;
})();
exports.LoggingComponent = LoggingComponent;
//# sourceMappingURL=logging.component.js.map