@webpieces/bunyan 0.4.393 → 0.4.395
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/README.md +17 -10
- package/package.json +3 -3
- package/src/BunyanConsoleFactory.d.ts +4 -2
- package/src/BunyanConsoleFactory.js +5 -2
- package/src/BunyanConsoleFactory.js.map +1 -1
- package/src/BunyanFactoryBase.d.ts +11 -1
- package/src/BunyanFactoryBase.js +13 -2
- package/src/BunyanFactoryBase.js.map +1 -1
- package/src/BunyanGcpFactory.d.ts +4 -2
- package/src/BunyanGcpFactory.js +5 -2
- package/src/BunyanGcpFactory.js.map +1 -1
- package/src/index.d.ts +11 -5
- package/src/index.js +12 -7
- package/src/index.js.map +1 -1
- package/src/BunyanFactoryOptions.d.ts +0 -21
- package/src/BunyanFactoryOptions.js +0 -24
- package/src/BunyanFactoryOptions.js.map +0 -1
package/README.md
CHANGED
|
@@ -17,28 +17,35 @@ Two factories, both auto-enriching every line with the logged context keys regis
|
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
import { LogManager, HeaderRegistry } from '@webpieces/core-util';
|
|
20
|
+
import { ServiceInfo } from '@webpieces/core-util';
|
|
20
21
|
import { BunyanGcpFactory, BunyanConsoleFactory } from '@webpieces/bunyan';
|
|
21
|
-
import { RequestContextReader } from '@webpieces/core-context';
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
// FIRST: name this service. Both factories read it in their CONSTRUCTOR, so this must come
|
|
24
|
+
// before you build one — a forgotten call throws at startup rather than shipping unnamed logs.
|
|
25
|
+
ServiceInfo.setName('my-service');
|
|
26
|
+
|
|
24
27
|
const loggerFactory = process.env.K_SERVICE
|
|
25
|
-
? new BunyanGcpFactory(
|
|
26
|
-
: new BunyanConsoleFactory(
|
|
28
|
+
? new BunyanGcpFactory()
|
|
29
|
+
: new BunyanConsoleFactory();
|
|
27
30
|
|
|
28
31
|
// Typically you pass loggerFactory to setupRuntime(new RuntimeSetupOptions(loggerFactory, ...)),
|
|
29
32
|
// which calls HeaderRegistry.configure(...) then LogManager.setFactory(loggerFactory) for you.
|
|
30
33
|
```
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
any node context package.
|
|
35
|
+
Both factories read the magic context **directly** from `RequestContext` on each line, so
|
|
36
|
+
nothing is threaded in: there is no `ContextReader` constructor argument.
|
|
35
37
|
|
|
36
38
|
`BunyanGcpFactory` sends to the Cloud Logging API and needs GCP Application Default
|
|
37
39
|
Credentials on the instance (automatic on Cloud Run), exactly as the source service runs.
|
|
38
40
|
|
|
39
41
|
## Options
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
There are none — both factories take no arguments.
|
|
42
44
|
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
+
- **Service name** — from `ServiceInfo.setName(...)` (see above), NOT a factory option. It
|
|
46
|
+
becomes bunyan's mandatory root-logger `name` and surfaces as `name` in the payload. It
|
|
47
|
+
lives in `@webpieces/core-util` because it is a fact about the SERVICE, not about bunyan:
|
|
48
|
+
the winston backend reads the same value, and so does `requestIdSource` (which records
|
|
49
|
+
which service minted a request-id).
|
|
50
|
+
- **Level** — there is deliberately no knob. webpieces does not filter by level; bunyan
|
|
51
|
+
filters at its own default.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/bunyan",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.395",
|
|
4
4
|
"description": "Node-only bunyan LoggerFactory backends for webpieces: Console (local pretty) + GCP (@google-cloud/logging-bunyan), 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.
|
|
27
|
-
"@webpieces/core-context": "0.4.
|
|
26
|
+
"@webpieces/core-util": "0.4.395",
|
|
27
|
+
"@webpieces/core-context": "0.4.395",
|
|
28
28
|
"bunyan": "1.8.15",
|
|
29
29
|
"@google-cloud/logging-bunyan": "5.1.0",
|
|
30
30
|
"@types/bunyan": "1.8.11"
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BunyanFactoryBase } from './BunyanFactoryBase';
|
|
2
|
-
import { BunyanFactoryOptions } from './BunyanFactoryOptions';
|
|
3
2
|
/**
|
|
4
3
|
* BunyanConsoleFactory - the LOCAL developer backend. Human-readable, greppable
|
|
5
4
|
* text to stdout (`[LEVEL][time][ctx tags]: message`) with the registered context
|
|
6
5
|
* keys as tags — same enrichment as the GCP backend, different rendering. Mirrors
|
|
7
6
|
* the tested trytami local console stream.
|
|
7
|
+
*
|
|
8
|
+
* The service name comes from {@link ServiceInfo}, which startup must have named
|
|
9
|
+
* BEFORE constructing this.
|
|
8
10
|
*/
|
|
9
11
|
export declare class BunyanConsoleFactory extends BunyanFactoryBase {
|
|
10
|
-
constructor(
|
|
12
|
+
constructor();
|
|
11
13
|
}
|
|
@@ -8,10 +8,13 @@ const streams_1 = require("./streams");
|
|
|
8
8
|
* text to stdout (`[LEVEL][time][ctx tags]: message`) with the registered context
|
|
9
9
|
* keys as tags — same enrichment as the GCP backend, different rendering. Mirrors
|
|
10
10
|
* the tested trytami local console stream.
|
|
11
|
+
*
|
|
12
|
+
* The service name comes from {@link ServiceInfo}, which startup must have named
|
|
13
|
+
* BEFORE constructing this.
|
|
11
14
|
*/
|
|
12
15
|
class BunyanConsoleFactory extends BunyanFactoryBase_1.BunyanFactoryBase {
|
|
13
|
-
constructor(
|
|
14
|
-
super(
|
|
16
|
+
constructor() {
|
|
17
|
+
super([(0, streams_1.createConsoleStream)()]);
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
exports.BunyanConsoleFactory = BunyanConsoleFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BunyanConsoleFactory.js","sourceRoot":"","sources":["../../../../../packages/logging/bunyan/src/BunyanConsoleFactory.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;
|
|
1
|
+
{"version":3,"file":"BunyanConsoleFactory.js","sourceRoot":"","sources":["../../../../../packages/logging/bunyan/src/BunyanConsoleFactory.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AACxD,uCAAgD;AAEhD;;;;;;;;GAQG;AACH,MAAa,oBAAqB,SAAQ,qCAAiB;IACvD;QACI,KAAK,CAAC,CAAC,IAAA,6BAAmB,GAAE,CAAC,CAAC,CAAC;IACnC,CAAC;CACJ;AAJD,oDAIC","sourcesContent":["import { BunyanFactoryBase } from './BunyanFactoryBase';\nimport { createConsoleStream } from './streams';\n\n/**\n * BunyanConsoleFactory - the LOCAL developer backend. Human-readable, greppable\n * text to stdout (`[LEVEL][time][ctx tags]: message`) with the registered context\n * keys as tags — same enrichment as the GCP backend, different rendering. Mirrors\n * the tested trytami local console stream.\n *\n * The service name comes from {@link ServiceInfo}, which startup must have named\n * BEFORE constructing this.\n */\nexport class BunyanConsoleFactory extends BunyanFactoryBase {\n constructor() {\n super([createConsoleStream()]);\n }\n}\n"]}
|
|
@@ -7,10 +7,20 @@ import type { Logger as WpLogger, LoggerFactory } from '@webpieces/core-util';
|
|
|
7
7
|
* carrying `loggerName`). Every logger reads the magic context DIRECTLY from
|
|
8
8
|
* RequestContext, so nothing is threaded through here. Subclasses differ only in
|
|
9
9
|
* the stream they pass up (GCP vs local console).
|
|
10
|
+
*
|
|
11
|
+
* The root logger's `name` is bunyan's ONE mandatory option (its constructor throws
|
|
12
|
+
* `options.name (string) is required`), and it comes from {@link ServiceInfo} — so an
|
|
13
|
+
* app names itself ONCE, in one place, for logging AND for requestIdSource. Reading it
|
|
14
|
+
* here means a forgotten `ServiceInfo.setName(...)` throws OUR actionable error while
|
|
15
|
+
* the process boots, rather than bunyan's opaque TypeError.
|
|
16
|
+
*
|
|
17
|
+
* Per-logger names ride as `loggerName` on each child rather than `name`, because
|
|
18
|
+
* bunyan REFUSES to let a child override `name` (`invalid options.name: child cannot
|
|
19
|
+
* set logger name`).
|
|
10
20
|
*/
|
|
11
21
|
export declare abstract class BunyanFactoryBase implements LoggerFactory {
|
|
12
22
|
private readonly base;
|
|
13
23
|
private readonly loggers;
|
|
14
|
-
protected constructor(
|
|
24
|
+
protected constructor(streams: Logger.Stream[]);
|
|
15
25
|
getLogger(name: string): WpLogger;
|
|
16
26
|
}
|
package/src/BunyanFactoryBase.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BunyanFactoryBase = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const bunyan_1 = tslib_1.__importDefault(require("bunyan"));
|
|
6
|
+
const core_util_1 = require("@webpieces/core-util");
|
|
6
7
|
const BunyanLogger_1 = require("./BunyanLogger");
|
|
7
8
|
/**
|
|
8
9
|
* BunyanFactoryBase - shared plumbing for the bunyan {@link LoggerFactory}
|
|
@@ -11,12 +12,22 @@ const BunyanLogger_1 = require("./BunyanLogger");
|
|
|
11
12
|
* carrying `loggerName`). Every logger reads the magic context DIRECTLY from
|
|
12
13
|
* RequestContext, so nothing is threaded through here. Subclasses differ only in
|
|
13
14
|
* the stream they pass up (GCP vs local console).
|
|
15
|
+
*
|
|
16
|
+
* The root logger's `name` is bunyan's ONE mandatory option (its constructor throws
|
|
17
|
+
* `options.name (string) is required`), and it comes from {@link ServiceInfo} — so an
|
|
18
|
+
* app names itself ONCE, in one place, for logging AND for requestIdSource. Reading it
|
|
19
|
+
* here means a forgotten `ServiceInfo.setName(...)` throws OUR actionable error while
|
|
20
|
+
* the process boots, rather than bunyan's opaque TypeError.
|
|
21
|
+
*
|
|
22
|
+
* Per-logger names ride as `loggerName` on each child rather than `name`, because
|
|
23
|
+
* bunyan REFUSES to let a child override `name` (`invalid options.name: child cannot
|
|
24
|
+
* set logger name`).
|
|
14
25
|
*/
|
|
15
26
|
class BunyanFactoryBase {
|
|
16
27
|
base;
|
|
17
28
|
loggers = new Map();
|
|
18
|
-
constructor(
|
|
19
|
-
this.base = bunyan_1.default.createLogger({ name, streams });
|
|
29
|
+
constructor(streams) {
|
|
30
|
+
this.base = bunyan_1.default.createLogger({ name: core_util_1.ServiceInfo.getName(), streams });
|
|
20
31
|
}
|
|
21
32
|
getLogger(name) {
|
|
22
33
|
let logger = this.loggers.get(name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BunyanFactoryBase.js","sourceRoot":"","sources":["../../../../../packages/logging/bunyan/src/BunyanFactoryBase.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAE5B,iDAA8C;AAE9C
|
|
1
|
+
{"version":3,"file":"BunyanFactoryBase.js","sourceRoot":"","sources":["../../../../../packages/logging/bunyan/src/BunyanFactoryBase.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAE5B,oDAAmD;AACnD,iDAA8C;AAE9C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAsB,iBAAiB;IAClB,IAAI,CAAS;IACb,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IAEvD,YAAsB,OAAwB;QAC1C,IAAI,CAAC,IAAI,GAAG,gBAAM,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,uBAAW,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC9E,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,2BAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACjE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAhBD,8CAgBC","sourcesContent":["import Logger from 'bunyan';\nimport type { Logger as WpLogger, LoggerFactory } from '@webpieces/core-util';\nimport { ServiceInfo } from '@webpieces/core-util';\nimport { BunyanLogger } from './BunyanLogger';\n\n/**\n * BunyanFactoryBase - shared plumbing for the bunyan {@link LoggerFactory}\n * backends. Builds ONE underlying bunyan logger with the caller-chosen stream,\n * then hands out a cached {@link BunyanLogger} per name (each a bunyan child\n * carrying `loggerName`). Every logger reads the magic context DIRECTLY from\n * RequestContext, so nothing is threaded through here. Subclasses differ only in\n * the stream they pass up (GCP vs local console).\n *\n * The root logger's `name` is bunyan's ONE mandatory option (its constructor throws\n * `options.name (string) is required`), and it comes from {@link ServiceInfo} — so an\n * app names itself ONCE, in one place, for logging AND for requestIdSource. Reading it\n * here means a forgotten `ServiceInfo.setName(...)` throws OUR actionable error while\n * the process boots, rather than bunyan's opaque TypeError.\n *\n * Per-logger names ride as `loggerName` on each child rather than `name`, because\n * bunyan REFUSES to let a child override `name` (`invalid options.name: child cannot\n * set logger name`).\n */\nexport abstract class BunyanFactoryBase implements LoggerFactory {\n private readonly base: Logger;\n private readonly loggers = new Map<string, WpLogger>();\n\n protected constructor(streams: Logger.Stream[]) {\n this.base = Logger.createLogger({ name: ServiceInfo.getName(), streams });\n }\n\n getLogger(name: string): WpLogger {\n let logger = this.loggers.get(name);\n if (!logger) {\n logger = new BunyanLogger(this.base.child({ loggerName: name }));\n this.loggers.set(name, logger);\n }\n return logger;\n }\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BunyanFactoryBase } from './BunyanFactoryBase';
|
|
2
|
-
import { BunyanFactoryOptions } from './BunyanFactoryOptions';
|
|
3
2
|
/**
|
|
4
3
|
* BunyanGcpFactory - the GCP backend. Streams to Cloud Logging via
|
|
5
4
|
* @google-cloud/logging-bunyan (which owns the numeric-level→severity mapping,
|
|
@@ -7,7 +6,10 @@ import { BunyanFactoryOptions } from './BunyanFactoryOptions';
|
|
|
7
6
|
* structured payload fields, read straight from RequestContext on each line. This
|
|
8
7
|
* matches the tested-in-GCP trytami service exactly. Requires GCP Application
|
|
9
8
|
* Default Credentials on the instance.
|
|
9
|
+
*
|
|
10
|
+
* The service name comes from {@link ServiceInfo}, which startup must have named
|
|
11
|
+
* BEFORE constructing this.
|
|
10
12
|
*/
|
|
11
13
|
export declare class BunyanGcpFactory extends BunyanFactoryBase {
|
|
12
|
-
constructor(
|
|
14
|
+
constructor();
|
|
13
15
|
}
|
package/src/BunyanGcpFactory.js
CHANGED
|
@@ -10,10 +10,13 @@ const streams_1 = require("./streams");
|
|
|
10
10
|
* structured payload fields, read straight from RequestContext on each line. This
|
|
11
11
|
* matches the tested-in-GCP trytami service exactly. Requires GCP Application
|
|
12
12
|
* Default Credentials on the instance.
|
|
13
|
+
*
|
|
14
|
+
* The service name comes from {@link ServiceInfo}, which startup must have named
|
|
15
|
+
* BEFORE constructing this.
|
|
13
16
|
*/
|
|
14
17
|
class BunyanGcpFactory extends BunyanFactoryBase_1.BunyanFactoryBase {
|
|
15
|
-
constructor(
|
|
16
|
-
super(
|
|
18
|
+
constructor() {
|
|
19
|
+
super([(0, streams_1.createGoogleCloudStream)()]);
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
exports.BunyanGcpFactory = BunyanGcpFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BunyanGcpFactory.js","sourceRoot":"","sources":["../../../../../packages/logging/bunyan/src/BunyanGcpFactory.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;
|
|
1
|
+
{"version":3,"file":"BunyanGcpFactory.js","sourceRoot":"","sources":["../../../../../packages/logging/bunyan/src/BunyanGcpFactory.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AACxD,uCAAoD;AAEpD;;;;;;;;;;GAUG;AACH,MAAa,gBAAiB,SAAQ,qCAAiB;IACnD;QACI,KAAK,CAAC,CAAC,IAAA,iCAAuB,GAAE,CAAC,CAAC,CAAC;IACvC,CAAC;CACJ;AAJD,4CAIC","sourcesContent":["import { BunyanFactoryBase } from './BunyanFactoryBase';\nimport { createGoogleCloudStream } from './streams';\n\n/**\n * BunyanGcpFactory - the GCP backend. Streams to Cloud Logging via\n * @google-cloud/logging-bunyan (which owns the numeric-level→severity mapping,\n * msg→message, trace/httpRequest fields). The logged context keys ride along as\n * structured payload fields, read straight from RequestContext on each line. This\n * matches the tested-in-GCP trytami service exactly. Requires GCP Application\n * Default Credentials on the instance.\n *\n * The service name comes from {@link ServiceInfo}, which startup must have named\n * BEFORE constructing this.\n */\nexport class BunyanGcpFactory extends BunyanFactoryBase {\n constructor() {\n super([createGoogleCloudStream()]);\n }\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -5,15 +5,22 @@
|
|
|
5
5
|
* startup via `LogManager.setFactory(...)`:
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
|
-
* import {
|
|
8
|
+
* import { ServiceInfo } from '@webpieces/core-util';
|
|
9
|
+
* import { BunyanGcpFactory, BunyanConsoleFactory } from '@webpieces/bunyan';
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
+
* ServiceInfo.setName('my-service'); // FIRST — the factories read it in their constructor
|
|
11
12
|
* const loggerFactory = process.env.K_SERVICE
|
|
12
|
-
* ? new BunyanGcpFactory(
|
|
13
|
-
* : new BunyanConsoleFactory(
|
|
13
|
+
* ? new BunyanGcpFactory() // Cloud Logging via @google-cloud/logging-bunyan
|
|
14
|
+
* : new BunyanConsoleFactory(); // local → pretty console
|
|
14
15
|
* // hand to setupRuntime(new RuntimeSetupOptions(loggerFactory, ...))
|
|
15
16
|
* ```
|
|
16
17
|
*
|
|
18
|
+
* BREAKING (was `new BunyanFactoryOptions('my-service')` passed to each factory): the service name
|
|
19
|
+
* moved to `ServiceInfo.setName(...)` in @webpieces/core-util, because it is a fact about the
|
|
20
|
+
* SERVICE, not about bunyan — winston needs the same name, and so does `requestIdSource`. Migration:
|
|
21
|
+
* delete the `BunyanFactoryOptions` import, call `ServiceInfo.setName(<the same string>)` before
|
|
22
|
+
* building the factory, and drop the ctor argument. A forgotten call throws at startup.
|
|
23
|
+
*
|
|
17
24
|
* Both backends auto-enrich every line with the logged context keys, read
|
|
18
25
|
* DIRECTLY from the active RequestContext (@webpieces/core-context) on each line —
|
|
19
26
|
* no ContextReader is threaded in. There is no level knob: bunyan filters at its
|
|
@@ -23,7 +30,6 @@
|
|
|
23
30
|
*/
|
|
24
31
|
export { BunyanGcpFactory } from './BunyanGcpFactory';
|
|
25
32
|
export { BunyanConsoleFactory } from './BunyanConsoleFactory';
|
|
26
|
-
export { BunyanFactoryOptions } from './BunyanFactoryOptions';
|
|
27
33
|
export { BunyanLogger } from './BunyanLogger';
|
|
28
34
|
export { createGoogleCloudStream, createConsoleStream } from './streams';
|
|
29
35
|
export { LEVEL_TO_BUNYAN, logLevelToBunyanLevel } from './levels';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logLevelToBunyanLevel = exports.LEVEL_TO_BUNYAN = exports.createConsoleStream = exports.createGoogleCloudStream = exports.BunyanLogger = exports.
|
|
3
|
+
exports.logLevelToBunyanLevel = exports.LEVEL_TO_BUNYAN = exports.createConsoleStream = exports.createGoogleCloudStream = exports.BunyanLogger = exports.BunyanConsoleFactory = exports.BunyanGcpFactory = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @webpieces/bunyan
|
|
6
6
|
*
|
|
@@ -8,15 +8,22 @@ exports.logLevelToBunyanLevel = exports.LEVEL_TO_BUNYAN = exports.createConsoleS
|
|
|
8
8
|
* startup via `LogManager.setFactory(...)`:
|
|
9
9
|
*
|
|
10
10
|
* ```ts
|
|
11
|
-
* import {
|
|
11
|
+
* import { ServiceInfo } from '@webpieces/core-util';
|
|
12
|
+
* import { BunyanGcpFactory, BunyanConsoleFactory } from '@webpieces/bunyan';
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
+
* ServiceInfo.setName('my-service'); // FIRST — the factories read it in their constructor
|
|
14
15
|
* const loggerFactory = process.env.K_SERVICE
|
|
15
|
-
* ? new BunyanGcpFactory(
|
|
16
|
-
* : new BunyanConsoleFactory(
|
|
16
|
+
* ? new BunyanGcpFactory() // Cloud Logging via @google-cloud/logging-bunyan
|
|
17
|
+
* : new BunyanConsoleFactory(); // local → pretty console
|
|
17
18
|
* // hand to setupRuntime(new RuntimeSetupOptions(loggerFactory, ...))
|
|
18
19
|
* ```
|
|
19
20
|
*
|
|
21
|
+
* BREAKING (was `new BunyanFactoryOptions('my-service')` passed to each factory): the service name
|
|
22
|
+
* moved to `ServiceInfo.setName(...)` in @webpieces/core-util, because it is a fact about the
|
|
23
|
+
* SERVICE, not about bunyan — winston needs the same name, and so does `requestIdSource`. Migration:
|
|
24
|
+
* delete the `BunyanFactoryOptions` import, call `ServiceInfo.setName(<the same string>)` before
|
|
25
|
+
* building the factory, and drop the ctor argument. A forgotten call throws at startup.
|
|
26
|
+
*
|
|
20
27
|
* Both backends auto-enrich every line with the logged context keys, read
|
|
21
28
|
* DIRECTLY from the active RequestContext (@webpieces/core-context) on each line —
|
|
22
29
|
* no ContextReader is threaded in. There is no level knob: bunyan filters at its
|
|
@@ -28,8 +35,6 @@ var BunyanGcpFactory_1 = require("./BunyanGcpFactory");
|
|
|
28
35
|
Object.defineProperty(exports, "BunyanGcpFactory", { enumerable: true, get: function () { return BunyanGcpFactory_1.BunyanGcpFactory; } });
|
|
29
36
|
var BunyanConsoleFactory_1 = require("./BunyanConsoleFactory");
|
|
30
37
|
Object.defineProperty(exports, "BunyanConsoleFactory", { enumerable: true, get: function () { return BunyanConsoleFactory_1.BunyanConsoleFactory; } });
|
|
31
|
-
var BunyanFactoryOptions_1 = require("./BunyanFactoryOptions");
|
|
32
|
-
Object.defineProperty(exports, "BunyanFactoryOptions", { enumerable: true, get: function () { return BunyanFactoryOptions_1.BunyanFactoryOptions; } });
|
|
33
38
|
var BunyanLogger_1 = require("./BunyanLogger");
|
|
34
39
|
Object.defineProperty(exports, "BunyanLogger", { enumerable: true, get: function () { return BunyanLogger_1.BunyanLogger; } });
|
|
35
40
|
var streams_1 = require("./streams");
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/logging/bunyan/src/index.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/logging/bunyan/src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,qCAAyE;AAAhE,kHAAA,uBAAuB,OAAA;AAAE,8GAAA,mBAAmB,OAAA;AACrD,mCAAkE;AAAzD,yGAAA,eAAe,OAAA;AAAE,+GAAA,qBAAqB,OAAA","sourcesContent":["/**\n * @webpieces/bunyan\n *\n * Node-only bunyan {@link LoggerFactory} backends for webpieces. Install one at\n * startup via `LogManager.setFactory(...)`:\n *\n * ```ts\n * import { ServiceInfo } from '@webpieces/core-util';\n * import { BunyanGcpFactory, BunyanConsoleFactory } from '@webpieces/bunyan';\n *\n * ServiceInfo.setName('my-service'); // FIRST — the factories read it in their constructor\n * const loggerFactory = process.env.K_SERVICE\n * ? new BunyanGcpFactory() // Cloud Logging via @google-cloud/logging-bunyan\n * : new BunyanConsoleFactory(); // local → pretty console\n * // hand to setupRuntime(new RuntimeSetupOptions(loggerFactory, ...))\n * ```\n *\n * BREAKING (was `new BunyanFactoryOptions('my-service')` passed to each factory): the service name\n * moved to `ServiceInfo.setName(...)` in @webpieces/core-util, because it is a fact about the\n * SERVICE, not about bunyan — winston needs the same name, and so does `requestIdSource`. Migration:\n * delete the `BunyanFactoryOptions` import, call `ServiceInfo.setName(<the same string>)` before\n * building the factory, and drop the ctor argument. A forgotten call throws at startup.\n *\n * Both backends auto-enrich every line with the logged context keys, read\n * DIRECTLY from the active RequestContext (@webpieces/core-context) on each line —\n * no ContextReader is threaded in. There is no level knob: bunyan filters at its\n * own default.\n *\n * @packageDocumentation\n */\nexport { BunyanGcpFactory } from './BunyanGcpFactory';\nexport { BunyanConsoleFactory } from './BunyanConsoleFactory';\nexport { BunyanLogger } from './BunyanLogger';\nexport { createGoogleCloudStream, createConsoleStream } from './streams';\nexport { LEVEL_TO_BUNYAN, logLevelToBunyanLevel } from './levels';\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BunyanFactoryOptions - tuning for the bunyan LoggerFactory backends.
|
|
3
|
-
*
|
|
4
|
-
* Data-only structure → a class, per CLAUDE.md.
|
|
5
|
-
*
|
|
6
|
-
* There is deliberately NO level knob: webpieces does not filter by level — that
|
|
7
|
-
* is bunyan's job (bunyan filters at its own default). You must name the service.
|
|
8
|
-
*/
|
|
9
|
-
export declare class BunyanFactoryOptions {
|
|
10
|
-
/**
|
|
11
|
-
* The bunyan logger `name` (surfaces as `name` in Cloud Logging's JSON
|
|
12
|
-
* payload). REQUIRED — every service names itself.
|
|
13
|
-
*/
|
|
14
|
-
readonly serviceName: string;
|
|
15
|
-
constructor(
|
|
16
|
-
/**
|
|
17
|
-
* The bunyan logger `name` (surfaces as `name` in Cloud Logging's JSON
|
|
18
|
-
* payload). REQUIRED — every service names itself.
|
|
19
|
-
*/
|
|
20
|
-
serviceName: string);
|
|
21
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BunyanFactoryOptions = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* BunyanFactoryOptions - tuning for the bunyan LoggerFactory backends.
|
|
6
|
-
*
|
|
7
|
-
* Data-only structure → a class, per CLAUDE.md.
|
|
8
|
-
*
|
|
9
|
-
* There is deliberately NO level knob: webpieces does not filter by level — that
|
|
10
|
-
* is bunyan's job (bunyan filters at its own default). You must name the service.
|
|
11
|
-
*/
|
|
12
|
-
class BunyanFactoryOptions {
|
|
13
|
-
serviceName;
|
|
14
|
-
constructor(
|
|
15
|
-
/**
|
|
16
|
-
* The bunyan logger `name` (surfaces as `name` in Cloud Logging's JSON
|
|
17
|
-
* payload). REQUIRED — every service names itself.
|
|
18
|
-
*/
|
|
19
|
-
serviceName) {
|
|
20
|
-
this.serviceName = serviceName;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.BunyanFactoryOptions = BunyanFactoryOptions;
|
|
24
|
-
//# sourceMappingURL=BunyanFactoryOptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BunyanFactoryOptions.js","sourceRoot":"","sources":["../../../../../packages/logging/bunyan/src/BunyanFactoryOptions.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,MAAa,oBAAoB;IAMT;IALpB;IACI;;;OAGG;IACa,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;IACpC,CAAC;CACP;AARD,oDAQC","sourcesContent":["/**\n * BunyanFactoryOptions - tuning for the bunyan LoggerFactory backends.\n *\n * Data-only structure → a class, per CLAUDE.md.\n *\n * There is deliberately NO level knob: webpieces does not filter by level — that\n * is bunyan's job (bunyan filters at its own default). You must name the service.\n */\nexport class BunyanFactoryOptions {\n constructor(\n /**\n * The bunyan logger `name` (surfaces as `name` in Cloud Logging's JSON\n * payload). REQUIRED — every service names itself.\n */\n public readonly serviceName: string,\n ) {}\n}\n"]}
|