From 82106426842fc917cd56c1570e1334483197871c Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Fri, 25 Sep 2020 22:19:13 +0200 Subject: [PATCH] Improve logging configuration structure --- config/default.ts | 9 ++++++--- config/production.ts | 9 ++++++--- config/test.ts | 2 +- src/Logger.ts | 6 +++--- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/config/default.ts b/config/default.ts index 7d37f72..c76a580 100644 --- a/config/default.ts +++ b/config/default.ts @@ -1,10 +1,13 @@ -module.exports = { +export default { app: { name: 'Example App', contact_email: 'contact@example.net' }, - log_level: "DEV", - db_log_level: "ERROR", + log: { + level: "DEBUG", + verbose: true, + db_level: "ERROR", + }, base_url: "http://localhost:4899", public_websocket_url: "ws://localhost:4899", listen_addr: '127.0.0.1', diff --git a/config/production.ts b/config/production.ts index a73f4a1..89e273b 100644 --- a/config/production.ts +++ b/config/production.ts @@ -1,6 +1,9 @@ -module.exports = { - log_level: "DEBUG", - db_log_level: "ERROR", +export default { + log: { + level: "DEV", + verbose: false, + db_level: "ERROR", + }, base_url: "https://watch-my.stream", public_websocket_url: "wss://watch-my.stream", session: { diff --git a/config/test.ts b/config/test.ts index 5dc5f77..c1cdbbd 100644 --- a/config/test.ts +++ b/config/test.ts @@ -1,4 +1,4 @@ -module.exports = { +export default { mysql: { host: "localhost", user: "root", diff --git a/src/Logger.ts b/src/Logger.ts index 13f89f3..022cae0 100644 --- a/src/Logger.ts +++ b/src/Logger.ts @@ -4,9 +4,9 @@ import Log from "./models/Log"; import {bufferToUUID} from "./Utils"; export default class Logger { - private static logLevel: LogLevelKeys = config.get('log_level'); - private static dbLogLevel: LogLevelKeys = config.get('db_log_level'); - private static verboseMode: boolean = false; + private static logLevel: LogLevelKeys = config.get('log.level'); + private static dbLogLevel: LogLevelKeys = config.get('log.db_level'); + private static verboseMode: boolean = config.get('log.verbose'); public static verbose() { this.verboseMode = true;