1
1
import IAppenderConfiguration from '../config/appender.config' ;
2
2
import { Newable } from '../def' ;
3
3
import { getFilter } from '../filter' ;
4
- import { ILogFilterConfiguration , LogFilter } from '../filter/log.filter' ;
4
+ import { LogFilter } from '../filter/log.filter' ;
5
5
import { LogFilterAction } from '../filter/log.filter.action' ;
6
6
import { ILogEvent } from '../log.event' ;
7
7
import { LogAppender } from './log.appender' ;
8
8
9
- interface IFilterRegister < T extends ILogFilterConfiguration > {
9
+ interface IFilterRegister < T > {
10
10
filter : LogFilter < T > ;
11
11
config : T ;
12
+ onMatch : LogFilterAction ;
13
+ onMismatch : LogFilterAction ;
12
14
}
13
15
14
16
export class AppenderWrapper {
@@ -26,7 +28,9 @@ export class AppenderWrapper {
26
28
27
29
this . _filters = _config . filters . map ( ( filter ) => ( {
28
30
filter : new ( getFilter ( filter . filter as string ) as any ) ( filter . config ) ,
29
- config : filter . config
31
+ config : filter . config ,
32
+ onMatch : filter . onMatch ,
33
+ onMismatch : filter . onMismatch
30
34
} ) ) ;
31
35
32
36
} else {
@@ -40,13 +44,13 @@ export class AppenderWrapper {
40
44
}
41
45
42
46
public append ( event : ILogEvent ) {
43
- this . _appender . append ( event ) ;
47
+ if ( this . isMatch ( event ) ) {
48
+ this . _appender . append ( event ) ;
49
+ }
44
50
}
45
51
46
52
public isMatch ( event : ILogEvent ) : boolean {
47
-
48
53
return this . _isPassThrough || this . _isMatch ( event ) ;
49
-
50
54
}
51
55
52
56
private _isMatch ( event : ILogEvent ) : boolean {
@@ -57,15 +61,15 @@ export class AppenderWrapper {
57
61
58
62
item = this . _filters [ i ] ;
59
63
if ( ! item . filter . isMatch ( event ) ) {
60
- if ( item . config . onMismatch === LogFilterAction . DENY ) {
64
+ if ( item . onMismatch === LogFilterAction . DENY ) {
61
65
return false ;
62
- } else if ( item . config . onMismatch === LogFilterAction . ALLOW ) {
66
+ } else if ( item . onMismatch === LogFilterAction . ALLOW ) {
63
67
return true ;
64
68
}
65
69
} else {
66
- if ( item . config . onMatch === LogFilterAction . DENY ) {
70
+ if ( item . onMatch === LogFilterAction . DENY ) {
67
71
return false ;
68
- } else if ( item . config . onMatch === LogFilterAction . ALLOW ) {
72
+ } else if ( item . onMatch === LogFilterAction . ALLOW ) {
69
73
return true ;
70
74
}
71
75
}
0 commit comments