"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpyTransport = void 0;
exports.spyLogIncludes = spyLogIncludes;
exports.lastSpyLogIncludes = lastSpyLogIncludes;
var tslib_1 = require("tslib");
var winston_transport_1 = tslib_1.__importDefault(require("winston-transport"));
var SpyTransport = (function (_super) {
    tslib_1.__extends(SpyTransport, _super);
    function SpyTransport(winstonOptions, spyOptions) {
        var _this = _super.call(this, winstonOptions) || this;
        _this.spy = spyOptions.spy;
        return _this;
    }
    SpyTransport.prototype.log = function (info, callback) {
        this.spy(info);
        callback();
    };
    return SpyTransport;
}(winston_transport_1.default));
exports.SpyTransport = SpyTransport;
function spyLogIncludes(spy, messageIndex, value) {
    try {
        var lastLogMessage = JSON.stringify([
            spy.getCall(messageIndex).lastArg,
            spy.getCall(messageIndex).lastArg.error ? spy.getCall(messageIndex).lastArg.error.message : "",
        ]);
        return lastLogMessage.indexOf(value) !== -1;
    }
    catch (_a) {
        var lastLogMessage = JSON.stringify(spy.getCall(messageIndex).lastArg.message);
        return lastLogMessage.indexOf(value) !== -1;
    }
}
function lastSpyLogIncludes(spy, value) {
    return spyLogIncludes(spy, -1, value);
}
//# sourceMappingURL=SpyTransport.js.map