diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-03-29 04:03:49 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-28 13:03:49 -0400 |
commit | bced52505f32d6cca4f944bb610a8a26767908a8 (patch) | |
tree | da49a5df4b7bd6f8306248069228cd6bd0db1303 /std/log | |
parent | 1397b8e0e7c85762e19d88fde103342bfa563360 (diff) |
Update to Prettier 2 and use ES Private Fields (#4498)
Diffstat (limited to 'std/log')
-rw-r--r-- | std/log/README.md | 12 | ||||
-rw-r--r-- | std/log/handlers_test.ts | 22 | ||||
-rw-r--r-- | std/log/levels.ts | 4 | ||||
-rw-r--r-- | std/log/logger.ts | 2 | ||||
-rw-r--r-- | std/log/logger_test.ts | 4 | ||||
-rw-r--r-- | std/log/mod.ts | 16 | ||||
-rw-r--r-- | std/log/test.ts | 28 |
7 files changed, 44 insertions, 44 deletions
diff --git a/std/log/README.md b/std/log/README.md index 613e69922..dea1e5fe7 100644 --- a/std/log/README.md +++ b/std/log/README.md @@ -21,22 +21,22 @@ await log.setup({ file: new log.handlers.FileHandler("WARNING", { filename: "./log.txt", // you can change format of output message - formatter: "{levelName} {msg}" - }) + formatter: "{levelName} {msg}", + }), }, loggers: { // configure default logger available via short-hand methods above default: { level: "DEBUG", - handlers: ["console", "file"] + handlers: ["console", "file"], }, tasks: { level: "ERROR", - handlers: ["console"] - } - } + handlers: ["console"], + }, + }, }); let logger; diff --git a/std/log/handlers_test.ts b/std/log/handlers_test.ts index 693d2a485..4feffdaf9 100644 --- a/std/log/handlers_test.ts +++ b/std/log/handlers_test.ts @@ -21,8 +21,8 @@ test(function simpleHandler(): void { "INFO info-test", "WARNING warning-test", "ERROR error-test", - "CRITICAL critical-test" - ] + "CRITICAL critical-test", + ], ], [ LogLevel.INFO, @@ -30,15 +30,15 @@ test(function simpleHandler(): void { "INFO info-test", "WARNING warning-test", "ERROR error-test", - "CRITICAL critical-test" - ] + "CRITICAL critical-test", + ], ], [ LogLevel.WARNING, - ["WARNING warning-test", "ERROR error-test", "CRITICAL critical-test"] + ["WARNING warning-test", "ERROR error-test", "CRITICAL critical-test"], ], [LogLevel.ERROR, ["ERROR error-test", "CRITICAL critical-test"]], - [LogLevel.CRITICAL, ["CRITICAL critical-test"]] + [LogLevel.CRITICAL, ["CRITICAL critical-test"]], ]); for (const [testCase, messages] of cases.entries()) { @@ -52,7 +52,7 @@ test(function simpleHandler(): void { args: [], datetime: new Date(), level: level, - levelName: levelName + levelName: levelName, }); } @@ -64,7 +64,7 @@ test(function simpleHandler(): void { test(function testFormatterAsString(): void { const handler = new TestHandler("DEBUG", { - formatter: "test {levelName} {msg}" + formatter: "test {levelName} {msg}", }); handler.handle({ @@ -72,7 +72,7 @@ test(function testFormatterAsString(): void { args: [], datetime: new Date(), level: LogLevel.DEBUG, - levelName: "DEBUG" + levelName: "DEBUG", }); assertEquals(handler.messages, ["test DEBUG Hello, world!"]); @@ -81,7 +81,7 @@ test(function testFormatterAsString(): void { test(function testFormatterAsFunction(): void { const handler = new TestHandler("DEBUG", { formatter: (logRecord): string => - `fn formmatter ${logRecord.levelName} ${logRecord.msg}` + `fn formmatter ${logRecord.levelName} ${logRecord.msg}`, }); handler.handle({ @@ -89,7 +89,7 @@ test(function testFormatterAsFunction(): void { args: [], datetime: new Date(), level: LogLevel.ERROR, - levelName: "ERROR" + levelName: "ERROR", }); assertEquals(handler.messages, ["fn formmatter ERROR Hello, world!"]); diff --git a/std/log/levels.ts b/std/log/levels.ts index 599629f85..be960dd57 100644 --- a/std/log/levels.ts +++ b/std/log/levels.ts @@ -5,7 +5,7 @@ export const LogLevel: Record<string, number> = { INFO: 20, WARNING: 30, ERROR: 40, - CRITICAL: 50 + CRITICAL: 50, }; const byLevel = { @@ -14,7 +14,7 @@ const byLevel = { [LogLevel.INFO]: "INFO", [LogLevel.WARNING]: "WARNING", [LogLevel.ERROR]: "ERROR", - [LogLevel.CRITICAL]: "CRITICAL" + [LogLevel.CRITICAL]: "CRITICAL", }; export function getLevelByName(name: string): number { diff --git a/std/log/logger.ts b/std/log/logger.ts index 99d17ef48..226b8dba6 100644 --- a/std/log/logger.ts +++ b/std/log/logger.ts @@ -34,7 +34,7 @@ export class Logger { args: args, datetime: new Date(), level: level, - levelName: getLevelName(level) + levelName: getLevelName(level), }; this.handlers.forEach((handler): void => { handler.handle(record); diff --git a/std/log/logger_test.ts b/std/log/logger_test.ts index 76ff4cf95..3e8898afa 100644 --- a/std/log/logger_test.ts +++ b/std/log/logger_test.ts @@ -67,7 +67,7 @@ test(function logFunctions(): void { "INFO bar", "WARNING baz", "ERROR boo", - "CRITICAL doo" + "CRITICAL doo", ]); handler = doLog("INFO"); @@ -76,7 +76,7 @@ test(function logFunctions(): void { "INFO bar", "WARNING baz", "ERROR boo", - "CRITICAL doo" + "CRITICAL doo", ]); handler = doLog("WARNING"); diff --git a/std/log/mod.ts b/std/log/mod.ts index b89896264..333e90fb9 100644 --- a/std/log/mod.ts +++ b/std/log/mod.ts @@ -4,7 +4,7 @@ import { BaseHandler, ConsoleHandler, WriterHandler, - FileHandler + FileHandler, } from "./handlers.ts"; import { assert } from "../testing/asserts.ts"; @@ -25,28 +25,28 @@ export interface LogConfig { const DEFAULT_LEVEL = "INFO"; const DEFAULT_CONFIG: LogConfig = { handlers: { - default: new ConsoleHandler(DEFAULT_LEVEL) + default: new ConsoleHandler(DEFAULT_LEVEL), }, loggers: { default: { level: DEFAULT_LEVEL, - handlers: ["default"] - } - } + handlers: ["default"], + }, + }, }; const state = { handlers: new Map<string, BaseHandler>(), loggers: new Map<string, Logger>(), - config: DEFAULT_CONFIG + config: DEFAULT_CONFIG, }; export const handlers = { BaseHandler, ConsoleHandler, WriterHandler, - FileHandler + FileHandler, }; export function getLogger(name?: string): Logger { @@ -81,7 +81,7 @@ export const critical = (msg: string, ...args: unknown[]): void => export async function setup(config: LogConfig): Promise<void> { state.config = { handlers: { ...DEFAULT_CONFIG.handlers, ...config.handlers }, - loggers: { ...DEFAULT_CONFIG.loggers, ...config.loggers } + loggers: { ...DEFAULT_CONFIG.loggers, ...config.loggers }, }; // tear down existing handlers diff --git a/std/log/test.ts b/std/log/test.ts index d4385968c..858f722e2 100644 --- a/std/log/test.ts +++ b/std/log/test.ts @@ -20,7 +20,7 @@ test(async function defaultHandlers(): Promise<void> { INFO: log.info, WARNING: log.warning, ERROR: log.error, - CRITICAL: log.critical + CRITICAL: log.critical, }; for (const levelName in LogLevel) { @@ -33,14 +33,14 @@ test(async function defaultHandlers(): Promise<void> { await log.setup({ handlers: { - default: handler + default: handler, }, loggers: { default: { level: levelName, - handlers: ["default"] - } - } + handlers: ["default"], + }, + }, }); logger("foo"); @@ -55,14 +55,14 @@ test(async function getLogger(): Promise<void> { await log.setup({ handlers: { - default: handler + default: handler, }, loggers: { default: { level: "DEBUG", - handlers: ["default"] - } - } + handlers: ["default"], + }, + }, }); const logger = log.getLogger(); @@ -76,14 +76,14 @@ test(async function getLoggerWithName(): Promise<void> { await log.setup({ handlers: { - foo: fooHandler + foo: fooHandler, }, loggers: { bar: { level: "INFO", - handlers: ["foo"] - } - } + handlers: ["foo"], + }, + }, }); const logger = log.getLogger("bar"); @@ -95,7 +95,7 @@ test(async function getLoggerWithName(): Promise<void> { test(async function getLoggerUnknown(): Promise<void> { await log.setup({ handlers: {}, - loggers: {} + loggers: {}, }); const logger = log.getLogger("nonexistent"); |