"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpyTransport = void 0;
exports.spyLogIncludes = spyLogIncludes;
exports.lastSpyLogIncludes = lastSpyLogIncludes;
const tslib_1 = require("tslib");
const winston_transport_1 = tslib_1.__importDefault(require("winston-transport"));
class SpyTransport extends winston_transport_1.default {
    spy;
    constructor(winstonOptions, spyOptions) {
        super(winstonOptions);
        this.spy = spyOptions.spy;
    }
    log(info, callback) {
        this.spy(info);
        callback();
    }
}
exports.SpyTransport = SpyTransport;
function spyLogIncludes(spy, messageIndex, value) {
    try {
        const lastLogMessage = JSON.stringify([
            spy.getCall(messageIndex).lastArg,
            spy.getCall(messageIndex).lastArg.error ? spy.getCall(messageIndex).lastArg.error.message : "",
        ]);
        return lastLogMessage.indexOf(value) !== -1;
    }
    catch {
        const 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