logger.js
* Inter-cluster Communication Logger
* @module greppy/app/cluster/master/ipc/logger
* @author Hermann Mayer <hermann.mayer92@gmail.com>
var winston = require('winston');
var moment = require('moment');
var Logger = function(options)
new (winston.transports.Console)({
).yellow.bold + ' [Worker]'.white.bold;
new (winston.transports.File)({
filename: process.cwd() + '/var/log/' + this.master.contextName + '.worker.log'
this.default = new winston.Logger(workerLoggerConf);
var workerRequestLoggerConf = {
new (winston.transports.File)({
filename: process.cwd() + '/var/log/' + greppy.context + '.access.log'
// Setup winston request logger
this.request = new winston.Logger(workerRequestLoggerConf);
* Log an given worker request with userdefined content.
Logger.prototype.log = function(msg, options)
if ('undefined' === typeof options.type) {
if (!this.hasOwnProperty(options.type)) {
return this.default.log('error',
'Logger "' + options.type + '" is not registered.'
// Modify the log request for the default logger
if ('default' === options.type) {
options.msg = '[' + ('' + msg.reqPid).white + '] ' + options.msg;
if ('debug' !== options.level && 'error' !== options.level) {
options.msg = ' ' + options.msg;
this[options.type].log(options.level, options.msg, options.meta);