From 824852fe7ac059650c99a5a08696d45319c3ea3b Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sat, 17 Aug 2024 15:06:12 +0200 Subject: [PATCH] Initialize and use bunyan logger --- src/lib/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/index.ts b/src/lib/index.ts index f5f5087..fe1270a 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1,5 +1,12 @@ // place files you want to import through the `$lib` alias in this folder. import path from 'path'; +import bunyan from 'bunyan'; + +export const log = bunyan.createLogger({ + name: 'fotochallenge', + level: process.env.NODE_ENV === 'production' ? 'info' : 'debug', + src: true +}); function safePath(basePath: string, name: string): boolean { const fullPath = `${basePath}/${name}`; @@ -17,7 +24,7 @@ function safePath(basePath: string, name: string): boolean { const defaultPath: string = './uploads'; if (!('STORAGE_PATH' in process.env)) { - console.warn(`'STORAGE_PATH' environment variable is not set. Defaulting to ${defaultPath}`); + log.warn(`'STORAGE_PATH' environment variable is not set. Defaulting to ${defaultPath}`); } export const storagePath: string = process.env.STORAGE_PATH ?? defaultPath;