mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 06:04:51 +00:00
Fix process.cwd() error when running from deleted directory
- Defer process.cwd() call in logger to avoid initialization errors - Resolve log file path only when actually writing logs - Bump version to 0.5.2
This commit is contained in:
parent
d304f377d7
commit
42dc46a513
8 changed files with 29 additions and 19 deletions
|
|
@ -10,7 +10,7 @@ export interface LoggerConfig {
|
|||
class Logger {
|
||||
private config: LoggerConfig = {
|
||||
enabled: false,
|
||||
logFile: join(process.cwd(), "tui-debug.log"),
|
||||
logFile: "tui-debug.log", // Will be resolved when needed
|
||||
logLevel: "debug",
|
||||
};
|
||||
|
||||
|
|
@ -20,7 +20,12 @@ class Logger {
|
|||
if (this.config.enabled) {
|
||||
// Clear log file on startup
|
||||
try {
|
||||
writeFileSync(this.config.logFile, `=== TUI Debug Log Started ${new Date().toISOString()} ===\n`);
|
||||
// Resolve log file path when needed
|
||||
const logFile = this.config.logFile.startsWith("/")
|
||||
? this.config.logFile
|
||||
: join(process.cwd(), this.config.logFile);
|
||||
|
||||
writeFileSync(logFile, `=== TUI Debug Log Started ${new Date().toISOString()} ===\n`);
|
||||
} catch (error) {
|
||||
// Silently fail if we can't write to log file
|
||||
}
|
||||
|
|
@ -45,7 +50,12 @@ class Logger {
|
|||
const dataStr = data ? ` | Data: ${JSON.stringify(data)}` : "";
|
||||
const logLine = `[${timestamp}] ${level.toUpperCase()} [${component}] ${message}${dataStr}\n`;
|
||||
|
||||
appendFileSync(this.config.logFile, logLine);
|
||||
// Resolve log file path when needed
|
||||
const logFile = this.config.logFile.startsWith("/")
|
||||
? this.config.logFile
|
||||
: join(process.cwd(), this.config.logFile);
|
||||
|
||||
appendFileSync(logFile, logLine);
|
||||
} catch (error) {
|
||||
// Silently fail if we can't write to log file
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue