Adding name getter

This commit is contained in:
Fabian Stamm
2019-04-03 14:25:12 +00:00
parent 11619948e3
commit fd77f1d288
3 changed files with 22 additions and 39 deletions

View File

@ -44,13 +44,15 @@ export interface LoggingBaseOptions {
}
export class LoggingBase {
private logFile: any;
private errorFile: any;
private adapter: Adapter[] = [];
private adapter_init: Promise<void>[] = [];
private messageObservable = new Observable<Message>();
protected name: string;
protected _name: string;
get name() {
return this._name;
}
constructor(options?: Partial<LoggingBaseOptions> | string) {
let opt: Partial<LoggingBaseOptions>;
@ -69,7 +71,7 @@ export class LoggingBase {
};
if (config.name)
this.name = config.name;
this._name = config.name;
for (let key in this) {
if (typeof this[key] === "function") this[key] = (<any>this[key]).bind(this);
@ -82,7 +84,7 @@ export class LoggingBase {
addAdapter(adapter: Adapter) {
this.adapter.push(adapter);
let prms = Promise.resolve(adapter.init(this.messageObservable.getPublicApi(), this.name));
let prms = Promise.resolve(adapter.init(this.messageObservable.getPublicApi(), this._name));
this.adapter_init.push(prms);
}
@ -171,7 +173,7 @@ export class LoggingBase {
let msg: Message = {
date: new Date(),
file,
name: this.name,
name: this._name,
text: {
raw: lines,
formatted