feat(medusa): Allow logging to file (#4696)

* enable additional log transport to file if FILE_NAME env var is set

* change var declaration to const

* Create chilly-geckos-look.md

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Lacey Pevey
2023-08-06 15:14:49 +02:00
committed by GitHub
co-authored by Oli Juhl
parent dc46927bc6
commit 03fb0479c0
2 changed files with 15 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
---
"@medusajs/medusa": patch
"@medusajs/medusa-cli": patch
---
Feat/allow logging to file
@@ -8,6 +8,7 @@ import { panicHandler } from "./panic-handler"
import * as Transport from "winston-transport"
const LOG_LEVEL = process.env.LOG_LEVEL || "silly"
const LOG_FILE = process.env.LOG_FILE || ""
const NODE_ENV = process.env.NODE_ENV || "development"
const IS_DEV = NODE_ENV.startsWith("dev")
@@ -26,6 +27,14 @@ if (!IS_DEV) {
)
}
if (LOG_FILE) {
transports.push(
new winston.transports.File({
filename: LOG_FILE
})
)
}
const loggerInstance = winston.createLogger({
level: LOG_LEVEL,
levels: winston.config.npm.levels,