@logtape/config 2.2.0-dev.675 → 2.2.0-dev.679

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/dist/config.cjs CHANGED
@@ -69,6 +69,7 @@ async function configureFromObject(config, options) {
69
69
  });
70
70
  }
71
71
  if (config.reset) logTapeConfig.reset = true;
72
+ if (options?.contextLocalStorage) logTapeConfig.contextLocalStorage = options.contextLocalStorage;
72
73
  await (0, __logtape_logtape.configure)(logTapeConfig);
73
74
  if (warnings.length > 0) {
74
75
  const metaLogger = (0, __logtape_logtape.getLogger)(["logtape", "meta"]);
package/dist/config.js CHANGED
@@ -68,6 +68,7 @@ async function configureFromObject(config, options) {
68
68
  });
69
69
  }
70
70
  if (config.reset) logTapeConfig.reset = true;
71
+ if (options?.contextLocalStorage) logTapeConfig.contextLocalStorage = options.contextLocalStorage;
71
72
  await configure(logTapeConfig);
72
73
  if (warnings.length > 0) {
73
74
  const metaLogger = getLogger(["logtape", "meta"]);
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["config: LogTapeConfig","options?: ConfigureOptions","warnings: string[]","sinks: Record<string, Sink>","filters: Record<string, Filter>","logTapeConfig: Config<string, string>","validSinks: string[]","validFilters: string[]"],"sources":["../src/config.ts"],"sourcesContent":["import { configure, getLogger } from \"@logtape/logtape\";\nimport type { Config, Filter, Sink } from \"@logtape/logtape\";\nimport { createFilter, createSink } from \"./loader.ts\";\nimport { DEFAULT_SHORTHANDS, mergeShorthands } from \"./shorthands.ts\";\nimport { ConfigError } from \"./types.ts\";\nimport type { ConfigureOptions, LogTapeConfig } from \"./types.ts\";\n\n/**\n * Configures LogTape from a plain object.\n *\n * @param config Configuration object (typically loaded from JSON/YAML/TOML)\n * @param options Configuration options\n * @throws {ConfigError} If configuration is invalid and onInvalidConfig is \"throw\"\n *\n * @example\n * ```typescript\n * import { configureFromObject } from \"@logtape/config\";\n * import { readFile } from \"fs/promises\";\n *\n * const config = JSON.parse(await readFile(\"./logtape.json\", \"utf-8\"));\n * await configureFromObject(config);\n * ```\n * @since 2.0.0\n */\nexport async function configureFromObject(\n config: LogTapeConfig,\n options?: ConfigureOptions,\n): Promise<void> {\n const shorthands = mergeShorthands(\n DEFAULT_SHORTHANDS,\n options?.shorthands,\n );\n const onInvalidConfig = options?.onInvalidConfig ?? \"throw\";\n const warnings: string[] = [];\n\n // 1. Create sinks\n const sinks: Record<string, Sink> = {};\n if (config.sinks) {\n for (const [name, sinkConfig] of Object.entries(config.sinks)) {\n try {\n sinks[name] = await createSink(sinkConfig, shorthands);\n } catch (e) {\n if (onInvalidConfig === \"throw\") {\n throw e;\n }\n warnings.push(`Failed to create sink '${name}': ${e}`);\n }\n }\n }\n\n // 2. Create filters\n const filters: Record<string, Filter> = {};\n if (config.filters) {\n for (const [name, filterConfig] of Object.entries(config.filters)) {\n try {\n filters[name] = await createFilter(filterConfig, shorthands);\n } catch (e) {\n if (onInvalidConfig === \"throw\") {\n throw e;\n }\n warnings.push(`Failed to create filter '${name}': ${e}`);\n }\n }\n }\n\n // 3. Configure logtape\n const logTapeConfig: Config<string, string> = {\n sinks,\n filters,\n loggers: [],\n };\n\n if (config.loggers) {\n for (const loggerConfig of config.loggers) {\n // Validate sink references\n const validSinks: string[] = [];\n if (loggerConfig.sinks) {\n for (const sinkName of loggerConfig.sinks) {\n if (sinkName in sinks) {\n validSinks.push(sinkName);\n } else {\n const msg = `Logger '${\n Array.isArray(loggerConfig.category)\n ? loggerConfig.category.join(\".\")\n : loggerConfig.category\n }' references unknown or failed sink '${sinkName}'`;\n if (onInvalidConfig === \"throw\") {\n throw new ConfigError(msg);\n }\n warnings.push(msg);\n }\n }\n }\n\n // Validate filter references\n const validFilters: string[] = [];\n if (loggerConfig.filters) {\n for (const filterName of loggerConfig.filters) {\n if (filterName in filters) {\n validFilters.push(filterName);\n } else {\n const msg = `Logger '${\n Array.isArray(loggerConfig.category)\n ? loggerConfig.category.join(\".\")\n : loggerConfig.category\n }' references unknown or failed filter '${filterName}'`;\n if (onInvalidConfig === \"throw\") {\n throw new ConfigError(msg);\n }\n warnings.push(msg);\n }\n }\n }\n\n logTapeConfig.loggers.push({\n category: loggerConfig.category,\n sinks: validSinks.length > 0 ? validSinks : undefined,\n filters: validFilters.length > 0 ? validFilters : undefined,\n lowestLevel: loggerConfig.lowestLevel,\n parentSinks: loggerConfig.parentSinks,\n });\n }\n }\n\n if (config.reset) {\n logTapeConfig.reset = true;\n }\n\n await configure(logTapeConfig);\n\n // 4. Log warnings to meta logger\n if (warnings.length > 0) {\n const metaLogger = getLogger([\"logtape\", \"meta\"]);\n for (const warning of warnings) {\n metaLogger.warn(warning);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA,eAAsB,oBACpBA,QACAC,SACe;CACf,MAAM,aAAa,gBACjB,oBACA,SAAS,WACV;CACD,MAAM,kBAAkB,SAAS,mBAAmB;CACpD,MAAMC,WAAqB,CAAE;CAG7B,MAAMC,QAA8B,CAAE;AACtC,KAAI,OAAO,MACT,MAAK,MAAM,CAAC,MAAM,WAAW,IAAI,OAAO,QAAQ,OAAO,MAAM,CAC3D,KAAI;AACF,QAAM,QAAQ,MAAM,WAAW,YAAY,WAAW;CACvD,SAAQ,GAAG;AACV,MAAI,oBAAoB,QACtB,OAAM;AAER,WAAS,MAAM,yBAAyB,KAAK,KAAK,EAAE,EAAE;CACvD;CAKL,MAAMC,UAAkC,CAAE;AAC1C,KAAI,OAAO,QACT,MAAK,MAAM,CAAC,MAAM,aAAa,IAAI,OAAO,QAAQ,OAAO,QAAQ,CAC/D,KAAI;AACF,UAAQ,QAAQ,MAAM,aAAa,cAAc,WAAW;CAC7D,SAAQ,GAAG;AACV,MAAI,oBAAoB,QACtB,OAAM;AAER,WAAS,MAAM,2BAA2B,KAAK,KAAK,EAAE,EAAE;CACzD;CAKL,MAAMC,gBAAwC;EAC5C;EACA;EACA,SAAS,CAAE;CACZ;AAED,KAAI,OAAO,QACT,MAAK,MAAM,gBAAgB,OAAO,SAAS;EAEzC,MAAMC,aAAuB,CAAE;AAC/B,MAAI,aAAa,MACf,MAAK,MAAM,YAAY,aAAa,MAClC,KAAI,YAAY,MACd,YAAW,KAAK,SAAS;OACpB;GACL,MAAM,OAAO,UACX,MAAM,QAAQ,aAAa,SAAS,GAChC,aAAa,SAAS,KAAK,IAAI,GAC/B,aAAa,SAClB,uCAAuC,SAAS;AACjD,OAAI,oBAAoB,QACtB,OAAM,IAAI,YAAY;AAExB,YAAS,KAAK,IAAI;EACnB;EAKL,MAAMC,eAAyB,CAAE;AACjC,MAAI,aAAa,QACf,MAAK,MAAM,cAAc,aAAa,QACpC,KAAI,cAAc,QAChB,cAAa,KAAK,WAAW;OACxB;GACL,MAAM,OAAO,UACX,MAAM,QAAQ,aAAa,SAAS,GAChC,aAAa,SAAS,KAAK,IAAI,GAC/B,aAAa,SAClB,yCAAyC,WAAW;AACrD,OAAI,oBAAoB,QACtB,OAAM,IAAI,YAAY;AAExB,YAAS,KAAK,IAAI;EACnB;AAIL,gBAAc,QAAQ,KAAK;GACzB,UAAU,aAAa;GACvB,OAAO,WAAW,SAAS,IAAI;GAC/B,SAAS,aAAa,SAAS,IAAI;GACnC,aAAa,aAAa;GAC1B,aAAa,aAAa;EAC3B,EAAC;CACH;AAGH,KAAI,OAAO,MACT,eAAc,QAAQ;AAGxB,OAAM,UAAU,cAAc;AAG9B,KAAI,SAAS,SAAS,GAAG;EACvB,MAAM,aAAa,UAAU,CAAC,WAAW,MAAO,EAAC;AACjD,OAAK,MAAM,WAAW,SACpB,YAAW,KAAK,QAAQ;CAE3B;AACF"}
1
+ {"version":3,"file":"config.js","names":["config: LogTapeConfig","options?: ConfigureOptions","warnings: string[]","sinks: Record<string, Sink>","filters: Record<string, Filter>","logTapeConfig: Config<string, string>","validSinks: string[]","validFilters: string[]"],"sources":["../src/config.ts"],"sourcesContent":["import { configure, getLogger } from \"@logtape/logtape\";\nimport type { Config, Filter, Sink } from \"@logtape/logtape\";\nimport { createFilter, createSink } from \"./loader.ts\";\nimport { DEFAULT_SHORTHANDS, mergeShorthands } from \"./shorthands.ts\";\nimport { ConfigError } from \"./types.ts\";\nimport type { ConfigureOptions, LogTapeConfig } from \"./types.ts\";\n\n/**\n * Configures LogTape from a plain object.\n *\n * @param config Configuration object (typically loaded from JSON/YAML/TOML)\n * @param options Configuration options\n * @throws {ConfigError} If configuration is invalid and onInvalidConfig is \"throw\"\n *\n * @example\n * ```typescript\n * import { configureFromObject } from \"@logtape/config\";\n * import { readFile } from \"fs/promises\";\n *\n * const config = JSON.parse(await readFile(\"./logtape.json\", \"utf-8\"));\n * await configureFromObject(config);\n * ```\n * @since 2.0.0\n */\nexport async function configureFromObject(\n config: LogTapeConfig,\n options?: ConfigureOptions,\n): Promise<void> {\n const shorthands = mergeShorthands(\n DEFAULT_SHORTHANDS,\n options?.shorthands,\n );\n const onInvalidConfig = options?.onInvalidConfig ?? \"throw\";\n const warnings: string[] = [];\n\n // 1. Create sinks\n const sinks: Record<string, Sink> = {};\n if (config.sinks) {\n for (const [name, sinkConfig] of Object.entries(config.sinks)) {\n try {\n sinks[name] = await createSink(sinkConfig, shorthands);\n } catch (e) {\n if (onInvalidConfig === \"throw\") {\n throw e;\n }\n warnings.push(`Failed to create sink '${name}': ${e}`);\n }\n }\n }\n\n // 2. Create filters\n const filters: Record<string, Filter> = {};\n if (config.filters) {\n for (const [name, filterConfig] of Object.entries(config.filters)) {\n try {\n filters[name] = await createFilter(filterConfig, shorthands);\n } catch (e) {\n if (onInvalidConfig === \"throw\") {\n throw e;\n }\n warnings.push(`Failed to create filter '${name}': ${e}`);\n }\n }\n }\n\n // 3. Configure logtape\n const logTapeConfig: Config<string, string> = {\n sinks,\n filters,\n loggers: [],\n };\n\n if (config.loggers) {\n for (const loggerConfig of config.loggers) {\n // Validate sink references\n const validSinks: string[] = [];\n if (loggerConfig.sinks) {\n for (const sinkName of loggerConfig.sinks) {\n if (sinkName in sinks) {\n validSinks.push(sinkName);\n } else {\n const msg = `Logger '${\n Array.isArray(loggerConfig.category)\n ? loggerConfig.category.join(\".\")\n : loggerConfig.category\n }' references unknown or failed sink '${sinkName}'`;\n if (onInvalidConfig === \"throw\") {\n throw new ConfigError(msg);\n }\n warnings.push(msg);\n }\n }\n }\n\n // Validate filter references\n const validFilters: string[] = [];\n if (loggerConfig.filters) {\n for (const filterName of loggerConfig.filters) {\n if (filterName in filters) {\n validFilters.push(filterName);\n } else {\n const msg = `Logger '${\n Array.isArray(loggerConfig.category)\n ? loggerConfig.category.join(\".\")\n : loggerConfig.category\n }' references unknown or failed filter '${filterName}'`;\n if (onInvalidConfig === \"throw\") {\n throw new ConfigError(msg);\n }\n warnings.push(msg);\n }\n }\n }\n\n logTapeConfig.loggers.push({\n category: loggerConfig.category,\n sinks: validSinks.length > 0 ? validSinks : undefined,\n filters: validFilters.length > 0 ? validFilters : undefined,\n lowestLevel: loggerConfig.lowestLevel,\n parentSinks: loggerConfig.parentSinks,\n });\n }\n }\n\n if (config.reset) {\n logTapeConfig.reset = true;\n }\n\n if (options?.contextLocalStorage) {\n logTapeConfig.contextLocalStorage = options.contextLocalStorage;\n }\n\n await configure(logTapeConfig);\n\n // 4. Log warnings to meta logger\n if (warnings.length > 0) {\n const metaLogger = getLogger([\"logtape\", \"meta\"]);\n for (const warning of warnings) {\n metaLogger.warn(warning);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA,eAAsB,oBACpBA,QACAC,SACe;CACf,MAAM,aAAa,gBACjB,oBACA,SAAS,WACV;CACD,MAAM,kBAAkB,SAAS,mBAAmB;CACpD,MAAMC,WAAqB,CAAE;CAG7B,MAAMC,QAA8B,CAAE;AACtC,KAAI,OAAO,MACT,MAAK,MAAM,CAAC,MAAM,WAAW,IAAI,OAAO,QAAQ,OAAO,MAAM,CAC3D,KAAI;AACF,QAAM,QAAQ,MAAM,WAAW,YAAY,WAAW;CACvD,SAAQ,GAAG;AACV,MAAI,oBAAoB,QACtB,OAAM;AAER,WAAS,MAAM,yBAAyB,KAAK,KAAK,EAAE,EAAE;CACvD;CAKL,MAAMC,UAAkC,CAAE;AAC1C,KAAI,OAAO,QACT,MAAK,MAAM,CAAC,MAAM,aAAa,IAAI,OAAO,QAAQ,OAAO,QAAQ,CAC/D,KAAI;AACF,UAAQ,QAAQ,MAAM,aAAa,cAAc,WAAW;CAC7D,SAAQ,GAAG;AACV,MAAI,oBAAoB,QACtB,OAAM;AAER,WAAS,MAAM,2BAA2B,KAAK,KAAK,EAAE,EAAE;CACzD;CAKL,MAAMC,gBAAwC;EAC5C;EACA;EACA,SAAS,CAAE;CACZ;AAED,KAAI,OAAO,QACT,MAAK,MAAM,gBAAgB,OAAO,SAAS;EAEzC,MAAMC,aAAuB,CAAE;AAC/B,MAAI,aAAa,MACf,MAAK,MAAM,YAAY,aAAa,MAClC,KAAI,YAAY,MACd,YAAW,KAAK,SAAS;OACpB;GACL,MAAM,OAAO,UACX,MAAM,QAAQ,aAAa,SAAS,GAChC,aAAa,SAAS,KAAK,IAAI,GAC/B,aAAa,SAClB,uCAAuC,SAAS;AACjD,OAAI,oBAAoB,QACtB,OAAM,IAAI,YAAY;AAExB,YAAS,KAAK,IAAI;EACnB;EAKL,MAAMC,eAAyB,CAAE;AACjC,MAAI,aAAa,QACf,MAAK,MAAM,cAAc,aAAa,QACpC,KAAI,cAAc,QAChB,cAAa,KAAK,WAAW;OACxB;GACL,MAAM,OAAO,UACX,MAAM,QAAQ,aAAa,SAAS,GAChC,aAAa,SAAS,KAAK,IAAI,GAC/B,aAAa,SAClB,yCAAyC,WAAW;AACrD,OAAI,oBAAoB,QACtB,OAAM,IAAI,YAAY;AAExB,YAAS,KAAK,IAAI;EACnB;AAIL,gBAAc,QAAQ,KAAK;GACzB,UAAU,aAAa;GACvB,OAAO,WAAW,SAAS,IAAI;GAC/B,SAAS,aAAa,SAAS,IAAI;GACnC,aAAa,aAAa;GAC1B,aAAa,aAAa;EAC3B,EAAC;CACH;AAGH,KAAI,OAAO,MACT,eAAc,QAAQ;AAGxB,KAAI,SAAS,oBACX,eAAc,sBAAsB,QAAQ;AAG9C,OAAM,UAAU,cAAc;AAG9B,KAAI,SAAS,SAAS,GAAG;EACvB,MAAM,aAAa,UAAU,CAAC,WAAW,MAAO,EAAC;AACjD,OAAK,MAAM,WAAW,SACpB,YAAW,KAAK,QAAQ;CAE3B;AACF"}
package/dist/types.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { LogLevel } from "@logtape/logtape";
1
+ import { ContextLocalStorage, LogLevel } from "@logtape/logtape";
2
2
 
3
3
  //#region src/types.d.ts
4
4
 
@@ -109,6 +109,23 @@ interface ConfigureOptions {
109
109
  * Custom shorthand mappings to extend or override defaults.
110
110
  */
111
111
  shorthands?: ShorthandRegistry;
112
+ /**
113
+ * The context-local storage to use for implicit contexts.
114
+ *
115
+ * In Node.js, Deno, and Bun, you can use `AsyncLocalStorage` from
116
+ * the `node:async_hooks` module.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * import { AsyncLocalStorage } from "node:async_hooks";
121
+ * import { configureFromObject } from "@logtape/config";
122
+ *
123
+ * await configureFromObject(config, {
124
+ * contextLocalStorage: new AsyncLocalStorage(),
125
+ * });
126
+ * ```
127
+ */
128
+ contextLocalStorage?: ContextLocalStorage<Record<string, unknown>>;
112
129
  /**
113
130
  * How to handle invalid configuration entries.
114
131
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA;;AAIyB,UAJR,aAAA,CAIQ;EAAU;;;EAKjB,KAKN,CAAA,EAVF,MAUE,CAAA,MAAA,EAVa,UAUb,CAAA;EAAY;AAYxB;AAaA;EAWiB,OAAA,CAAA,EAzCL,MAyCK,CAAA,MAAe,EAzCL,YAyCK,CAAA;EAWf;AA+BjB;;EAAkC,OAIxB,CAAA,EAlFE,YAkFF,EAAA;EAAM;;AAUK;EAOJ,KAAA,CAAA,EAAA,OAAA;AAmBjB;AA6BA;;;;UAvIiB,UAAA;;;;uBAIM;;;;;;;;UASN,YAAA;;;;;;;;;;UAWA,eAAA;;;;;;;;;;UAWA,YAAA;;;;;;;;;;;;;;;;gBAmBD;;;;;;;;;;UAYC,iBAAA;;;;UAIP;;;;YAKE;;;;eAKG;;;;;;UAOE,gBAAA;;;;eAIF;;;;;;;;;;;;;UAeE,mBAAA;;;;;YAKL;;;;;;;;;;;cAwBC,WAAA,SAAoB,KAAK"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA;;AAIyB,UAJR,aAAA,CAIQ;EAAU;;;EAKjB,KAKN,CAAA,EAVF,MAUE,CAAA,MAAA,EAVa,UAUb,CAAA;EAAY;AAYxB;AAaA;EAWiB,OAAA,CAAA,EAzCL,MAyCK,CAAA,MAAe,EAzCL,YAyCK,CAAA;EAWf;AA+BjB;;EAAkC,OAIxB,CAAA,EAlFE,YAkFF,EAAA;EAAM;;AAUK;EAOJ,KAAA,CAAA,EAAA,OAAA;;;;;AAsB0B;AAe1B,UA5HA,UAAA,CA4HmB;EA6BvB;;;uBArJU;;;;;;;;UASN,YAAA;;;;;;;;;;UAWA,eAAA;;;;;;;;;;UAWA,YAAA;;;;;;;;;;;;;;;;gBAmBD;;;;;;;;;;UAYC,iBAAA;;;;UAIP;;;;YAKE;;;;eAKG;;;;;;UAOE,gBAAA;;;;eAIF;;;;;;;;;;;;;;;;;wBAkBS,oBAAoB;;;;;;;;;;;;;UAe3B,mBAAA;;;;;YAKL;;;;;;;;;;;cAwBC,WAAA,SAAoB,KAAK"}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LogLevel } from "@logtape/logtape";
1
+ import { ContextLocalStorage, LogLevel } from "@logtape/logtape";
2
2
 
3
3
  //#region src/types.d.ts
4
4
 
@@ -109,6 +109,23 @@ interface ConfigureOptions {
109
109
  * Custom shorthand mappings to extend or override defaults.
110
110
  */
111
111
  shorthands?: ShorthandRegistry;
112
+ /**
113
+ * The context-local storage to use for implicit contexts.
114
+ *
115
+ * In Node.js, Deno, and Bun, you can use `AsyncLocalStorage` from
116
+ * the `node:async_hooks` module.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * import { AsyncLocalStorage } from "node:async_hooks";
121
+ * import { configureFromObject } from "@logtape/config";
122
+ *
123
+ * await configureFromObject(config, {
124
+ * contextLocalStorage: new AsyncLocalStorage(),
125
+ * });
126
+ * ```
127
+ */
128
+ contextLocalStorage?: ContextLocalStorage<Record<string, unknown>>;
112
129
  /**
113
130
  * How to handle invalid configuration entries.
114
131
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA;;AAIyB,UAJR,aAAA,CAIQ;EAAU;;;EAKjB,KAKN,CAAA,EAVF,MAUE,CAAA,MAAA,EAVa,UAUb,CAAA;EAAY;AAYxB;AAaA;EAWiB,OAAA,CAAA,EAzCL,MAyCK,CAAA,MAAe,EAzCL,YAyCK,CAAA;EAWf;AA+BjB;;EAAkC,OAIxB,CAAA,EAlFE,YAkFF,EAAA;EAAM;;AAUK;EAOJ,KAAA,CAAA,EAAA,OAAA;AAmBjB;AA6BA;;;;UAvIiB,UAAA;;;;uBAIM;;;;;;;;UASN,YAAA;;;;;;;;;;UAWA,eAAA;;;;;;;;;;UAWA,YAAA;;;;;;;;;;;;;;;;gBAmBD;;;;;;;;;;UAYC,iBAAA;;;;UAIP;;;;YAKE;;;;eAKG;;;;;;UAOE,gBAAA;;;;eAIF;;;;;;;;;;;;;UAeE,mBAAA;;;;;YAKL;;;;;;;;;;;cAwBC,WAAA,SAAoB,KAAK"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA;;AAIyB,UAJR,aAAA,CAIQ;EAAU;;;EAKjB,KAKN,CAAA,EAVF,MAUE,CAAA,MAAA,EAVa,UAUb,CAAA;EAAY;AAYxB;AAaA;EAWiB,OAAA,CAAA,EAzCL,MAyCK,CAAA,MAAe,EAzCL,YAyCK,CAAA;EAWf;AA+BjB;;EAAkC,OAIxB,CAAA,EAlFE,YAkFF,EAAA;EAAM;;AAUK;EAOJ,KAAA,CAAA,EAAA,OAAA;;;;;AAsB0B;AAe1B,UA5HA,UAAA,CA4HmB;EA6BvB;;;uBArJU;;;;;;;;UASN,YAAA;;;;;;;;;;UAWA,eAAA;;;;;;;;;;UAWA,YAAA;;;;;;;;;;;;;;;;gBAmBD;;;;;;;;;;UAYC,iBAAA;;;;UAIP;;;;YAKE;;;;eAKG;;;;;;UAOE,gBAAA;;;;eAIF;;;;;;;;;;;;;;;;;wBAkBS,oBAAoB;;;;;;;;;;;;;UAe3B,mBAAA;;;;;YAKL;;;;;;;;;;;cAwBC,WAAA,SAAoB,KAAK"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["message: string"],"sources":["../src/types.ts"],"sourcesContent":["import type { LogLevel } from \"@logtape/logtape\";\n\n/**\n * Configuration object schema for `configureFromObject()`.\n * @since 2.0.0\n */\nexport interface LogTapeConfig {\n /**\n * The sinks to configure.\n */\n sinks?: Record<string, SinkConfig>;\n\n /**\n * The filters to configure.\n */\n filters?: Record<string, FilterConfig>;\n\n /**\n * The loggers to configure.\n */\n loggers?: LoggerConfig[];\n\n /**\n * Whether to reset the configuration before applying this one.\n */\n reset?: boolean;\n}\n\n/**\n * Sink configuration with module reference.\n * @since 2.0.0\n */\nexport interface SinkConfig {\n /** Module reference in `module#export()` format */\n type: string;\n /** Formatter configuration or shorthand */\n formatter?: string | FormatterConfig;\n /** Additional options passed to the factory function */\n [key: string]: unknown;\n}\n\n/**\n * Filter configuration with module reference.\n * @since 2.0.0\n */\nexport interface FilterConfig {\n /** Module reference in `module#export()` format */\n type: string;\n /** Additional options passed to the factory function */\n [key: string]: unknown;\n}\n\n/**\n * Formatter configuration with module reference.\n * @since 2.0.0\n */\nexport interface FormatterConfig {\n /** Module reference in `module#export()` format */\n type: string;\n /** Additional options passed to the factory function */\n [key: string]: unknown;\n}\n\n/**\n * Logger configuration.\n * @since 2.0.0\n */\nexport interface LoggerConfig {\n /**\n * The category of the logger.\n */\n category: string | string[];\n\n /**\n * The sink identifiers to use.\n */\n sinks?: string[];\n\n /**\n * The filter identifiers to use.\n */\n filters?: string[];\n\n /**\n * The lowest log level to log.\n */\n lowestLevel?: LogLevel;\n\n /**\n * Whether to inherit the parent's sinks.\n */\n parentSinks?: \"inherit\" | \"override\";\n}\n\n/**\n * Registry of shorthand mappings.\n * @since 2.0.0\n */\nexport interface ShorthandRegistry {\n /**\n * The shorthand mappings for sinks.\n */\n sinks?: Record<string, string>;\n\n /**\n * The shorthand mappings for filters.\n */\n filters?: Record<string, string>;\n\n /**\n * The shorthand mappings for formatters.\n */\n formatters?: Record<string, string>;\n}\n\n/**\n * Options for `configureFromObject()`.\n * @since 2.0.0\n */\nexport interface ConfigureOptions {\n /**\n * Custom shorthand mappings to extend or override defaults.\n */\n shorthands?: ShorthandRegistry;\n\n /**\n * How to handle invalid configuration entries.\n *\n * - `\"throw\"` (default): Throw `ConfigError` on any invalid configuration.\n * - `\"warn\"`: Apply only valid parts and log warnings to meta logger.\n */\n onInvalidConfig?: \"throw\" | \"warn\";\n}\n\n/**\n * Options for environment variable expansion.\n * @since 2.0.0\n */\nexport interface EnvExpansionOptions {\n /**\n * Regular expression pattern for matching environment variables.\n * Default: `/\\$\\{([^}:]+)(?::([^}]+))?\\}/g` (matches `${VAR}` or `${VAR:default}`)\n */\n pattern?: RegExp;\n}\n\n/**\n * Parsed module reference.\n * @since 2.0.0\n */\nexport interface ParsedModuleReference {\n /** Whether this is a shorthand (starts with #) */\n isShorthand: boolean;\n /** The shorthand name (if isShorthand is true) */\n shorthandName?: string;\n /** The module path */\n modulePath?: string;\n /** The export name (after #) */\n exportName?: string;\n /** Whether this is a factory function (ends with ()) */\n isFactory: boolean;\n}\n\n/**\n * Error thrown when configuration is invalid.\n * @since 2.0.0\n */\nexport class ConfigError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigError\";\n }\n}\n"],"mappings":";;;;;AAuKA,IAAa,cAAb,cAAiC,MAAM;CACrC,YAAYA,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;CACb;AACF"}
1
+ {"version":3,"file":"types.js","names":["message: string"],"sources":["../src/types.ts"],"sourcesContent":["import type { ContextLocalStorage, LogLevel } from \"@logtape/logtape\";\n\n/**\n * Configuration object schema for `configureFromObject()`.\n * @since 2.0.0\n */\nexport interface LogTapeConfig {\n /**\n * The sinks to configure.\n */\n sinks?: Record<string, SinkConfig>;\n\n /**\n * The filters to configure.\n */\n filters?: Record<string, FilterConfig>;\n\n /**\n * The loggers to configure.\n */\n loggers?: LoggerConfig[];\n\n /**\n * Whether to reset the configuration before applying this one.\n */\n reset?: boolean;\n}\n\n/**\n * Sink configuration with module reference.\n * @since 2.0.0\n */\nexport interface SinkConfig {\n /** Module reference in `module#export()` format */\n type: string;\n /** Formatter configuration or shorthand */\n formatter?: string | FormatterConfig;\n /** Additional options passed to the factory function */\n [key: string]: unknown;\n}\n\n/**\n * Filter configuration with module reference.\n * @since 2.0.0\n */\nexport interface FilterConfig {\n /** Module reference in `module#export()` format */\n type: string;\n /** Additional options passed to the factory function */\n [key: string]: unknown;\n}\n\n/**\n * Formatter configuration with module reference.\n * @since 2.0.0\n */\nexport interface FormatterConfig {\n /** Module reference in `module#export()` format */\n type: string;\n /** Additional options passed to the factory function */\n [key: string]: unknown;\n}\n\n/**\n * Logger configuration.\n * @since 2.0.0\n */\nexport interface LoggerConfig {\n /**\n * The category of the logger.\n */\n category: string | string[];\n\n /**\n * The sink identifiers to use.\n */\n sinks?: string[];\n\n /**\n * The filter identifiers to use.\n */\n filters?: string[];\n\n /**\n * The lowest log level to log.\n */\n lowestLevel?: LogLevel;\n\n /**\n * Whether to inherit the parent's sinks.\n */\n parentSinks?: \"inherit\" | \"override\";\n}\n\n/**\n * Registry of shorthand mappings.\n * @since 2.0.0\n */\nexport interface ShorthandRegistry {\n /**\n * The shorthand mappings for sinks.\n */\n sinks?: Record<string, string>;\n\n /**\n * The shorthand mappings for filters.\n */\n filters?: Record<string, string>;\n\n /**\n * The shorthand mappings for formatters.\n */\n formatters?: Record<string, string>;\n}\n\n/**\n * Options for `configureFromObject()`.\n * @since 2.0.0\n */\nexport interface ConfigureOptions {\n /**\n * Custom shorthand mappings to extend or override defaults.\n */\n shorthands?: ShorthandRegistry;\n\n /**\n * The context-local storage to use for implicit contexts.\n *\n * In Node.js, Deno, and Bun, you can use `AsyncLocalStorage` from\n * the `node:async_hooks` module.\n *\n * @example\n * ```typescript\n * import { AsyncLocalStorage } from \"node:async_hooks\";\n * import { configureFromObject } from \"@logtape/config\";\n *\n * await configureFromObject(config, {\n * contextLocalStorage: new AsyncLocalStorage(),\n * });\n * ```\n */\n contextLocalStorage?: ContextLocalStorage<Record<string, unknown>>;\n\n /**\n * How to handle invalid configuration entries.\n *\n * - `\"throw\"` (default): Throw `ConfigError` on any invalid configuration.\n * - `\"warn\"`: Apply only valid parts and log warnings to meta logger.\n */\n onInvalidConfig?: \"throw\" | \"warn\";\n}\n\n/**\n * Options for environment variable expansion.\n * @since 2.0.0\n */\nexport interface EnvExpansionOptions {\n /**\n * Regular expression pattern for matching environment variables.\n * Default: `/\\$\\{([^}:]+)(?::([^}]+))?\\}/g` (matches `${VAR}` or `${VAR:default}`)\n */\n pattern?: RegExp;\n}\n\n/**\n * Parsed module reference.\n * @since 2.0.0\n */\nexport interface ParsedModuleReference {\n /** Whether this is a shorthand (starts with #) */\n isShorthand: boolean;\n /** The shorthand name (if isShorthand is true) */\n shorthandName?: string;\n /** The module path */\n modulePath?: string;\n /** The export name (after #) */\n exportName?: string;\n /** Whether this is a factory function (ends with ()) */\n isFactory: boolean;\n}\n\n/**\n * Error thrown when configuration is invalid.\n * @since 2.0.0\n */\nexport class ConfigError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigError\";\n }\n}\n"],"mappings":";;;;;AAyLA,IAAa,cAAb,cAAiC,MAAM;CACrC,YAAYA,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;CACb;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logtape/config",
3
- "version": "2.2.0-dev.675+f2dd45bd",
3
+ "version": "2.2.0-dev.679+7d928b73",
4
4
  "description": "Configure LogTape from plain objects (JSON, YAML, TOML)",
5
5
  "keywords": [
6
6
  "logging",
@@ -49,7 +49,7 @@
49
49
  "dist/"
50
50
  ],
51
51
  "peerDependencies": {
52
- "@logtape/logtape": "^2.2.0-dev.675+f2dd45bd"
52
+ "@logtape/logtape": "^2.2.0-dev.679+7d928b73"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@alinea/suite": "^0.6.3",