@orxataguy/tyr 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/Logger.ts +8 -5
package/package.json
CHANGED
package/src/core/Logger.ts
CHANGED
|
@@ -15,12 +15,15 @@ export function createLogger(isDebug: boolean): Logger {
|
|
|
15
15
|
const logDir = path.join(homedir(), '.tyr', 'logs');
|
|
16
16
|
const logFile = path.join(logDir, `${new Date().toISOString().slice(0, 10)}.log`);
|
|
17
17
|
|
|
18
|
-
fs.mkdirSync(logDir, { recursive: true });
|
|
19
|
-
|
|
20
18
|
const writeToFile = (level: string, msg: any) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
try {
|
|
20
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
21
|
+
const timestamp = new Date().toISOString();
|
|
22
|
+
const line = `[${timestamp}] [${level}] ${String(msg)}\n`;
|
|
23
|
+
fs.appendFileSync(logFile, line, 'utf-8');
|
|
24
|
+
} catch {
|
|
25
|
+
// Logging failures must never crash the application
|
|
26
|
+
}
|
|
24
27
|
};
|
|
25
28
|
|
|
26
29
|
return {
|