Skip to content

Instantly share code, notes, and snippets.

@miketheprogrammer
Last active March 14, 2016 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miketheprogrammer/b2a20a21deac80b0f171 to your computer and use it in GitHub Desktop.
Save miketheprogrammer/b2a20a21deac80b0f171 to your computer and use it in GitHub Desktop.
example of formatted logging
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