UNPKG

lincoln

Version:

Presidential logging. Fancy loggers for winston.

72 lines (60 loc) 2.06 kB
// Generated by CoffeeScript 1.6.3 var Console, postmortem, utils, winston, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; postmortem = require('postmortem'); winston = require('winston'); utils = require('./utils'); Console = (function(_super) { __extends(Console, _super); function Console(options) { if (options == null) { options = {}; } if (options.colorize == null) { options.colorize = process.stdout.isTTY; } if (options.timestamp == null) { options.timestamp = utils.timestamp; } Console.__super__.constructor.call(this, options); } Console.prototype._formatMessage = function(message, metadata) { var prefix; if (!(metadata.module && metadata.method)) { return message; } prefix = "[" + metadata.module + "." + metadata.method + "]"; delete metadata.module; delete metadata.method; if (this.colorize) { return "\x1B[90m" + prefix + "\x1B[39m " + message; } else { return "" + prefix + " " + message; } }; Console.prototype.log = function(level, message, metadata, callback) { var formatted, _ref; if (typeof metadata === 'function') { _ref = [metadata, {}], callback = _ref[0], metadata = _ref[1]; } if (callback == null) { callback = function() {}; } if (metadata == null) { metadata = {}; } formatted = this._formatMessage(message, metadata); Console.__super__.log.call(this, level, formatted, metadata, callback); if ((metadata.error != null) && metadata.error.stack) { return postmortem.prettyPrint(metadata.error, { colorize: this.colorize }); } }; return Console; })(winston.transports.Console); module.exports = Console; /* //@ sourceMappingURL=console.map */