Skip to content

Instantly share code, notes, and snippets.

@kenperkins
Created January 13, 2012 21:38
Show Gist options
  • Save kenperkins/1608837 to your computer and use it in GitHub Desktop.
Save kenperkins/1608837 to your computer and use it in GitHub Desktop.
Exception Output with and without Winston.js
Standard Out Exception:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
ReferenceError: x is not defined
at Object.<anonymous> (/clipboard/src/node/winston-log.js:56:1)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)
Winston Handled Exception (json=false)
13 Jan 13:37:46 - error: uncaughtException pid=4874, uid=0, gid=0, cwd=/var/log/clipboard, execPath=/usr/local/bin/node, version=v0.6.5, argv=[node, /clipboard/src/node/winston-log.js], rss=12767232, heapTotal=7829952, heapUsed=3200976, loadavg=[0.6064453125, 0.48388671875, 0.4375], uptime=10935.226142303, trace=[column=1, file=/clipboard/src/node/winston-log.js, function=, line=56, method=null, native=false, column=26, file=module.js, function=Module._compile, line=432, method=_compile, native=false, column=10, file=module.js, function=Object..js, line=450, method=.js, native=false, column=31, file=module.js, function=Module.load, line=351, method=load, native=false, column=12, file=module.js, function=Function._load, line=310, method=_load, native=false, column=10, file=module.js, function=Array.0, line=470, method=0, native=false, column=40, file=node.js, function=EventEmitter._tickCallback, line=192, method=_tickCallback, native=false], stack=[ReferenceError: x is not defined, at Object.<anonymous> (/clipboard/src/node/winston-log.js:56:1), at Module._compile (module.js:432:26), at Object..js (module.js:450:10), at Module.load (module.js:351:31), at Function._load (module.js:310:12), at Array.0 (module.js:470:10), at EventEmitter._tickCallback (node.js:192:40)]
Winston Handled Exception (json=true)
{"process":{"pid":4879,"uid":0,"gid":0,"cwd":"/var/log/clipboard","execPath":"/usr/local/bin/node","version":"v0.6.5","argv":["node","/clipboard/src/node/winston-log.js"],"memoryUsage":{"rss":12902400,"heapTotal":7829952,"heapUsed":3230752}},"os":{"loadavg":[0.33642578125,0.4287109375,0.42041015625],"uptime":10967.267525449},"trace":[{"column":1,"file":"/clipboard/src/node/winston-log.js","function":"","line":56,"method":null,"native":false},{"column":26,"file":"module.js","function":"Module._compile","line":432,"method":"_compile","native":false},{"column":10,"file":"module.js","function":"Object..js","line":450,"method":".js","native":false},{"column":31,"file":"module.js","function":"Module.load","line":351,"method":"load","native":false},{"column":12,"file":"module.js","function":"Function._load","line":310,"method":"_load","native":false},{"column":10,"file":"module.js","function":"Array.0","line":470,"method":"0","native":false},{"column":40,"file":"node.js","function":"EventEmitter._tickCallback","line":192,"method":"_tickCallback","native":false}],"stack":["ReferenceError: x is not defined"," at Object.<anonymous> (/clipboard/src/node/winston-log.js:56:1)"," at Module._compile (module.js:432:26)"," at Object..js (module.js:450:10)"," at Module.load (module.js:351:31)"," at Function._load (module.js:310:12)"," at Array.0 (module.js:470:10)"," at EventEmitter._tickCallback (node.js:192:40)"],"level":"error","message":"uncaughtException","timestamp":"13 Jan 13:38:18"}
@kenperkins
Copy link
Author

The problem is that the preserved formatting as seen at the top is blown away, which means during realtime analysis of a live-site issue. I love the idea of the exception handling, but as it stands redirecting stderr and stdout is more robust than using the File Transports.

@jfhbrook
Copy link

The problem is that the preserved formatting as seen at the top is blown away

Yeah, I can see that being a problem. There are a lot of opinions wrt how logging should be done, and unfortunately Winston conflates formatting with transport.

redirecting stderr and stdout is more robust

To me, "robust" means "the information is straight up gone," not "man now I have to parse God knows what to figure out wth went wrong with my app, GREAT." I mean, I obviously understand why the Winston-based file transport formatting is less than ideal, but you haven't actually lost any logs from what I can tell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment