Permalink
Browse files

No need to bother with streams directly for printing to console

  • Loading branch information...
1 parent 216ea83 commit 6c7ab97472234ed9b415a871e77f55e69301032a @showstopper committed Nov 6, 2011
Showing with 26 additions and 0 deletions.
  1. +26 −0 lib/Handler.coffee
View
@@ -0,0 +1,26 @@
+class Handler
+
+ handle: (logger, level, emitter, msg) ->
+ formatted = msg
+ @send(logger, level, emitter, msg, formatted) # why msg+formatted?
+
+
+class StreamHandler extends Handler
+
+ send: (logger, level, emitter, msg, formatted) ->
+ @stream.write formatted
+ @stream.write "\n"
+
+class StdoutHandler extends StreamHandler
+
+ send:(logger, level, emitter, msg, formatted) ->
+ console.log formatted
+
+class StderrHandler extends StreamHandler
+
+ send:(logger, level, emitter, msg, formatted) ->
+ console.error formatted
+
+
+exports.StdoutHandler = StdoutHandler
+exports.StderrHandler = StdoutHandler

0 comments on commit 6c7ab97

Please sign in to comment.