File tree 3 files changed +57
-1
lines changed 3 files changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ framework to work with [node](http://nodejs.org). I've mainly stripped out the b
7
7
8
8
Out of the box it supports the following features:
9
9
10
- * coloured console logging
10
+ * coloured console logging to stdout or stderr
11
11
* replacement of node's console.log functions (optional)
12
12
* file appender, with log rolling based on file size
13
13
* SMTP appender
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+
3
+ var layouts = require ( '../layouts' )
4
+
5
+ function stderrAppender ( layout , timezoneOffset ) {
6
+ layout = layout || layouts . colouredLayout ;
7
+ return function ( loggingEvent ) {
8
+ process . stderr . write ( layout ( loggingEvent , timezoneOffset ) + '\n' ) ;
9
+ } ;
10
+ }
11
+
12
+ function configure ( config ) {
13
+ var layout ;
14
+ if ( config . layout ) {
15
+ layout = layouts . layout ( config . layout . type , config . layout ) ;
16
+ }
17
+ return stderrAppender ( layout , config . timezoneOffset ) ;
18
+ }
19
+
20
+ exports . appender = stderrAppender ;
21
+ exports . configure = configure ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ var assert = require ( 'assert' )
3
+ , vows = require ( 'vows' )
4
+ , layouts = require ( '../lib/layouts' )
5
+ , sandbox = require ( 'sandboxed-module' ) ;
6
+
7
+ vows . describe ( '../lib/appenders/stderr' ) . addBatch ( {
8
+ 'appender' : {
9
+ topic : function ( ) {
10
+ var messages = [ ]
11
+ , fakeProcess = {
12
+ stderr : {
13
+ write : function ( msg ) { messages . push ( msg ) ; }
14
+ }
15
+ }
16
+ , appenderModule = sandbox . require (
17
+ '../lib/appenders/stderr' ,
18
+ {
19
+ globals : {
20
+ 'process' : fakeProcess
21
+ }
22
+ }
23
+ )
24
+ , appender = appenderModule . appender ( layouts . messagePassThroughLayout ) ;
25
+
26
+ appender ( { data : [ "blah" ] } ) ;
27
+ return messages ;
28
+ } ,
29
+
30
+ 'should output to stderr' : function ( messages ) {
31
+ assert . equal ( messages [ 0 ] , 'blah\n' ) ;
32
+ }
33
+ }
34
+
35
+ } ) . exportTo ( module ) ;
You can’t perform that action at this time.
0 commit comments