diff options
Diffstat (limited to 'log')
| -rw-r--r-- | log/handlers.ts | 19 | ||||
| -rw-r--r-- | log/handlers_test.ts | 8 | ||||
| -rw-r--r-- | log/logger.ts | 8 | ||||
| -rw-r--r-- | log/logger_test.ts | 6 | ||||
| -rw-r--r-- | log/mod.ts | 18 | ||||
| -rw-r--r-- | log/test.ts | 8 |
6 files changed, 38 insertions, 29 deletions
diff --git a/log/handlers.ts b/log/handlers.ts index 666a8aa48..f13a858e9 100644 --- a/log/handlers.ts +++ b/log/handlers.ts @@ -37,16 +37,19 @@ export class BaseHandler { return this.formatter(logRecord); } - return this.formatter.replace(/{(\S+)}/g, (match, p1) => { - const value = logRecord[p1]; + return this.formatter.replace( + /{(\S+)}/g, + (match, p1): string => { + const value = logRecord[p1]; - // do not interpolate missing values - if (!value) { - return match; - } + // do not interpolate missing values + if (!value) { + return match; + } - return value; - }); + return value; + } + ); } log(_msg: string): void {} diff --git a/log/handlers_test.ts b/log/handlers_test.ts index 9cbf70be6..329541fa1 100644 --- a/log/handlers_test.ts +++ b/log/handlers_test.ts @@ -12,7 +12,7 @@ class TestHandler extends BaseHandler { } } -test(function simpleHandler() { +test(function simpleHandler(): void { const cases = new Map<number, string[]>([ [ LogLevel.DEBUG, @@ -62,7 +62,7 @@ test(function simpleHandler() { } }); -test(function testFormatterAsString() { +test(function testFormatterAsString(): void { const handler = new TestHandler("DEBUG", { formatter: "test {levelName} {msg}" }); @@ -78,9 +78,9 @@ test(function testFormatterAsString() { assertEquals(handler.messages, ["test DEBUG Hello, world!"]); }); -test(function testFormatterAsFunction() { +test(function testFormatterAsFunction(): void { const handler = new TestHandler("DEBUG", { - formatter: logRecord => + formatter: (logRecord): string => `fn formmatter ${logRecord.levelName} ${logRecord.msg}` }); diff --git a/log/logger.ts b/log/logger.ts index d92c34a58..4150fb524 100644 --- a/log/logger.ts +++ b/log/logger.ts @@ -39,9 +39,11 @@ export class Logger { levelName: getLevelName(level) }; - this.handlers.forEach(handler => { - handler.handle(record); - }); + this.handlers.forEach( + (handler): void => { + handler.handle(record); + } + ); } // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/log/logger_test.ts b/log/logger_test.ts index 702720160..eb4e7673d 100644 --- a/log/logger_test.ts +++ b/log/logger_test.ts @@ -19,7 +19,7 @@ class TestHandler extends BaseHandler { } } -test(function simpleLogger() { +test(function simpleLogger(): void { const handler = new TestHandler("DEBUG"); let logger = new Logger("DEBUG"); @@ -32,7 +32,7 @@ test(function simpleLogger() { assertEquals(logger.handlers, [handler]); }); -test(function customHandler() { +test(function customHandler(): void { const handler = new TestHandler("DEBUG"); const logger = new Logger("DEBUG", [handler]); @@ -51,7 +51,7 @@ test(function customHandler() { assertEquals(handler.messages, ["DEBUG foo"]); }); -test(function logFunctions() { +test(function logFunctions(): void { let handler: TestHandler; const doLog = (level: string): void => { diff --git a/log/mod.ts b/log/mod.ts index ef5ca5a89..9149e8604 100644 --- a/log/mod.ts +++ b/log/mod.ts @@ -89,9 +89,11 @@ export async function setup(config: LogConfig): Promise<void> { }; // tear down existing handlers - state.handlers.forEach(handler => { - handler.destroy(); - }); + state.handlers.forEach( + (handler): void => { + handler.destroy(); + } + ); state.handlers.clear(); // setup handlers @@ -113,11 +115,13 @@ export async function setup(config: LogConfig): Promise<void> { const handlerNames = loggerConfig.handlers || []; const handlers: BaseHandler[] = []; - handlerNames.forEach(handlerName => { - if (state.handlers.has(handlerName)) { - handlers.push(state.handlers.get(handlerName)); + handlerNames.forEach( + (handlerName): void => { + if (state.handlers.has(handlerName)) { + handlers.push(state.handlers.get(handlerName)); + } } - }); + ); const levelName = loggerConfig.level || DEFAULT_LEVEL; const logger = new Logger(levelName, handlers); diff --git a/log/test.ts b/log/test.ts index 44d86fa65..f21fb5b3d 100644 --- a/log/test.ts +++ b/log/test.ts @@ -22,7 +22,7 @@ class TestHandler extends log.handlers.BaseHandler { } } -test(async function defaultHandlers() { +test(async function defaultHandlers(): Promise<void> { const loggers = { DEBUG: log.debug, INFO: log.info, @@ -59,7 +59,7 @@ test(async function defaultHandlers() { } }); -test(async function getLogger() { +test(async function getLogger(): Promise<void> { const handler = new TestHandler("DEBUG"); await log.setup({ @@ -80,7 +80,7 @@ test(async function getLogger() { assertEquals(logger.handlers, [handler]); }); -test(async function getLoggerWithName() { +test(async function getLoggerWithName(): Promise<void> { const fooHandler = new TestHandler("DEBUG"); await log.setup({ @@ -101,7 +101,7 @@ test(async function getLoggerWithName() { assertEquals(logger.handlers, [fooHandler]); }); -test(async function getLoggerUnknown() { +test(async function getLoggerUnknown(): Promise<void> { await log.setup({ handlers: {}, loggers: {} |
