File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed 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