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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user