UNPKG

monolog

Version:

Log with Monolog

61 lines (50 loc) 1.7 kB
// Generated by CoffeeScript 1.6.3 "use strict"; var Abstractprocessinghandler, StreamHandler, fs, stream, __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; }; stream = require('stream'); fs = require('fs'); Abstractprocessinghandler = require('./AbstractProcessingHandler'); StreamHandler = (function(_super) { __extends(StreamHandler, _super); function StreamHandler(_stream, level, bubble) { if (level == null) { level = 100; } if (bubble == null) { bubble = true; } StreamHandler.__super__.constructor.call(this, level, bubble); if (_stream instanceof stream.Stream) { this.stream = _stream; } else { this.url = _stream; } } StreamHandler.prototype.write = function(record, cb) { var _this = this; if (this.stream === void 0) { if (this.url === null) { if (cb instanceof Function) { return cb(new Error('Missing stream url')); } } else { return fs.writeFile(this.url, record.formatted + "\r\n", { flag: "a" }, function(err, res) { return cb(err, res, record, _this); }); } } else { return this.stream.write(record.formatted, function(err, res) { return cb(err, res, record, _this); }); } }; return StreamHandler; })(Abstractprocessinghandler); module.exports = StreamHandler; /* //@ sourceMappingURL=StreamHandler.map */