@atproto/common 0.6.3 → 0.6.4
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 +15 -0
- package/dist/logger.d.ts +2 -2
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +16 -20
- package/dist/logger.js.map +1 -1
- package/package.json +5 -5
- package/src/logger.ts +21 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atproto/common
|
|
2
2
|
|
|
3
|
+
## 0.6.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#5149](https://github.com/bluesky-social/atproto/pull/5149) [`f2cf8f7`](https://github.com/bluesky-social/atproto/commit/f2cf8f7fc5f3a10847f2e6d785e5fa2244ee8cfb) Thanks [@matthieusieben](https://github.com/matthieusieben)! - `LOG_ENABLED` now supports upper case (TRUE) for enabling logging
|
|
8
|
+
|
|
9
|
+
- [#5151](https://github.com/bluesky-social/atproto/pull/5151) [`a51c45d`](https://github.com/bluesky-social/atproto/commit/a51c45d38f6bd7b8765f640e564cf921d52162e7) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Update dependencies
|
|
10
|
+
|
|
11
|
+
- [#5149](https://github.com/bluesky-social/atproto/pull/5149) [`f2cf8f7`](https://github.com/bluesky-social/atproto/commit/f2cf8f7fc5f3a10847f2e6d785e5fa2244ee8cfb) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Update `pino` logger to version 10
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`a51c45d`](https://github.com/bluesky-social/atproto/commit/a51c45d38f6bd7b8765f640e564cf921d52162e7)]:
|
|
14
|
+
- @atproto/common-web@0.5.2
|
|
15
|
+
- @atproto/lex-cbor@0.1.2
|
|
16
|
+
- @atproto/lex-data@0.1.3
|
|
17
|
+
|
|
3
18
|
## 0.6.3
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const subsystemLogger: (name: string) =>
|
|
1
|
+
import { type Logger } from 'pino';
|
|
2
|
+
export declare const subsystemLogger: (name: string) => Logger;
|
|
3
3
|
//# 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,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAqB,MAAM,MAAM,CAAA;AAgBrD,eAAO,MAAM,eAAe,SAAU,MAAM,KAAG,MAY9C,CAAA"}
|
package/dist/logger.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { destination, pino } from 'pino';
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
.replace(',', ' ')
|
|
5
|
-
.split(' ');
|
|
6
|
-
const enabledEnv = process.env.LOG_ENABLED;
|
|
7
|
-
const enabled = enabledEnv === 'true' || enabledEnv === 't' || enabledEnv === '1';
|
|
2
|
+
const enabled = /^(true|t|1)$/i.test(process.env.LOG_ENABLED ?? '0');
|
|
3
|
+
const dest = process.env.LOG_DESTINATION;
|
|
8
4
|
const level = process.env.LOG_LEVEL || 'info';
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
const
|
|
14
|
-
? pino(config, destination(process.env.LOG_DESTINATION))
|
|
15
|
-
: pino(config);
|
|
16
|
-
const subsystems = {};
|
|
5
|
+
const systems = process.env.LOG_SYSTEMS?.trim()
|
|
6
|
+
? process.env.LOG_SYSTEMS.replace(',', ' ').split(/\s+/).filter(Boolean)
|
|
7
|
+
: null;
|
|
8
|
+
const rootLogger = pino({ enabled, level }, dest ? destination(dest) : undefined);
|
|
9
|
+
const subsystems = new Map();
|
|
17
10
|
export const subsystemLogger = (name) => {
|
|
18
|
-
if (subsystems
|
|
19
|
-
return subsystems
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
if (subsystems.has(name))
|
|
12
|
+
return subsystems.get(name);
|
|
13
|
+
// can't disable child loggers, so we just set their level to "silent"
|
|
14
|
+
// to effectively turn them off
|
|
15
|
+
const subsystemEnabled = !systems || systems.includes(name);
|
|
16
|
+
const subsystemLevel = enabled && subsystemEnabled ? level : 'silent';
|
|
17
|
+
const logger = rootLogger.child({ name }, { level: subsystemLevel });
|
|
18
|
+
subsystems.set(name, logger);
|
|
19
|
+
return logger;
|
|
24
20
|
};
|
|
25
21
|
//# 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,EAAe,WAAW,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAErD,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,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE;IAC7C,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IACxE,CAAC,CAAC,IAAI,CAAA;AAER,MAAM,UAAU,GAAG,IAAI,CACrB,EAAE,OAAO,EAAE,KAAK,EAAE,EAClB,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CACrC,CAAA;AAED,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAA;AAE5C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAU,EAAE;IACtD,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAE,CAAA;IAEtD,sEAAsE;IACtE,+BAA+B;IAC/B,MAAM,gBAAgB,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC3D,MAAM,cAAc,GAAG,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAA;IAErE,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAA;IAEpE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC5B,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { type Logger, destination, pino } from 'pino'\n\nconst enabled = /^(true|t|1)$/i.test(process.env.LOG_ENABLED ?? '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 = pino(\n { enabled, level },\n dest ? destination(dest) : undefined,\n)\n\nconst subsystems = new Map<string, Logger>()\n\nexport const subsystemLogger = (name: string): Logger => {\n if (subsystems.has(name)) return subsystems.get(name)!\n\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 const logger = rootLogger.child({ name }, { level: subsystemLevel })\n\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.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared web-platform-friendly code for atproto libraries",
|
|
6
6
|
"keywords": [
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"multiformats": "^13.0.0",
|
|
20
|
-
"pino": "^
|
|
21
|
-
"@atproto/
|
|
22
|
-
"@atproto/lex-
|
|
23
|
-
"@atproto/
|
|
20
|
+
"pino": "^10.3.1",
|
|
21
|
+
"@atproto/common-web": "^0.5.2",
|
|
22
|
+
"@atproto/lex-cbor": "^0.1.2",
|
|
23
|
+
"@atproto/lex-data": "^0.1.3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"jest": "^30.0.0",
|
package/src/logger.ts
CHANGED
|
@@ -1,36 +1,29 @@
|
|
|
1
|
-
import { destination, pino } from 'pino'
|
|
2
|
-
|
|
3
|
-
const allSystemsEnabled = !process.env.LOG_SYSTEMS
|
|
4
|
-
const enabledSystems = (process.env.LOG_SYSTEMS || '')
|
|
5
|
-
.replace(',', ' ')
|
|
6
|
-
.split(' ')
|
|
7
|
-
|
|
8
|
-
const enabledEnv = process.env.LOG_ENABLED
|
|
9
|
-
const enabled =
|
|
10
|
-
enabledEnv === 'true' || enabledEnv === 't' || enabledEnv === '1'
|
|
1
|
+
import { type Logger, destination, pino } from 'pino'
|
|
11
2
|
|
|
3
|
+
const enabled = /^(true|t|1)$/i.test(process.env.LOG_ENABLED ?? '0')
|
|
4
|
+
const dest = process.env.LOG_DESTINATION
|
|
12
5
|
const level = process.env.LOG_LEVEL || 'info'
|
|
6
|
+
const systems = process.env.LOG_SYSTEMS?.trim()
|
|
7
|
+
? process.env.LOG_SYSTEMS.replace(',', ' ').split(/\s+/).filter(Boolean)
|
|
8
|
+
: null
|
|
13
9
|
|
|
14
|
-
const
|
|
15
|
-
enabled,
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
const rootLogger = pino(
|
|
11
|
+
{ enabled, level },
|
|
12
|
+
dest ? destination(dest) : undefined,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
const subsystems = new Map<string, Logger>()
|
|
18
16
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
: pino(config)
|
|
17
|
+
export const subsystemLogger = (name: string): Logger => {
|
|
18
|
+
if (subsystems.has(name)) return subsystems.get(name)!
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
// can't disable child loggers, so we just set their level to "silent"
|
|
21
|
+
// to effectively turn them off
|
|
22
|
+
const subsystemEnabled = !systems || systems.includes(name)
|
|
23
|
+
const subsystemLevel = enabled && subsystemEnabled ? level : 'silent'
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
if (subsystems[name]) return subsystems[name]
|
|
27
|
-
const subsystemEnabled =
|
|
28
|
-
enabled && (allSystemsEnabled || enabledSystems.indexOf(name) > -1)
|
|
25
|
+
const logger = rootLogger.child({ name }, { level: subsystemLevel })
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
{ name },
|
|
33
|
-
{ level: subsystemEnabled ? level : 'silent' },
|
|
34
|
-
)
|
|
35
|
-
return subsystems[name]
|
|
27
|
+
subsystems.set(name, logger)
|
|
28
|
+
return logger
|
|
36
29
|
}
|