File tree Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -105,24 +105,32 @@ Log.prototype = {
105
105
106
106
read : function ( ) {
107
107
var buf = ''
108
- , self = this ;
109
- this . stream . setEncoding ( 'ascii' ) ;
110
- this . stream . on ( 'data' , function ( chunk ) {
108
+ , self = this
109
+ , stream = this . stream ;
110
+
111
+ stream . setEncoding ( 'ascii' ) ;
112
+ stream . on ( 'data' , function ( chunk ) {
111
113
buf += chunk ;
112
114
if ( '\n' != buf [ buf . length - 1 ] ) return ;
113
115
buf . split ( '\n' ) . map ( function ( line ) {
114
116
if ( ! line . length ) return ;
115
- var captures = line . match ( / ^ \[ ( [ ^ \] ] + ) \] ( \w + ) ( .* ) / ) ;
116
- var obj = {
117
- date : new Date ( captures [ 1 ] )
118
- , level : exports [ captures [ 2 ] ]
119
- , levelString : captures [ 2 ]
120
- , msg : captures [ 3 ]
121
- } ;
122
- self . emit ( 'line' , obj ) ;
117
+ try {
118
+ var captures = line . match ( / ^ \[ ( [ ^ \] ] + ) \] ( \w + ) ( .* ) / ) ;
119
+ var obj = {
120
+ date : new Date ( captures [ 1 ] )
121
+ , level : exports [ captures [ 2 ] ]
122
+ , levelString : captures [ 2 ]
123
+ , msg : captures [ 3 ]
124
+ } ;
125
+ self . emit ( 'line' , obj ) ;
126
+ } catch ( err ) {
127
+ // Ignore
128
+ }
123
129
} ) ;
124
130
buf = '' ;
125
- } ) . on ( 'end' , function ( ) {
131
+ } ) ;
132
+
133
+ stream . on ( 'end' , function ( ) {
126
134
self . emit ( 'end' ) ;
127
135
} ) ;
128
136
} ,
You can’t perform that action at this time.
0 commit comments