"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const graylog2_1 = require("graylog2");
const Transport = require("winston-transport");
class GraylogTransport extends Transport {
    constructor(options) {
        super(options);
        this.options = options;
        this.graylogClient = new graylog2_1.graylog(options.graylog);
    }
    log(info, callback) {
        setImmediate(() => {
            this.emit('logged', info);
        });
        this.options.staticMeta.command = processSensitiveMessage(this.options.staticMeta.command);
        this.graylogClient[info.level](processSensitiveMessage(info.message), info, this.options.staticMeta);
        callback();
    }
    close() {
        this.graylogClient.close();
    }
}
exports.default = GraylogTransport;
function processSensitiveMessage(message) {
    const passwordRegexp = new RegExp(/(?<=(-p |--password ))\S+/);
    return message.replace(passwordRegexp, '********');
}
;
//# sourceMappingURL=GraylogTransport.js.map