@webpieces/winston 0.4.446 → 0.4.447

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/winston",
3
- "version": "0.4.446",
3
+ "version": "0.4.447",
4
4
  "description": "Node-only winston LoggerFactory backends for webpieces: Console (local pretty) + GCP (Cloud Run stdout JSON), auto-enriched with HeaderRegistry context keys",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -23,8 +23,8 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@webpieces/core-util": "0.4.446",
27
- "@webpieces/core-context": "0.4.446",
26
+ "@webpieces/core-util": "0.4.447",
27
+ "@webpieces/core-context": "0.4.447",
28
28
  "winston": "3.11.0",
29
29
  "logform": "2.7.0",
30
30
  "safe-stable-stringify": "2.5.0"
@@ -8,14 +8,12 @@ import type { Logger, LoggerFactory } from '@webpieces/core-util';
8
8
  * out a cached {@link WinstonLogger} per name (each a winston child carrying
9
9
  * `loggerName`). Subclasses differ only in the format stack they pass up.
10
10
  *
11
- * Every line carries `svcName` from {@link ServiceInfo} (winston has no mandatory logger name, so this
12
- * backend used to emit none a winston service was distinguishable only by GCP's own resource
13
- * labels). It is read here at construction and rides as `defaultMeta`; it is simply absent if the
14
- * service was not identified before this factory was built.
15
- *
16
- * `version` is NOT read here: it is stamped per-record by `RequestContext.buildStructuredLogFields`
17
- * (the one map `injectContextFormat` already loops), so it appears the moment `setInfo` runs — even
18
- * if that is after this factory was constructed — and logging works before it.
11
+ * Neither `svcName` nor `version` is read here: BOTH are stamped per-record by
12
+ * `RequestContext.buildStructuredLogFields` (the one map `injectContextFormat` already loops), so they
13
+ * appear the moment `setInfo` runs even if that is after this factory was constructed and logging
14
+ * works before it. This keeps winston and bunyan symmetrical: both read the same two ServiceInfo facts
15
+ * from the same map, on every line. (svcName used to ride as construction-time `defaultMeta`, which
16
+ * silently missed a `setInfo` that ran after the factory was built.)
19
17
  */
