| 35 | */ |
| 36 | @Injectable() |
| 37 | export class LoggerService implements Logger { |
| 38 | private prefix: string = "" |
| 39 | |
| 40 | /** |
| 41 | * Set a prefix for all log messages from this logger instance |
| 42 | */ |
| 43 | setPrefix(prefix: string): void { |
| 44 | this.prefix = prefix ? `[${prefix}] ` : "" |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Create a child logger with a specific prefix |
| 49 | */ |
| 50 | child(prefix: string): LoggerService { |
| 51 | const childLogger = new LoggerService() |
| 52 | childLogger.setPrefix(prefix) |
| 53 | return childLogger |
| 54 | } |
| 55 | |
| 56 | log(...params: any[]): void { |
| 57 | if (this.prefix) { |
| 58 | electronLog.log(this.prefix, ...params) |
| 59 | } else { |
| 60 | electronLog.log(...params) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | info(...params: any[]): void { |
| 65 | if (this.prefix) { |
| 66 | electronLog.info(this.prefix, ...params) |
| 67 | } else { |
| 68 | electronLog.info(...params) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | warn(...params: any[]): void { |
| 73 | if (this.prefix) { |
| 74 | electronLog.warn(this.prefix, ...params) |
| 75 | } else { |
| 76 | electronLog.warn(...params) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | error(...params: any[]): void { |
| 81 | if (this.prefix) { |
| 82 | electronLog.error(this.prefix, ...params) |
| 83 | } else { |
| 84 | electronLog.error(...params) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | debug(...params: any[]): void { |
| 89 | if (this.prefix) { |
| 90 | electronLog.debug(this.prefix, ...params) |
| 91 | } else { |
| 92 | electronLog.debug(...params) |
| 93 | } |
| 94 | } |
nothing calls this directly
no outgoing calls
no test coverage detected