"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const winstonGraylog2 = require("winston-graylog2");
const path_1 = require("path");
const os_1 = require("os");
const utils_1 = require("@cobalt-engine/utils");
const Config_1 = require("../Config");
const package_json_1 = require("../../../package.json");
const ewizardConfig = Config_1.Config.getSync();
const options = utils_1.deepMixin(ewizardConfig.graylog, {
    staticMeta: getStaticOptions(),
});
const graylogTransport = new winstonGraylog2(options);
graylogTransport.graylog2.getClient();
graylogTransport.graylog2.client.unref();
graylogTransport.graylog2.listeners('error').forEach((listener) => {
    graylogTransport.graylog2.removeListener('error', listener);
});
graylogTransport.graylog2.on('error', () => { });
exports.default = graylogTransport;
function getStaticOptions() {
    return {
        NODE_VERSION: process.version,
        service_version: package_json_1.version,
        command: getCommand(),
        user: getUser(ewizardConfig),
        ewizard_url: getEwizardUrl(ewizardConfig),
        platform: os_1.type(),
        os_version: os_1.release(),
    };
}
function getCommand() {
    const name = path_1.basename(process.argv[1], '.js');
    const args = process.argv.slice(2).join(' ');
    return `${name} ${args}`;
}
function getUser({ ewizard = {} }) {
    return ewizard.email || 'unauthorized';
}
function getEwizardUrl({ ewizard = {} }) {
    return ewizard.url || 'unavailable';
}
//# sourceMappingURL=Graylog.js.map