20
18
  export declare abstract class WinstonFactoryBase implements LoggerFactory {
21
19
  private readonly base;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WinstonFactoryBase = void 0;
4
4
  const winston_1 = require("winston");
5
- const core_util_1 = require("@webpieces/core-util");
6
5
  const WinstonLogger_1 = require("./WinstonLogger");
7
6
  /**
8
7
  * WinstonFactoryBase - shared plumbing for the winston {@link LoggerFactory}
@@ -11,14 +10,12 @@ const WinstonLogger_1 = require("./WinstonLogger");
11
10
  * out a cached {@link WinstonLogger} per name (each a winston child carrying
12
11
  * `loggerName`). Subclasses differ only in the format stack they pass up.
13
12
  *
14
- * Every line carries `svcName` from {@link ServiceInfo} (winston has no mandatory logger name, so this
15
- * backend used to emit none a winston service was distinguishable only by GCP's own resource
16
- * labels). It is read here at construction and rides as `defaultMeta`; it is simply absent if the
17
- * service was not identified before this factory was built.
18
- *
19
- * `version` is NOT read here: it is stamped per-record by `RequestContext.buildStructuredLogFields`
20
- * (the one map `injectContextFormat` already loops), so it appears the moment `setInfo` runs — even
21
- * if that is after this factory was constructed — and logging works before it.
13
+ * Neither `svcName` nor `version` is read here: BOTH are stamped per-record by
14
+ * `RequestContext.buildStructuredLogFields` (the one map `injectContextFormat` already loops), so they
15
+ * appear the moment `setInfo` runs even if that is after this factory was constructed and logging
16
+ * works before it. This keeps winston and bunyan symmetrical: both read the same two ServiceInfo facts
17
+ * from the same map, on every line. (svcName used to ride as construction-time `defaultMeta`, which
18
+ * silently missed a `setInfo` that ran after the factory was built.)
22
19
  */
23
20
  class WinstonFactoryBase {
24
21
  base;
@@ -30,19 +27,12 @@ class WinstonFactoryBase {
30
27
  * about the SINK, which is where it actually lives — a dev terminal has no such limit.
31
28
  */
32
29
  constructor(finalFormat, transport) {
33
- // svcName is a base field on every record when known. Non-throwing read: if the service was
34
- // not identified before this factory was built, svcName is simply omitted rather than blocking
35
- // the deploysetupRuntime identifies the service via ServiceInfo.setInfo (name+version are
36
- // required inputs) before it serves traffic.
37
- const svcName = core_util_1.ServiceInfo.getName();
38
- const defaultMeta = {};
39
- if (svcName) {
40
- defaultMeta['svcName'] = svcName;
41
- }
42
- // No level set — we do NOT filter; that is winston's job (defaults to 'info').
30
+ // No defaultMeta: svcName + version are BOTH stamped per-record by injectContextFormat (reading
31
+ // RequestContext.buildStructuredLogFields), so they pick up a late setInfo and stay symmetrical
32
+ // with the bunyan backend. No level set we do NOT filter; that is winston's job (defaults to
33
+ // 'info').
43
34
  this.base = (0, winston_1.createLogger)({
44
35
  format: finalFormat,
45
- defaultMeta: defaultMeta,
46
36
  transports: [transport ?? new winston_1.transports.Console()],
47
37
  handleExceptions: true,
48
38
  handleRejections: true,
@@ -1 +1 @@
1
- {"version":3,"file":"WinstonFactoryBase.js","sourceRoot":"","sources":["../../../../../packages/logging/winston/src/WinstonFactoryBase.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AAKnD,oDAAmD;AACnD,mDAAgD;AAEhD;;;;;;;;;;;;;;;GAeG;AACH,MAAsB,kBAAkB;IACnB,IAAI,CAAc;IAClB,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAErD;;;;;OAKG;IACH,YAAsB,WAAmB,EAAE,SAAqB;QAC5D,4FAA4F;QAC5F,+FAA+F;QAC/F,6FAA6F;QAC7F,6CAA6C;QAC7C,MAAM,OAAO,GAAG,uBAAW,CAAC,OAAO,EAAE,CAAC;QACtC,MAAM,WAAW,GAA2B,EAAE,CAAC;QAC/C,IAAI,OAAO,EAAE,CAAC;YACV,WAAW,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;QACrC,CAAC;QAED,+EAA+E;QAC/E,IAAI,CAAC,IAAI,GAAG,IAAA,sBAAY,EAAC;YACrB,MAAM,EAAE,WAAW;YACnB,WAAW,EAAE,WAAW;YACxB,UAAU,EAAE,CAAC,SAAS,IAAI,IAAI,oBAAU,CAAC,OAAO,EAAE,CAAC;YACnD,gBAAgB,EAAE,IAAI;YACtB,gBAAgB,EAAE,IAAI;SACzB,CAAC,CAAC;IACP,CAAC;IAED,SAAS,CAAC,IAAY;QAClB,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,GAAG,IAAI,6BAAa,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAClE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAvCD,gDAuCC","sourcesContent":["import { createLogger, transports } from 'winston';\nimport type { Logger as WinstonBase } from 'winston';\nimport type Transport from 'winston-transport';\nimport type { Format } from 'logform';\nimport type { Logger, LoggerFactory } from '@webpieces/core-util';\nimport { ServiceInfo } from '@webpieces/core-util';\nimport { WinstonLogger } from './WinstonLogger';\n\n/**\n * WinstonFactoryBase - shared plumbing for the winston {@link LoggerFactory}\n * backends. Builds ONE underlying winston logger (a single `Console` transport,\n * handleExceptions/Rejections on) with the caller-chosen format stack, then hands\n * out a cached {@link WinstonLogger} per name (each a winston child carrying\n * `loggerName`). Subclasses differ only in the format stack they pass up.\n *\n * Every line carries `svcName` from {@link ServiceInfo} (winston has no mandatory logger name, so this\n * backend used to emit none a winston service was distinguishable only by GCP's own resource\n * labels). It is read here at construction and rides as `defaultMeta`; it is simply absent if the\n * service was not identified before this factory was built.\n *\n * `version` is NOT read here: it is stamped per-record by `RequestContext.buildStructuredLogFields`\n * (the one map `injectContextFormat` already loops), so it appears the moment `setInfo` runs — even\n * if that is after this factory was constructed — and logging works before it.\n */\nexport abstract class WinstonFactoryBase implements LoggerFactory {\n private readonly base: WinstonBase;\n private readonly loggers = new Map<string, Logger>();\n\n /**\n * @param transport - the sink to write through. Defaults to a plain Console; the GCP subclass\n * passes a {@link ChunkingConsoleTransport} instead, because only there does a per-entry size\n * limit exist. Taking the whole transport (rather than a size knob) keeps the size limit a fact\n * about the SINK, which is where it actually lives — a dev terminal has no such limit.\n */\n protected constructor(finalFormat: Format, transport?: Transport) {\n // svcName is a base field on every record when known. Non-throwing read: if the service was\n // not identified before this factory was built, svcName is simply omitted rather than blocking\n // the deploy — setupRuntime identifies the service via ServiceInfo.setInfo (name+version are\n // required inputs) before it serves traffic.\n const svcName = ServiceInfo.getName();\n const defaultMeta: Record<string, string> = {};\n if (svcName) {\n defaultMeta['svcName'] = svcName;\n }\n\n // No level set — we do NOT filter; that is winston's job (defaults to 'info').\n this.base = createLogger({\n format: finalFormat,\n defaultMeta: defaultMeta,\n transports: [transport ?? new transports.Console()],\n handleExceptions: true,\n handleRejections: true,\n });\n }\n\n getLogger(name: string): Logger {\n let logger = this.loggers.get(name);\n if (!logger) {\n logger = new WinstonLogger(this.base.child({ loggerName: name }));\n this.loggers.set(name, logger);\n }\n return logger;\n }\n}\n"]}
1
+ {"version":3,"file":"WinstonFactoryBase.js","sourceRoot":"","sources":["../../../../../packages/logging/winston/src/WinstonFactoryBase.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AAKnD,mDAAgD;AAEhD;;;;;;;;;;;;;GAaG;AACH,MAAsB,kBAAkB;IACnB,IAAI,CAAc;IAClB,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAErD;;;;;OAKG;IACH,YAAsB,WAAmB,EAAE,SAAqB;QAC5D,gGAAgG;QAChG,gGAAgG;QAChG,+FAA+F;QAC/F,WAAW;QACX,IAAI,CAAC,IAAI,GAAG,IAAA,sBAAY,EAAC;YACrB,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,CAAC,SAAS,IAAI,IAAI,oBAAU,CAAC,OAAO,EAAE,CAAC;YACnD,gBAAgB,EAAE,IAAI;YACtB,gBAAgB,EAAE,IAAI;SACzB,CAAC,CAAC;IACP,CAAC;IAED,SAAS,CAAC,IAAY;QAClB,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,GAAG,IAAI,6BAAa,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAClE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA/BD,gDA+BC","sourcesContent":["import { createLogger, transports } from 'winston';\nimport type { Logger as WinstonBase } from 'winston';\nimport type Transport from 'winston-transport';\nimport type { Format } from 'logform';\nimport type { Logger, LoggerFactory } from '@webpieces/core-util';\nimport { WinstonLogger } from './WinstonLogger';\n\n/**\n * WinstonFactoryBase - shared plumbing for the winston {@link LoggerFactory}\n * backends. Builds ONE underlying winston logger (a single `Console` transport,\n * handleExceptions/Rejections on) with the caller-chosen format stack, then hands\n * out a cached {@link WinstonLogger} per name (each a winston child carrying\n * `loggerName`). Subclasses differ only in the format stack they pass up.\n *\n * Neither `svcName` nor `version` is read here: BOTH are stamped per-record by\n * `RequestContext.buildStructuredLogFields` (the one map `injectContextFormat` already loops), so they\n * appear the moment `setInfo` runs even if that is after this factory was constructed and logging\n * works before it. This keeps winston and bunyan symmetrical: both read the same two ServiceInfo facts\n * from the same map, on every line. (svcName used to ride as construction-time `defaultMeta`, which\n * silently missed a `setInfo` that ran after the factory was built.)\n */\nexport abstract class WinstonFactoryBase implements LoggerFactory {\n private readonly base: WinstonBase;\n private readonly loggers = new Map<string, Logger>();\n\n /**\n * @param transport - the sink to write through. Defaults to a plain Console; the GCP subclass\n * passes a {@link ChunkingConsoleTransport} instead, because only there does a per-entry size\n * limit exist. Taking the whole transport (rather than a size knob) keeps the size limit a fact\n * about the SINK, which is where it actually lives — a dev terminal has no such limit.\n */\n protected constructor(finalFormat: Format, transport?: Transport) {\n // No defaultMeta: svcName + version are BOTH stamped per-record by injectContextFormat (reading\n // RequestContext.buildStructuredLogFields), so they pick up a late setInfo and stay symmetrical\n // with the bunyan backend. No level set — we do NOT filter; that is winston's job (defaults to\n // 'info').\n this.base = createLogger({\n format: finalFormat,\n transports: [transport ?? new transports.Console()],\n handleExceptions: true,\n handleRejections: true,\n });\n }\n\n getLogger(name: string): Logger {\n let logger = this.loggers.get(name);\n if (!logger) {\n logger = new WinstonLogger(this.base.child({ loggerName: name }));\n this.loggers.set(name, logger);\n }\n return logger;\n }\n}\n"]}