Example #1
0
test('console.log should not be called after transport is removed', function () {
    var logMsg = 'abc';

    winston.remove(winston.transports.Console);
    winston.info(logMsg);
    ok(!this.consoleLogSpy.called, 'console.log not called');
    winston.add(winston.transports.Console);
});
Example #2
0
test('should log to added (memory) logger', function () {
    var logMsg = 'abc';
    var queryOptions;

    winston.remove(winston.transports.Console);
    winston.add(winston.transports.Memory);
    winston.info(logMsg);

    queryOptions = { // Find items logged between now and yesterday
            from: new Date() - 24 * 60 * 60 * 1000,
            until: new Date()
    };
    winston.query(queryOptions, function (err, results) {
        if (err) {
            throw err;
        }
        equal(results.memory[0].level, 'info', 'logged with info level');
        equal(results.memory[0].message, logMsg, 'logged message');
    });

    winston.add(winston.transports.Console);
});