fix(logger): make file transport opt-in via LOG_FILE_PATH (#9)

The file transport defaulted to writing excalidraw.log relative to
process.cwd(), polluting every project directory where the MCP server
started. Console transport already handles warn+error to stderr.

File logging is now opt-in: set LOG_FILE_PATH to enable it.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maxime Roy (new.blacc)
2026-04-06 10:02:27 +02:00
committed by GitHub
co-authored by Claude Opus 4.6
parent f770c811e9
commit 798f62f63a
+7 -7
View File
@@ -1,7 +1,5 @@
import winston from 'winston';
const LOG_FILE_PATH = process.env.LOG_FILE_PATH || 'excalidraw.log';
const logger: winston.Logger = winston.createLogger({
level: process.env.LOG_LEVEL || 'info',
@@ -21,13 +19,15 @@ const logger: winston.Logger = winston.createLogger({
new winston.transports.Console({
level: 'warn', // only warn+error to stderr
stderrLevels: ['warn','error']
}),
new winston.transports.File({
filename: LOG_FILE_PATH, // all levels to file
level: 'debug'
})
]
});
if (process.env.LOG_FILE_PATH) {
logger.add(new winston.transports.File({
filename: process.env.LOG_FILE_PATH,
level: 'debug'
}));
}
export default logger;