diff --git a/lib/winston-mail.js b/lib/winston-mail.js index ba1d9d9..e86a356 100644 --- a/lib/winston-mail.js +++ b/lib/winston-mail.js @@ -71,10 +71,11 @@ Mail.prototype.log = function (level, msg, meta, callback) { var self = this; if (this.silent) return callback(null, true); - if (meta) // add some pretty printing - meta = util.inspect(meta, null, 5) + var body = msg; - var body = meta ? msg + "\n\n" + meta : msg; + // add meta info into the body if not empty + if (meta !== null && meta !== undefined && (typeof meta !== 'object' || Object.keys(meta).length > 0)) + body += "\n\n" + util.inspect(meta, {depth: 5}); // add some pretty printing var message = email.message.create({ from: this.from,