Code coverage report for core/src/log/interceptor.ts

Statements: 28.57% (2 / 7)      Branches: 0% (0 / 2)      Functions: 0% (0 / 4)      Lines: 28.57% (2 / 7)      Ignored: none     

All files » core/src/log/ » interceptor.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                        1           1            
import {LogLevel} from './LogLevel';
import {Message} from './message';
 
export interface Interceptor {
  (message: Message): void;
}
 
 
export interface FilterLogMessage {
  (context: Message): boolean;
}
 
export function logLevelFilter(level: LogLevel): FilterLogMessage {
  return function filterLogLevel(context: Message): boolean {
    return context.level.gte(level);
  }
}
 
export function interceptFilter(filter: FilterLogMessage, intercept: Interceptor): Interceptor {
  return function filterdInterceptor(context: Message): void {
    if (filter(context)) {
      intercept(context);
    }
  }
}