@epztickets/common 1.66.0 → 1.67.0
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/build/logging/logger.js +14 -4
- package/package.json +3 -2
package/build/logging/logger.js
CHANGED
|
@@ -6,7 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createLogger = createLogger;
|
|
7
7
|
const pino_1 = __importDefault(require("pino"));
|
|
8
8
|
const isTest = process.env.NODE_ENV === "test";
|
|
9
|
-
|
|
9
|
+
// Pretty-printing is OPT-IN. The previous behavior ("pretty unless
|
|
10
|
+
// production or test") caused crashes in dockerized dev/staging
|
|
11
|
+
// environments where NODE_ENV is unset — pino's transport mechanism
|
|
12
|
+
// would try to spawn the pino-pretty worker and fail. Inverting the
|
|
13
|
+
// check so prod-defaults (no NODE_ENV) get raw JSON matches what
|
|
14
|
+
// log aggregators want anyway.
|
|
15
|
+
//
|
|
16
|
+
// To enable pretty output on a local laptop: `NODE_ENV=development`
|
|
17
|
+
// or `LOG_PRETTY=1`.
|
|
18
|
+
const wantsPretty = process.env.NODE_ENV === "development" || process.env.LOG_PRETTY === "1";
|
|
10
19
|
function createLogger(serviceOrOpts) {
|
|
11
20
|
var _a, _b;
|
|
12
21
|
const opts = typeof serviceOrOpts === "string"
|
|
@@ -16,9 +25,10 @@ function createLogger(serviceOrOpts) {
|
|
|
16
25
|
return (0, pino_1.default)({
|
|
17
26
|
name: opts.service,
|
|
18
27
|
level,
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
28
|
+
// Pretty-printed colored lines for local dev only. Defaults to
|
|
29
|
+
// raw JSON everywhere else — exactly what every log aggregator
|
|
30
|
+
// (Loki, Datadog, CloudWatch, etc.) expects.
|
|
31
|
+
transport: wantsPretty
|
|
22
32
|
? {
|
|
23
33
|
target: "pino-pretty",
|
|
24
34
|
options: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epztickets/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.67.0",
|
|
4
4
|
"main": "./build/index.js",
|
|
5
5
|
"types": "./build/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"jsonwebtoken": "^9.0.2",
|
|
36
36
|
"nats": "^2.29.3",
|
|
37
37
|
"pino": "^9.5.0",
|
|
38
|
-
"pino-http": "^10.3.0"
|
|
38
|
+
"pino-http": "^10.3.0",
|
|
39
|
+
"pino-pretty": "^11.3.0"
|
|
39
40
|
}
|
|
40
41
|
}
|