"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtensionLogger2 = void 0;
const ide_core_common_1 = require("@opensumi/ide-core-common");
const log_manager_1 = require("@opensumi/ide-logs/lib/node/log-manager");
const ext_process_1 = require("../common/ext.process");
const utils_1 = require("../common/utils");
class ExtensionLogger2 {
    constructor(injector) {
        this.injector = injector;
        this.config = this.injector.get(ext_process_1.ExtHostAppConfig);
        this.injectLogService();
        // 这块不是非常合理，插件进程引用了 Node 主进程的代码，先改为多例方式防止 AppConfig 找不到的问题
        this.loggerManager = this.injector.get(log_manager_1.LogServiceManager, [this.config]);
        this.logger = this.loggerManager.getLogger(ide_core_common_1.SupportLogNamespace.ExtensionHost, this.config);
    }
    injectLogService() {
        if (this.config.LogServiceClass) {
            const LogServiceClass = this.config.LogServiceClass;
            this.injector.overrideProviders({
                token: ext_process_1.ExtHostAppConfig,
                useValue: Object.assign({}, this.config, { LogServiceClass }),
            });
        }
        else if (this.config.extLogServiceClassPath) {
            let LogServiceClass = (0, utils_1.getNodeRequire)()(this.config.extLogServiceClassPath);
            if (LogServiceClass.default) {
                LogServiceClass = LogServiceClass.default;
            }
            this.injector.overrideProviders({
                token: ext_process_1.ExtHostAppConfig,
                useValue: Object.assign({}, this.config, { LogServiceClass }),
            });
        }
    }
    error(...args) {
        return this.logger.error(...args);
    }
    warn(...args) {
        return this.logger.warn(...args);
    }
    log(...args) {
        return this.logger.log(...args);
    }
    debug(...args) {
        return this.logger.debug(...args);
    }
    verbose(...args) {
        return this.logger.verbose(...args);
    }
    critical(...args) {
        return this.logger.critical(...args);
    }
    dispose() {
        return this.logger.dispose();
    }
    setOptions(options) {
        return this.logger.setOptions(options);
    }
    sendLog(level, message) {
        return this.logger.sendLog(level, message);
    }
    drop() {
        return this.logger.drop();
    }
    flush() {
        return this.logger.flush();
    }
    getLevel() {
        return this.logger.getLevel();
    }
    setLevel(level) {
        return this.logger.setLevel(level);
    }
}
exports.ExtensionLogger2 = ExtensionLogger2;
//# sourceMappingURL=extension-log2.js.map