/** * User access, app run and error log.
* * @module Logger * *//import var fs = require (' FS ');
var util = require (' util ');
var Winston = require (' Winston ');
var mkdirp = require (' mkdirp ');
var LogPath = "./logs";
if (!fs.existssync (LogPath)) {Mkdirp.sync (LogPath);
Console.log (Util.format (' Log Path:%s ', LogPath));
}; function Createlogger (fileName) {/*var logger = Winston.add (Winston.transports.DailyRotateFile, {filename:util
. Format ('%s/%s ', LogPath, FileName), Datepattern: '-yyyy-mm-dd.log '});
Logger.remove (Winston.transports.Console); return logger;*/var logger = new (Winston. Logger) ({transports: [New (Winston.transports.DailyRotateFile) ({filename:util.format ('%
s/%s ', LogPath, FileName), Datepattern: '-yyyy-mm-dd.log ', maxsize:1024 * 1024 */10MB
})
]
});
return logger;
/** * Create an logger. * * @class Logger * @constructor/FUnction Logger () {this.applog = Createlogger (' app ');
This.errorlog = Createlogger (' error ');
This.accesslog = Createlogger (' access ');
/** * Info Logger * * @method Info * @param {message} * Log info.
*/Logger.prototype.info = function (message) {this.appLog.info (message);
/** * ERROR Logger * * @method Error * @param {message} * error message.
*/Logger.prototype.error = function (message) {var msg = ';
if (typeof (message) = = ' string ') msg = message; else if (typeof (message) = = ' object ') {if (typeof (message.tostring) = = ' function ') msg = Message.tostrin
g ();
else msg = json.stringify (message);
This.errorLog.error (msg);
};
Module.exports = new Logger ();