diff --git a/src/log-record.ts b/src/log-record.ts index 6c6f335..cafca77 100644 --- a/src/log-record.ts +++ b/src/log-record.ts @@ -48,13 +48,32 @@ export class LogRecord { public readonly levelno: LogLevel; public readonly levelname: string|LogLevel; public readonly scope: string; + public readonly name: string; + public readonly msg: string; + public readonly args: any[]|undefined; + public message: string = ''; public readonly created: MillisecondsSinceUnixEpoch = Date.now(); + public asctime: string = ''; constructor(scope: string, options: LogRecordOptions) { this.levelno = options.level; this.levelname = getLevelName(options.level); this.scope = scope; + this.name = scope; + this.msg = options.msg; + this.args = options.args; + } + + getMessage(): string { + let msg = String(this.msg); + if (this.args && this.args.length > 0) { + msg = this.args.reduce( + (s, arg) => s.replace('%s', String(arg)), + msg + ); + } + return msg; } }