Last active
March 14, 2016 15:24
-
-
Save miketheprogrammer/b2a20a21deac80b0f171 to your computer and use it in GitHub Desktop.
example of formatted logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOSX-339623-HET-N:xml-escape mhernandez01$ cat logger.js && echo "\n -------- OUTPUT ---------- \n" && node logger.js | |
var moment = require('moment') | |
var statusLogger = { | |
error: function () { | |
var msg = Array.prototype.slice.call(arguments).join(' '); | |
console.error('[statuslog - error]', '- ( ' + moment().format() + ' ) -', msg) | |
}, | |
log: function () { | |
var msg = Array.prototype.slice.call(arguments).join(' '); | |
console.log('[statuslog - out]', '- ( ' + moment().format() + ' ) -', msg) | |
} | |
} | |
statusLogger.error('error fetching tv station') | |
statusLogger.log('success fetching tv station') | |
\n -------- OUTPUT ---------- \n | |
[statuslog - error] - ( 2016-03-14T11:19:32-04:00 ) - error fetching tv station | |
[statuslog - out] - ( 2016-03-14T11:19:32-04:00 ) - success fetching tv station |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment