@atproto/common 0.7.5 → 0.7.6
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/CHANGELOG.md +8 -0
- package/dist/logger.d.ts +15 -2
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +17 -7
- package/dist/logger.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atproto/common
|
|
2
2
|
|
|
3
|
+
## 0.7.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4805](https://github.com/bluesky-social/atproto/pull/4805) [`b66870d`](https://github.com/bluesky-social/atproto/commit/b66870d5a1efbcfa0cc07498c7cfcf3f0f243e86) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Export new `createLogger` helper
|
|
8
|
+
|
|
9
|
+
- [#4805](https://github.com/bluesky-social/atproto/pull/4805) [`b66870d`](https://github.com/bluesky-social/atproto/commit/b66870d5a1efbcfa0cc07498c7cfcf3f0f243e86) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Deprecate `subsystemLogger` in favor of `createLogger`
|
|
10
|
+
|
|
3
11
|
## 0.7.5
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
import { type Logger } from 'pino';
|
|
2
|
-
export declare
|
|
1
|
+
import { type Logger, type SerializerFn } from 'pino';
|
|
2
|
+
export declare function createLogger(name: string, options?: {
|
|
3
|
+
serializers?: {
|
|
4
|
+
[key: string]: SerializerFn;
|
|
5
|
+
};
|
|
6
|
+
msgPrefix?: string;
|
|
7
|
+
}): Logger;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated The use of singleton loggers is deprecated as they don't allow
|
|
10
|
+
* for proper configuration of serializers, and are not really used across the
|
|
11
|
+
* "atproto" mono repo. Indeed, whenever used, loggers are created and
|
|
12
|
+
* re-exported from a central place, achieving the same effect as a singleton
|
|
13
|
+
* logger, but with more flexibility. Use {@link createLogger} instead.
|
|
14
|
+
*/
|
|
15
|
+
export declare function subsystemLogger(name: string): Logger;
|
|
3
16
|
//# sourceMappingURL=logger.d.ts.map
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAqB,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAqB,MAAM,MAAM,CAAA;AAcxE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IACR,WAAW,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;KAAE,CAAA;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GACA,MAAM,CAOR;AAID;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpD"}
|
package/dist/logger.js
CHANGED
|
@@ -5,17 +5,27 @@ const level = process.env.LOG_LEVEL || 'info';
|
|
|
5
5
|
const systems = process.env.LOG_SYSTEMS?.trim()
|
|
6
6
|
? process.env.LOG_SYSTEMS.replace(',', ' ').split(/\s+/).filter(Boolean)
|
|
7
7
|
: null;
|
|
8
|
-
const rootLogger = pino({ enabled, level }, dest ? destination(dest) : undefined);
|
|
9
|
-
|
|
10
|
-
export const subsystemLogger = (name) => {
|
|
11
|
-
if (subsystems.has(name))
|
|
12
|
-
return subsystems.get(name);
|
|
8
|
+
const rootLogger = /*#__PURE__*/ pino({ enabled, level }, dest ? destination(dest) : undefined);
|
|
9
|
+
export function createLogger(name, options) {
|
|
13
10
|
// can't disable child loggers, so we just set their level to "silent"
|
|
14
11
|
// to effectively turn them off
|
|
15
12
|
const subsystemEnabled = !systems || systems.includes(name);
|
|
16
13
|
const subsystemLevel = enabled && subsystemEnabled ? level : 'silent';
|
|
17
|
-
|
|
14
|
+
return rootLogger.child({ name }, { ...options, level: subsystemLevel });
|
|
15
|
+
}
|
|
16
|
+
const subsystems = new Map();
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated The use of singleton loggers is deprecated as they don't allow
|
|
19
|
+
* for proper configuration of serializers, and are not really used across the
|
|
20
|
+
* "atproto" mono repo. Indeed, whenever used, loggers are created and
|
|
21
|
+
* re-exported from a central place, achieving the same effect as a singleton
|
|
22
|
+
* logger, but with more flexibility. Use {@link createLogger} instead.
|
|
23
|
+
*/
|
|
24
|
+
export function subsystemLogger(name) {
|
|
25
|
+
if (subsystems.has(name))
|
|
26
|
+
return subsystems.get(name);
|
|
27
|
+
const logger = createLogger(name);
|
|
18
28
|
subsystems.set(name, logger);
|
|
19
29
|
return logger;
|
|
20
|
-
}
|
|
30
|
+
}
|
|
21
31
|
//# sourceMappingURL=logger.js.map
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,WAAW,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAExE,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,CAAA;AACpE,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAA;AACxC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM,CAAA;AAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,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'0')\nconst dest = process.env.LOG_DESTINATION\nconst level = process.env.LOG_LEVEL || 'info'\nconst systems = process.env.LOG_SYSTEMS?.trim()\n ? process.env.LOG_SYSTEMS.replace(',', ' ').split(/\\s+/).filter(Boolean)\n : null\n\nconst rootLogger = /*#__PURE__*/ pino(\n { enabled, level },\n dest ? destination(dest) : undefined,\n)\n\nexport function createLogger(\n name: string,\n options?: {\n serializers?: { [key: string]: SerializerFn }\n msgPrefix?: string\n },\n): Logger {\n // can't disable child loggers, so we just set their level to \"silent\"\n // to effectively turn them off\n const subsystemEnabled = !systems || systems.includes(name)\n const subsystemLevel = enabled && subsystemEnabled ? level : 'silent'\n\n return rootLogger.child({ name }, { ...options, level: subsystemLevel })\n}\n\nconst subsystems = new Map<string, Logger>()\n\n/**\n * @deprecated The use of singleton loggers is deprecated as they don't allow\n * for proper configuration of serializers, and are not really used across the\n * \"atproto\" mono repo. Indeed, whenever used, loggers are created and\n * re-exported from a central place, achieving the same effect as a singleton\n * logger, but with more flexibility. Use {@link createLogger} instead.\n */\nexport function subsystemLogger(name: string): Logger {\n if (subsystems.has(name)) return subsystems.get(name)!\n const logger = createLogger(name)\n subsystems.set(name, logger)\n return logger\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/common",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared web-platform-friendly code for atproto libraries",
|
|
6
6
|
"keywords": [
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"multiformats": "^13.0.0",
|
|
32
32
|
"pino": "^10.3.1",
|
|
33
|
-
"@atproto/common-web": "^0.5.9",
|
|
34
33
|
"@atproto/lex-cbor": "^0.1.6",
|
|
34
|
+
"@atproto/common-web": "^0.5.9",
|
|
35
35
|
"@atproto/lex-data": "^0.1.7"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|