@oh-my-pi/pi-utils 16.1.17 → 16.1.19
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 +2 -2
- package/src/logger.ts +18 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/pi-utils",
|
|
4
|
-
"version": "16.1.
|
|
4
|
+
"version": "16.1.19",
|
|
5
5
|
"description": "Shared utilities for pi packages",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"fmt": "biome format --write ."
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@oh-my-pi/pi-natives": "16.1.
|
|
34
|
+
"@oh-my-pi/pi-natives": "16.1.19",
|
|
35
35
|
"handlebars": "^4.7.9",
|
|
36
36
|
"winston": "^3.19.0",
|
|
37
37
|
"winston-daily-rotate-file": "^5.0.0"
|
package/src/logger.ts
CHANGED
|
@@ -105,13 +105,20 @@ function buildTransports(opts: { console?: boolean; file?: boolean | string }):
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
function getWinstonLogger(): winston.Logger {
|
|
108
|
-
winstonLogger
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
if (!winstonLogger) {
|
|
109
|
+
const transports = buildTransports(transportOpts);
|
|
110
|
+
winstonLogger = winston.createLogger({
|
|
111
|
+
level: "debug",
|
|
112
|
+
format: getLogFormat(),
|
|
113
|
+
transports,
|
|
114
|
+
// A transport-less winston logger console.warns "Attempt to write logs
|
|
115
|
+
// with no transports" on every emit; mark it silent instead so disabling
|
|
116
|
+
// all transports is a clean no-op.
|
|
117
|
+
silent: transports.length === 0,
|
|
118
|
+
// Don't exit on error - logging failures shouldn't crash the app
|
|
119
|
+
exitOnError: false,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
115
122
|
return winstonLogger;
|
|
116
123
|
}
|
|
117
124
|
|
|
@@ -124,7 +131,10 @@ export function setTransports(opts: { console?: boolean; file?: boolean | string
|
|
|
124
131
|
transportOpts = opts;
|
|
125
132
|
if (!winstonLogger) return; // applied lazily when the logger is first built
|
|
126
133
|
winstonLogger.clear();
|
|
127
|
-
|
|
134
|
+
const transports = buildTransports(opts);
|
|
135
|
+
for (const transport of transports) winstonLogger.add(transport);
|
|
136
|
+
// Keep the logger silent when nothing is attached so winston doesn't warn on emit.
|
|
137
|
+
winstonLogger.silent = transports.length === 0;
|
|
128
138
|
}
|
|
129
139
|
|
|
130
140
|
/**
|