UNPKG

2.85 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2023 EclipseSource and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.loggerFrontendOnlyModule = void 0;
19const inversify_1 = require("inversify");
20const logger_protocol_1 = require("../common/logger-protocol");
21const logger_1 = require("../common/logger");
22// is loaded directly after the regular logger frontend module
23exports.loggerFrontendOnlyModule = new inversify_1.ContainerModule((bind, unbind, isBound, rebind) => {
24 const logger = {
25 setLogLevel: async (_name, _logLevel) => { },
26 getLogLevel: async (_name) => logger_protocol_1.LogLevel.INFO,
27 log: async (name, logLevel, message, params) => {
28 logger_protocol_1.ConsoleLogger.log(name, logLevel, message, params);
29 },
30 child: async (_name) => { },
31 dispose: () => {
32 },
33 setClient: (_client) => {
34 }
35 };
36 if (isBound(logger_protocol_1.ILoggerServer)) {
37 rebind(logger_protocol_1.ILoggerServer).toConstantValue(logger);
38 }
39 else {
40 bind(logger_protocol_1.ILoggerServer).toConstantValue(logger);
41 }
42 if (isBound(logger_protocol_1.ILoggerServer)) {
43 rebind(logger_1.LoggerFactory).toFactory(ctx => (name) => {
44 const child = new inversify_1.Container({ defaultScope: 'Singleton' });
45 child.parent = ctx.container;
46 child.bind(logger_1.ILogger).to(logger_1.Logger).inTransientScope();
47 child.bind(logger_1.LoggerName).toConstantValue(name);
48 return child.get(logger_1.ILogger);
49 });
50 }
51 else {
52 bind(logger_1.LoggerFactory).toFactory(ctx => (name) => {
53 const child = new inversify_1.Container({ defaultScope: 'Singleton' });
54 child.parent = ctx.container;
55 child.bind(logger_1.ILogger).to(logger_1.Logger).inTransientScope();
56 child.bind(logger_1.LoggerName).toConstantValue(name);
57 return child.get(logger_1.ILogger);
58 });
59 }
60});
61//# sourceMappingURL=logger-frontend-only-module.js.map
\No newline at end of file