@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 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 { pino } from 'pino';
2
- export declare const subsystemLogger: (name: string) => pino.Logger;
1
+ import { type Logger } from 'pino';
2
+ export declare const subsystemLogger: (name: string) => Logger;
3
3
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,MAAM,CAAA;AAwBxC,eAAO,MAAM,eAAe,SAAU,MAAM,KAAG,IAAI,CAAC,MAWnD,CAAA"}
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 allSystemsEnabled = !process.env.LOG_SYSTEMS;
3
- const enabledSystems = (process.env.LOG_SYSTEMS || '')
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 config = {
10
- enabled,
11
- level,
12
- };
13
- const rootLogger = process.env.LOG_DESTINATION
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[name])
19
- return subsystems[name];
20
- const subsystemEnabled = enabled && (allSystemsEnabled || enabledSystems.indexOf(name) > -1);
21
- // can't disable child loggers, so we just set their level to fatal to effectively turn them off
22
- subsystems[name] = rootLogger.child({ name }, { level: subsystemEnabled ? level : 'silent' });
23
- return subsystems[name];
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
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAExC,MAAM,iBAAiB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;AAClD,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;KACnD,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;KACjB,KAAK,CAAC,GAAG,CAAC,CAAA;AAEb,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;AAC1C,MAAM,OAAO,GACX,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,GAAG,CAAA;AAEnE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM,CAAA;AAE7C,MAAM,MAAM,GAAG;IACb,OAAO;IACP,KAAK;CACN,CAAA;AAED,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe;IAC5C,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACxD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAEhB,MAAM,UAAU,GAAgC,EAAE,CAAA;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAe,EAAE;IAC3D,IAAI,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA;IAC7C,MAAM,gBAAgB,GACpB,OAAO,IAAI,CAAC,iBAAiB,IAAI,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAErE,gGAAgG;IAChG,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,CACjC,EAAE,IAAI,EAAE,EACR,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAC/C,CAAA;IACD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC,CAAA","sourcesContent":["import { destination, pino } from 'pino'\n\nconst allSystemsEnabled = !process.env.LOG_SYSTEMS\nconst enabledSystems = (process.env.LOG_SYSTEMS || '')\n .replace(',', ' ')\n .split(' ')\n\nconst enabledEnv = process.env.LOG_ENABLED\nconst enabled =\n enabledEnv === 'true' || enabledEnv === 't' || enabledEnv === '1'\n\nconst level = process.env.LOG_LEVEL || 'info'\n\nconst config = {\n enabled,\n level,\n}\n\nconst rootLogger = process.env.LOG_DESTINATION\n ? pino(config, destination(process.env.LOG_DESTINATION))\n : pino(config)\n\nconst subsystems: Record<string, pino.Logger> = {}\n\nexport const subsystemLogger = (name: string): pino.Logger => {\n if (subsystems[name]) return subsystems[name]\n const subsystemEnabled =\n enabled && (allSystemsEnabled || enabledSystems.indexOf(name) > -1)\n\n // can't disable child loggers, so we just set their level to fatal to effectively turn them off\n subsystems[name] = rootLogger.child(\n { name },\n { level: subsystemEnabled ? level : 'silent' },\n )\n return subsystems[name]\n}\n"]}
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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= 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",
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": "^8.21.0",
21
- "@atproto/lex-cbor": "^0.1.1",
22
- "@atproto/lex-data": "^0.1.2",
23
- "@atproto/common-web": "^0.5.1"
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 config = {
15
- enabled,
16
- level,
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 rootLogger = process.env.LOG_DESTINATION
20
- ? pino(config, destination(process.env.LOG_DESTINATION))
21
- : pino(config)
17
+ export const subsystemLogger = (name: string): Logger => {
18
+ if (subsystems.has(name)) return subsystems.get(name)!
22
19
 
23
- const subsystems: Record<string, pino.Logger> = {}
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
- export const subsystemLogger = (name: string): pino.Logger => {
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
- // can't disable child loggers, so we just set their level to fatal to effectively turn them off
31
- subsystems[name] = rootLogger.child(
32
- { name },
33
- { level: subsystemEnabled ? level : 'silent' },
34
- )
35
- return subsystems[name]
27
+ subsystems.set(name, logger)
28
+ return logger
36
29
  }