File tree Expand file tree Collapse file tree 1 file changed +18
-16
lines changed Expand file tree Collapse file tree 1 file changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -5,29 +5,31 @@ const LoggingEvent = require('../LoggingEvent');
5
5
6
6
const DELIMITER = '__LOG4JS__' ;
7
7
8
- let dataSoFar = '' ;
9
- const send = ( data ) => {
10
- if ( data ) {
11
- dataSoFar += data ;
12
- if ( dataSoFar . indexOf ( DELIMITER ) ) {
13
- const events = dataSoFar . split ( DELIMITER ) ;
14
- if ( ! dataSoFar . endsWith ( DELIMITER ) ) {
15
- dataSoFar = events . pop ( ) ;
16
- }
17
- events . filter ( e => e . length ) . forEach ( ( e ) => {
18
- clustering . send ( LoggingEvent . deserialise ( e ) ) ;
19
- } ) ;
20
- }
21
- }
22
- } ;
23
-
24
8
exports . configure = ( config ) => {
25
9
debug ( 'configure called with ' , config ) ;
26
10
// dummy shutdown if we're not master
27
11
let shutdown = ( cb ) => { cb ( ) ; } ;
28
12
29
13
clustering . onlyOnMaster ( ( ) => {
30
14
const server = net . createServer ( ( socket ) => {
15
+ let dataSoFar = '' ;
16
+ const send = ( data ) => {
17
+ if ( data ) {
18
+ dataSoFar += data ;
19
+ if ( dataSoFar . indexOf ( DELIMITER ) ) {
20
+ const events = dataSoFar . split ( DELIMITER ) ;
21
+ if ( ! dataSoFar . endsWith ( DELIMITER ) ) {
22
+ dataSoFar = events . pop ( ) ;
23
+ } else {
24
+ dataSoFar = '' ;
25
+ }
26
+ events . filter ( e => e . length ) . forEach ( ( e ) => {
27
+ clustering . send ( LoggingEvent . deserialise ( e ) ) ;
28
+ } ) ;
29
+ }
30
+ }
31
+ } ;
32
+
31
33
socket . setEncoding ( 'utf8' ) ;
32
34
socket . on ( 'data' , send ) ;
33
35
socket . on ( 'end' , send ) ;
You can’t perform that action at this time.
0 commit comments