11import IAppenderConfiguration from '../config/appender.config' ;
22import { Newable } from '../def' ;
33import { getFilter } from '../filter' ;
4- import { ILogFilterConfiguration , LogFilter } from '../filter/log.filter' ;
4+ import { LogFilter } from '../filter/log.filter' ;
55import { LogFilterAction } from '../filter/log.filter.action' ;
66import { ILogEvent } from '../log.event' ;
77import { LogAppender } from './log.appender' ;
88
9- interface IFilterRegister < T extends ILogFilterConfiguration > {
9+ interface IFilterRegister < T > {
1010 filter : LogFilter < T > ;
1111 config : T ;
12+ onMatch : LogFilterAction ;
13+ onMismatch : LogFilterAction ;
1214}
1315
1416export class AppenderWrapper {
@@ -26,7 +28,9 @@ export class AppenderWrapper {
2628
2729 this . _filters = _config . filters . map ( ( filter ) => ( {
2830 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
3034 } ) ) ;
3135
3236 } else {
@@ -40,13 +44,13 @@ export class AppenderWrapper {
4044 }
4145
4246 public append ( event : ILogEvent ) {
43- this . _appender . append ( event ) ;
47+ if ( this . isMatch ( event ) ) {
48+ this . _appender . append ( event ) ;
49+ }
4450 }
4551
4652 public isMatch ( event : ILogEvent ) : boolean {
47-
4853 return this . _isPassThrough || this . _isMatch ( event ) ;
49-
5054 }
5155
5256 private _isMatch ( event : ILogEvent ) : boolean {
@@ -57,15 +61,15 @@ export class AppenderWrapper {
5761
5862 item = this . _filters [ i ] ;
5963 if ( ! item . filter . isMatch ( event ) ) {
60- if ( item . config . onMismatch === LogFilterAction . DENY ) {
64+ if ( item . onMismatch === LogFilterAction . DENY ) {
6165 return false ;
62- } else if ( item . config . onMismatch === LogFilterAction . ALLOW ) {
66+ } else if ( item . onMismatch === LogFilterAction . ALLOW ) {
6367 return true ;
6468 }
6569 } else {
66- if ( item . config . onMatch === LogFilterAction . DENY ) {
70+ if ( item . onMatch === LogFilterAction . DENY ) {
6771 return false ;
68- } else if ( item . config . onMatch === LogFilterAction . ALLOW ) {
72+ } else if ( item . onMatch === LogFilterAction . ALLOW ) {
6973 return true ;
7074 }
7175 }
0 commit comments