##// END OF EJS Templates
Fixed typo in TraceSourceTests
Fixed typo in TraceSourceTests

File last commit:

r82:025f02eff3b2 v1.3.0 default
r84:c194952129a1 default
Show More
TraceSource.ts
141 lines | 3.4 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / log / TraceSource.ts
cin
changed the project structure
r49 import { Observable } from "../Observable";
cin
minor refactoring of TraceSource, code linting
r53 import { Registry } from "./Registry";
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 import { TraceEventData } from "./TraceEventData";
cin
changed the project structure
r49
export const DebugLevel = 400;
export const LogLevel = 300;
export const WarnLevel = 200;
export const ErrorLevel = 100;
export const SilentLevel = 0;
cin
minor refactoring of TraceSource, code linting
r53 export interface TraceEvent {
cin
changed the project structure
r49 readonly source: TraceSource;
readonly level: number;
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 readonly message: any;
cin
changed the project structure
r49
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 readonly args?: any[];
cin
fixed "singleton" activation type handling in container configuration...
r65 }
cin
changed the project structure
r49 export class TraceSource {
cin
minor refactoring of TraceSource, code linting
r53 readonly id: any;
cin
changed the project structure
r49
cin
minor refactoring of TraceSource, code linting
r53 level: number;
cin
changed the project structure
r49
cin
minor refactoring of TraceSource, code linting
r53 readonly events: Observable<TraceEvent>;
cin
changed the project structure
r49
cin
minor refactoring of TraceSource, code linting
r53 _notifyNext: (arg: TraceEvent) => void;
cin
changed the project structure
r49
constructor(id: any) {
this.id = id || new Object();
cin
minor refactoring of TraceSource, code linting
r53 this.events = new Observable(next => {
cin
changed the project structure
r49 this._notifyNext = next;
cin
minor refactoring of TraceSource, code linting
r53 });
cin
changed the project structure
r49 }
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 protected emit(level: number, message: any, args?: any[]) {
this._notifyNext(new TraceEventData(this, level, message, args));
cin
changed the project structure
r49 }
isDebugEnabled() {
return this.level >= DebugLevel;
}
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 debug(data: any): void;
debug(msg: string, ...args: any[]): void;
cin
changed the project structure
r49 debug(msg: string, ...args: any[]) {
if (this.isEnabled(DebugLevel))
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 this.emit(DebugLevel, msg, args);
cin
changed the project structure
r49 }
isLogEnabled() {
return this.level >= LogLevel;
}
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 log(data: any): void;
log(msg: string, ...args: any[]): void;
cin
changed the project structure
r49 log(msg: string, ...args: any[]) {
if (this.isEnabled(LogLevel))
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 this.emit(LogLevel, msg, args);
cin
changed the project structure
r49 }
isWarnEnabled() {
return this.level >= WarnLevel;
}
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 warn(data: any): void;
warn(msg: string, ...args: any[]): void;
cin
changed the project structure
r49 warn(msg: string, ...args: any[]) {
if (this.isEnabled(WarnLevel))
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 this.emit(WarnLevel, msg, args);
cin
changed the project structure
r49 }
/**
* returns true if errors will be recorded.
*/
isErrorEnabled() {
return this.level >= ErrorLevel;
}
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 /** Traces a error
* @param data The object which will be passed to the underlying listeners
*/
error(data: any): void;
cin
changed the project structure
r49 /**
* Traces a error.
cin
minor refactoring of TraceSource, code linting
r53 *
cin
changed the project structure
r49 * @param msg the message.
* @param args parameters which will be substituted in the message.
*/
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 error(msg: string, ...args: any[]): void;
cin
changed the project structure
r49 error(msg: string, ...args: any[]) {
if (this.isEnabled(ErrorLevel))
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 this.emit(ErrorLevel, msg, args);
cin
changed the project structure
r49 }
/**
* Checks whether the specified level is enabled for this
* trace source.
cin
minor refactoring of TraceSource, code linting
r53 *
cin
changed the project structure
r49 * @param level the trace level which should be checked.
*/
isEnabled(level: number) {
return (this.level >= level);
}
/**
* Traces a raw event, passing data as it is to the underlying listeners
cin
minor refactoring of TraceSource, code linting
r53 *
cin
changed the project structure
r49 * @param level the level of the event
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 * @param msg the data of the event, can be a simple string or any object.
cin
changed the project structure
r49 */
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 traceEvent(level: number, msg: any, ...args: any[]) {
cin
changed the project structure
r49 if (this.isEnabled(level))
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 this.emit(level, msg, args);
cin
changed the project structure
r49 }
/**
* Register the specified handler to be called for every new and already
* created trace source.
cin
minor refactoring of TraceSource, code linting
r53 *
cin
changed the project structure
r49 * @param handler the handler which will be called for each trace source
*/
static on(handler: (source: TraceSource) => void) {
return Registry.instance.on(handler);
}
/**
* Creates or returns already created trace source for the specified id.
cin
minor refactoring of TraceSource, code linting
r53 *
cin
changed the project structure
r49 * @param id the id for the trace source
*/
static get(id: any) {
return Registry.instance.get(id);
}
}