@logtape/adaptor-pino 1.1.0-dev.315 → 1.1.0-dev.323

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/deno.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@logtape/adaptor-pino",
3
- "version": "1.1.0-dev.315+fc46f65c",
3
+ "version": "1.1.0-dev.323+146f8194",
4
4
  "license": "MIT",
5
- "exports": "./mod.ts",
5
+ "exports": "./src/mod.ts",
6
6
  "imports": {
7
7
  "pino-abstract-transport": "npm:pino-abstract-transport@^2.0.0"
8
8
  },
package/dist/mod.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
2
  const __logtape_logtape = require_rolldown_runtime.__toESM(require("@logtape/logtape"));
3
3
 
4
- //#region mod.ts
4
+ //#region src/mod.ts
5
5
  /**
6
6
  * Creates a LogTape sink that forwards log records to a Pino logger.
7
7
  *
@@ -32,8 +32,8 @@ const __logtape_logtape = require_rolldown_runtime.__toESM(require("@logtape/log
32
32
  * });
33
33
  * ```
34
34
  *
35
- * @typeParam CustomLevels The custom log levels supported by the Pino logger.
36
- * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined
35
+ * @template CustomLevels The custom log levels supported by the Pino logger.
36
+ * @template UseOnlyCustomLevels Whether to use only custom levels defined
37
37
  * in the Pino logger.
38
38
  * @param logger The Pino logger instance to forward logs to.
39
39
  * @param options Configuration options for the sink adapter.
@@ -118,8 +118,8 @@ function getPinoSink(logger, options = {}) {
118
118
  * });
119
119
  * ```
120
120
  *
121
- * @typeParam CustomLevels The custom log levels supported by the Pino logger.
122
- * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined
121
+ * @template CustomLevels The custom log levels supported by the Pino logger.
122
+ * @template UseOnlyCustomLevels Whether to use only custom levels defined
123
123
  * in the Pino logger.
124
124
  * @param logger The Pino logger instance to forward logs to.
125
125
  * @param options Configuration options for the sink adapter.
package/dist/mod.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Logger } from "pino";
2
2
  import { Sink } from "@logtape/logtape";
3
3
 
4
- //#region mod.d.ts
4
+ //#region src/mod.d.ts
5
5
 
6
6
  /**
7
7
  * Options for configuring the Pino sink adapter.
@@ -78,8 +78,8 @@ interface CategoryOptions {
78
78
  * });
79
79
  * ```
80
80
  *
81
- * @typeParam CustomLevels The custom log levels supported by the Pino logger.
82
- * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined
81
+ * @template CustomLevels The custom log levels supported by the Pino logger.
82
+ * @template UseOnlyCustomLevels Whether to use only custom levels defined
83
83
  * in the Pino logger.
84
84
  * @param logger The Pino logger instance to forward logs to.
85
85
  * @param options Configuration options for the sink adapter.
@@ -130,8 +130,8 @@ declare function getPinoSink<CustomLevels extends string, UseOnlyCustomLevels ex
130
130
  * });
131
131
  * ```
132
132
  *
133
- * @typeParam CustomLevels The custom log levels supported by the Pino logger.
134
- * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined
133
+ * @template CustomLevels The custom log levels supported by the Pino logger.
134
+ * @template UseOnlyCustomLevels Whether to use only custom levels defined
135
135
  * in the Pino logger.
136
136
  * @param logger The Pino logger instance to forward logs to.
137
137
  * @param options Configuration options for the sink adapter.
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.cts","names":[],"sources":["../mod.ts"],"sourcesContent":[],"mappings":";;;;;;;AAOA;AAcA;AAqEgB,UAnFC,eAAA,CAmFU;EAAA;;;;;;EAMpB,SAAA,QAAA,CAAA,EAAA,OAAA,GAlFyB,eAkFzB;AAqIP;;;;;AAKW,UArNM,eAAA,CAqNN;EAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAhJf,sFAIN,OAAO,cAAc,gCACpB,kBACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqIa,kFAIN,OAAO,cAAc,gCACpB"}
1
+ {"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;;;AAOA;AAcA;AAqEgB,UAnFC,eAAA,CAmFU;EAAA;;;;;;EAMpB,SAAA,QAAA,CAAA,EAAA,OAAA,GAlFyB,eAkFzB;AAqIP;;;;;AAKW,UArNM,eAAA,CAqNN;EAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAhJf,sFAIN,OAAO,cAAc,gCACpB,kBACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqIa,kFAIN,OAAO,cAAc,gCACpB"}
package/dist/mod.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Sink } from "@logtape/logtape";
2
2
  import { Logger } from "pino";
3
3
 
4
- //#region mod.d.ts
4
+ //#region src/mod.d.ts
5
5
 
6
6
  /**
7
7
  * Options for configuring the Pino sink adapter.
@@ -78,8 +78,8 @@ interface CategoryOptions {
78
78
  * });
79
79
  * ```
80
80
  *
81
- * @typeParam CustomLevels The custom log levels supported by the Pino logger.
82
- * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined
81
+ * @template CustomLevels The custom log levels supported by the Pino logger.
82
+ * @template UseOnlyCustomLevels Whether to use only custom levels defined
83
83
  * in the Pino logger.
84
84
  * @param logger The Pino logger instance to forward logs to.
85
85
  * @param options Configuration options for the sink adapter.
@@ -130,8 +130,8 @@ declare function getPinoSink<CustomLevels extends string, UseOnlyCustomLevels ex
130
130
  * });
131
131
  * ```
132
132
  *
133
- * @typeParam CustomLevels The custom log levels supported by the Pino logger.
134
- * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined
133
+ * @template CustomLevels The custom log levels supported by the Pino logger.
134
+ * @template UseOnlyCustomLevels Whether to use only custom levels defined
135
135
  * in the Pino logger.
136
136
  * @param logger The Pino logger instance to forward logs to.
137
137
  * @param options Configuration options for the sink adapter.
package/dist/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","names":[],"sources":["../mod.ts"],"sourcesContent":[],"mappings":";;;;;;;AAOA;AAcA;AAqEgB,UAnFC,eAAA,CAmFU;EAAA;;;;;;EAMpB,SAAA,QAAA,CAAA,EAAA,OAAA,GAlFyB,eAkFzB;AAqIP;;;;;AAKW,UArNM,eAAA,CAqNN;EAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAhJf,sFAIN,OAAO,cAAc,gCACpB,kBACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqIa,kFAIN,OAAO,cAAc,gCACpB"}
1
+ {"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;;;AAOA;AAcA;AAqEgB,UAnFC,eAAA,CAmFU;EAAA;;;;;;EAMpB,SAAA,QAAA,CAAA,EAAA,OAAA,GAlFyB,eAkFzB;AAqIP;;;;;AAKW,UArNM,eAAA,CAqNN;EAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAhJf,sFAIN,OAAO,cAAc,gCACpB,kBACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqIa,kFAIN,OAAO,cAAc,gCACpB"}
package/dist/mod.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { configureSync } from "@logtape/logtape";
2
2
 
3
- //#region mod.ts
3
+ //#region src/mod.ts
4
4
  /**
5
5
  * Creates a LogTape sink that forwards log records to a Pino logger.
6
6
  *
@@ -31,8 +31,8 @@ import { configureSync } from "@logtape/logtape";
31
31
  * });
32
32
  * ```
33
33
  *
34
- * @typeParam CustomLevels The custom log levels supported by the Pino logger.
35
- * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined
34
+ * @template CustomLevels The custom log levels supported by the Pino logger.
35
+ * @template UseOnlyCustomLevels Whether to use only custom levels defined
36
36
  * in the Pino logger.
37
37
  * @param logger The Pino logger instance to forward logs to.
38
38
  * @param options Configuration options for the sink adapter.
@@ -117,8 +117,8 @@ function getPinoSink(logger, options = {}) {
117
117
  * });
118
118
  * ```
119
119
  *
120
- * @typeParam CustomLevels The custom log levels supported by the Pino logger.
121
- * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined
120
+ * @template CustomLevels The custom log levels supported by the Pino logger.
121
+ * @template UseOnlyCustomLevels Whether to use only custom levels defined
122
122
  * in the Pino logger.
123
123
  * @param logger The Pino logger instance to forward logs to.
124
124
  * @param options Configuration options for the sink adapter.
package/dist/mod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","names":["logger: Logger<CustomLevels, UseOnlyCustomLevels>","options: PinoSinkOptions","category: Required<CategoryOptions> | undefined","record: LogRecord","interpolationValues: unknown[]"],"sources":["../mod.ts"],"sourcesContent":["import type { Logger } from \"pino\";\nimport { configureSync, type LogRecord, type Sink } from \"@logtape/logtape\";\n\n/**\n * Options for configuring the Pino sink adapter.\n * @since 1.0.0\n */\nexport interface PinoSinkOptions {\n /**\n * Configuration for how LogTape categories are handled in Pino logs.\n * - `false` or `undefined`: Categories are not included in the log message\n * - `true`: Categories are included with default formatting\n * - `CategoryOptions`: Custom category formatting configuration\n */\n readonly category?: boolean | CategoryOptions;\n}\n\n/**\n * Configuration options for formatting LogTape categories in Pino log messages.\n * @since 1.0.0\n */\nexport interface CategoryOptions {\n /**\n * The separator used to join category parts when multiple categories exist.\n * @default \"·\"\n */\n readonly separator?: string;\n\n /**\n * Where to position the category in the log message.\n * - `\"start\"`: Category appears at the beginning of the message\n * - `\"end\"`: Category appears at the end of the message\n * @default \"start\"\n */\n readonly position?: \"start\" | \"end\";\n\n /**\n * The decorator used to format the category in the log message.\n * - `\"[]\"`: [category] format\n * - `\"()\"`: (category) format\n * - `\"<>\"`: <category> format\n * - `\"{}\"`: {category} format\n * - `\":\"`: category: format\n * - `\"-\"`: category - format\n * - `\"|\"`: category | format\n * - `\"/\"`: category / format\n * - `\"\"`: category format (no decoration)\n * @default \":\"\n */\n readonly decorator?: \"[]\" | \"()\" | \"<>\" | \"{}\" | \":\" | \"-\" | \"|\" | \"/\" | \"\";\n}\n\n/**\n * Creates a LogTape sink that forwards log records to a Pino logger.\n *\n * This adapter allows LogTape-enabled libraries to integrate seamlessly with\n * applications that use Pino for logging.\n *\n * @example\n * ```typescript\n * import { configure } from \"@logtape/logtape\";\n * import { getPinoSink } from \"@logtape/adaptor-pino\";\n * import pino from \"pino\";\n *\n * const pinoLogger = pino();\n *\n * await configure({\n * sinks: {\n * pino: getPinoSink(pinoLogger, {\n * category: {\n * position: \"start\",\n * decorator: \"[]\",\n * separator: \".\"\n * }\n * })\n * },\n * loggers: [\n * { category: \"my-library\", sinks: [\"pino\"] }\n * ]\n * });\n * ```\n *\n * @typeParam CustomLevels The custom log levels supported by the Pino logger.\n * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined\n * in the Pino logger.\n * @param logger The Pino logger instance to forward logs to.\n * @param options Configuration options for the sink adapter.\n * @returns A LogTape sink function that can be used in LogTape configuration.\n * @since 1.0.0\n */\nexport function getPinoSink<\n CustomLevels extends string,\n UseOnlyCustomLevels extends boolean,\n>(\n logger: Logger<CustomLevels, UseOnlyCustomLevels>,\n options: PinoSinkOptions = {},\n): Sink {\n const categoryOptions = !options.category\n ? undefined\n : typeof options.category === \"object\"\n ? options.category\n : {};\n const category: Required<CategoryOptions> | undefined =\n categoryOptions == null ? undefined : {\n separator: categoryOptions.separator ?? \"·\",\n position: categoryOptions.position ?? \"start\",\n decorator: categoryOptions.decorator ?? \":\",\n };\n return (record: LogRecord) => {\n let message = \"\";\n const interpolationValues: unknown[] = [];\n if (category?.position === \"start\" && record.category.length > 0) {\n message += category.decorator === \"[]\"\n ? \"[%s] \"\n : category.decorator === \"()\"\n ? \"(%s) \"\n : category.decorator === \"<>\"\n ? \"<%s> \"\n : category.decorator === \"{}\"\n ? \"{%s} \"\n : category.decorator === \":\"\n ? \"%s: \"\n : category.decorator === \"-\"\n ? \"%s - \"\n : category.decorator === \"|\"\n ? \"%s | \"\n : category.decorator === \"/\"\n ? \"%s / \"\n : \"%s \";\n interpolationValues.push(\n record.category.join(category.separator),\n );\n }\n for (let i = 0; i < record.message.length; i += 2) {\n message += record.message[i];\n if (i + 1 < record.message.length) {\n message += \"%o\";\n interpolationValues.push(record.message[i + 1]);\n }\n }\n if (category?.position === \"end\" && record.category.length > 0) {\n message += category.decorator === \"[]\"\n ? \" [%s]\"\n : category.decorator === \"()\"\n ? \" (%s)\"\n : category.decorator === \"<>\"\n ? \" <%s>\"\n : category.decorator === \"{}\"\n ? \" {%s}\"\n : category.decorator === \":\"\n ? \": %s\"\n : category.decorator === \"-\"\n ? \" - %s\"\n : category.decorator === \"|\"\n ? \" | %s\"\n : category.decorator === \"/\"\n ? \" / %s\"\n : \" %s\";\n interpolationValues.push(\n record.category.join(category.separator),\n );\n }\n switch (record.level) {\n case \"trace\":\n return logger.trace(record.properties, message, interpolationValues);\n case \"debug\":\n return logger.debug(record.properties, message, interpolationValues);\n case \"info\":\n return logger.info(record.properties, message, interpolationValues);\n case \"warning\":\n return logger.warn(record.properties, message, interpolationValues);\n case \"error\":\n return logger.error(record.properties, message, interpolationValues);\n case \"fatal\":\n return logger.fatal(record.properties, message, interpolationValues);\n }\n };\n}\n\n/**\n * Automatically configures LogTape to route all logs to a Pino logger.\n *\n * This is a convenience function that automatically sets up LogTape to forward\n * all log records to a Pino logger instance.\n *\n * @example Basic auto-configuration\n * ```typescript\n * import pino from \"pino\";\n * import { install } from \"@logtape/adaptor-pino\";\n *\n * const pinoLogger = pino();\n *\n * // Automatically route all LogTape logs to the Pino logger\n * install(pinoLogger);\n *\n * // Now any LogTape-enabled library will log through Pino\n * import { getLogger } from \"@logtape/logtape\";\n * const logger = getLogger(\"my-app\");\n * logger.info(\"This will be logged through Pino\");\n * ```\n *\n * @example Auto-configuration with custom options\n * ```typescript\n * import pino from \"pino\";\n * import { install } from \"@logtape/adaptor-pino\";\n *\n * const pinoLogger = pino({\n * level: \"info\",\n * transport: {\n * target: \"pino-pretty\"\n * }\n * });\n *\n * install(pinoLogger, {\n * category: {\n * position: \"start\",\n * decorator: \"[]\",\n * separator: \".\"\n * }\n * });\n * ```\n *\n * @typeParam CustomLevels The custom log levels supported by the Pino logger.\n * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined\n * in the Pino logger.\n * @param logger The Pino logger instance to forward logs to.\n * @param options Configuration options for the sink adapter.\n * @since 1.0.0\n */\nexport function install<\n CustomLevels extends string,\n UseOnlyCustomLevels extends boolean,\n>(\n logger: Logger<CustomLevels, UseOnlyCustomLevels>,\n options: PinoSinkOptions = {},\n): void {\n configureSync({\n sinks: {\n pino: getPinoSink(logger, options),\n },\n loggers: [\n {\n category: [\"logtape\", \"meta\"],\n sinks: [\"pino\"],\n lowestLevel: \"warning\",\n },\n { category: [], sinks: [\"pino\"] },\n ],\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FA,SAAgB,YAIdA,QACAC,UAA2B,CAAE,GACvB;CACN,MAAM,mBAAmB,QAAQ,2BAEtB,QAAQ,aAAa,WAC5B,QAAQ,WACR,CAAE;CACN,MAAMC,WACJ,mBAAmB,gBAAmB;EACpC,WAAW,gBAAgB,aAAa;EACxC,UAAU,gBAAgB,YAAY;EACtC,WAAW,gBAAgB,aAAa;CACzC;AACH,QAAO,CAACC,WAAsB;EAC5B,IAAI,UAAU;EACd,MAAMC,sBAAiC,CAAE;AACzC,MAAI,UAAU,aAAa,WAAW,OAAO,SAAS,SAAS,GAAG;AAChE,cAAW,SAAS,cAAc,OAC9B,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,MACvB,SACA,SAAS,cAAc,MACvB,UACA,SAAS,cAAc,MACvB,UACA,SAAS,cAAc,MACvB,UACA;AACJ,uBAAoB,KAClB,OAAO,SAAS,KAAK,SAAS,UAAU,CACzC;EACF;AACD,OAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,QAAQ,KAAK,GAAG;AACjD,cAAW,OAAO,QAAQ;AAC1B,OAAI,IAAI,IAAI,OAAO,QAAQ,QAAQ;AACjC,eAAW;AACX,wBAAoB,KAAK,OAAO,QAAQ,IAAI,GAAG;GAChD;EACF;AACD,MAAI,UAAU,aAAa,SAAS,OAAO,SAAS,SAAS,GAAG;AAC9D,cAAW,SAAS,cAAc,OAC9B,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,MACvB,SACA,SAAS,cAAc,MACvB,UACA,SAAS,cAAc,MACvB,UACA,SAAS,cAAc,MACvB,UACA;AACJ,uBAAoB,KAClB,OAAO,SAAS,KAAK,SAAS,UAAU,CACzC;EACF;AACD,UAAQ,OAAO,OAAf;GACE,KAAK,QACH,QAAO,OAAO,MAAM,OAAO,YAAY,SAAS,oBAAoB;GACtE,KAAK,QACH,QAAO,OAAO,MAAM,OAAO,YAAY,SAAS,oBAAoB;GACtE,KAAK,OACH,QAAO,OAAO,KAAK,OAAO,YAAY,SAAS,oBAAoB;GACrE,KAAK,UACH,QAAO,OAAO,KAAK,OAAO,YAAY,SAAS,oBAAoB;GACrE,KAAK,QACH,QAAO,OAAO,MAAM,OAAO,YAAY,SAAS,oBAAoB;GACtE,KAAK,QACH,QAAO,OAAO,MAAM,OAAO,YAAY,SAAS,oBAAoB;EACvE;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDD,SAAgB,QAIdJ,QACAC,UAA2B,CAAE,GACvB;AACN,eAAc;EACZ,OAAO,EACL,MAAM,YAAY,QAAQ,QAAQ,CACnC;EACD,SAAS,CACP;GACE,UAAU,CAAC,WAAW,MAAO;GAC7B,OAAO,CAAC,MAAO;GACf,aAAa;EACd,GACD;GAAE,UAAU,CAAE;GAAE,OAAO,CAAC,MAAO;EAAE,CAClC;CACF,EAAC;AACH"}
1
+ {"version":3,"file":"mod.js","names":["logger: Logger<CustomLevels, UseOnlyCustomLevels>","options: PinoSinkOptions","category: Required<CategoryOptions> | undefined","record: LogRecord","interpolationValues: unknown[]"],"sources":["../src/mod.ts"],"sourcesContent":["import type { Logger } from \"pino\";\nimport { configureSync, type LogRecord, type Sink } from \"@logtape/logtape\";\n\n/**\n * Options for configuring the Pino sink adapter.\n * @since 1.0.0\n */\nexport interface PinoSinkOptions {\n /**\n * Configuration for how LogTape categories are handled in Pino logs.\n * - `false` or `undefined`: Categories are not included in the log message\n * - `true`: Categories are included with default formatting\n * - `CategoryOptions`: Custom category formatting configuration\n */\n readonly category?: boolean | CategoryOptions;\n}\n\n/**\n * Configuration options for formatting LogTape categories in Pino log messages.\n * @since 1.0.0\n */\nexport interface CategoryOptions {\n /**\n * The separator used to join category parts when multiple categories exist.\n * @default \"·\"\n */\n readonly separator?: string;\n\n /**\n * Where to position the category in the log message.\n * - `\"start\"`: Category appears at the beginning of the message\n * - `\"end\"`: Category appears at the end of the message\n * @default \"start\"\n */\n readonly position?: \"start\" | \"end\";\n\n /**\n * The decorator used to format the category in the log message.\n * - `\"[]\"`: [category] format\n * - `\"()\"`: (category) format\n * - `\"<>\"`: <category> format\n * - `\"{}\"`: {category} format\n * - `\":\"`: category: format\n * - `\"-\"`: category - format\n * - `\"|\"`: category | format\n * - `\"/\"`: category / format\n * - `\"\"`: category format (no decoration)\n * @default \":\"\n */\n readonly decorator?: \"[]\" | \"()\" | \"<>\" | \"{}\" | \":\" | \"-\" | \"|\" | \"/\" | \"\";\n}\n\n/**\n * Creates a LogTape sink that forwards log records to a Pino logger.\n *\n * This adapter allows LogTape-enabled libraries to integrate seamlessly with\n * applications that use Pino for logging.\n *\n * @example\n * ```typescript\n * import { configure } from \"@logtape/logtape\";\n * import { getPinoSink } from \"@logtape/adaptor-pino\";\n * import pino from \"pino\";\n *\n * const pinoLogger = pino();\n *\n * await configure({\n * sinks: {\n * pino: getPinoSink(pinoLogger, {\n * category: {\n * position: \"start\",\n * decorator: \"[]\",\n * separator: \".\"\n * }\n * })\n * },\n * loggers: [\n * { category: \"my-library\", sinks: [\"pino\"] }\n * ]\n * });\n * ```\n *\n * @template CustomLevels The custom log levels supported by the Pino logger.\n * @template UseOnlyCustomLevels Whether to use only custom levels defined\n * in the Pino logger.\n * @param logger The Pino logger instance to forward logs to.\n * @param options Configuration options for the sink adapter.\n * @returns A LogTape sink function that can be used in LogTape configuration.\n * @since 1.0.0\n */\nexport function getPinoSink<\n CustomLevels extends string,\n UseOnlyCustomLevels extends boolean,\n>(\n logger: Logger<CustomLevels, UseOnlyCustomLevels>,\n options: PinoSinkOptions = {},\n): Sink {\n const categoryOptions = !options.category\n ? undefined\n : typeof options.category === \"object\"\n ? options.category\n : {};\n const category: Required<CategoryOptions> | undefined =\n categoryOptions == null ? undefined : {\n separator: categoryOptions.separator ?? \"·\",\n position: categoryOptions.position ?? \"start\",\n decorator: categoryOptions.decorator ?? \":\",\n };\n return (record: LogRecord) => {\n let message = \"\";\n const interpolationValues: unknown[] = [];\n if (category?.position === \"start\" && record.category.length > 0) {\n message += category.decorator === \"[]\"\n ? \"[%s] \"\n : category.decorator === \"()\"\n ? \"(%s) \"\n : category.decorator === \"<>\"\n ? \"<%s> \"\n : category.decorator === \"{}\"\n ? \"{%s} \"\n : category.decorator === \":\"\n ? \"%s: \"\n : category.decorator === \"-\"\n ? \"%s - \"\n : category.decorator === \"|\"\n ? \"%s | \"\n : category.decorator === \"/\"\n ? \"%s / \"\n : \"%s \";\n interpolationValues.push(\n record.category.join(category.separator),\n );\n }\n for (let i = 0; i < record.message.length; i += 2) {\n message += record.message[i];\n if (i + 1 < record.message.length) {\n message += \"%o\";\n interpolationValues.push(record.message[i + 1]);\n }\n }\n if (category?.position === \"end\" && record.category.length > 0) {\n message += category.decorator === \"[]\"\n ? \" [%s]\"\n : category.decorator === \"()\"\n ? \" (%s)\"\n : category.decorator === \"<>\"\n ? \" <%s>\"\n : category.decorator === \"{}\"\n ? \" {%s}\"\n : category.decorator === \":\"\n ? \": %s\"\n : category.decorator === \"-\"\n ? \" - %s\"\n : category.decorator === \"|\"\n ? \" | %s\"\n : category.decorator === \"/\"\n ? \" / %s\"\n : \" %s\";\n interpolationValues.push(\n record.category.join(category.separator),\n );\n }\n switch (record.level) {\n case \"trace\":\n return logger.trace(record.properties, message, interpolationValues);\n case \"debug\":\n return logger.debug(record.properties, message, interpolationValues);\n case \"info\":\n return logger.info(record.properties, message, interpolationValues);\n case \"warning\":\n return logger.warn(record.properties, message, interpolationValues);\n case \"error\":\n return logger.error(record.properties, message, interpolationValues);\n case \"fatal\":\n return logger.fatal(record.properties, message, interpolationValues);\n }\n };\n}\n\n/**\n * Automatically configures LogTape to route all logs to a Pino logger.\n *\n * This is a convenience function that automatically sets up LogTape to forward\n * all log records to a Pino logger instance.\n *\n * @example Basic auto-configuration\n * ```typescript\n * import pino from \"pino\";\n * import { install } from \"@logtape/adaptor-pino\";\n *\n * const pinoLogger = pino();\n *\n * // Automatically route all LogTape logs to the Pino logger\n * install(pinoLogger);\n *\n * // Now any LogTape-enabled library will log through Pino\n * import { getLogger } from \"@logtape/logtape\";\n * const logger = getLogger(\"my-app\");\n * logger.info(\"This will be logged through Pino\");\n * ```\n *\n * @example Auto-configuration with custom options\n * ```typescript\n * import pino from \"pino\";\n * import { install } from \"@logtape/adaptor-pino\";\n *\n * const pinoLogger = pino({\n * level: \"info\",\n * transport: {\n * target: \"pino-pretty\"\n * }\n * });\n *\n * install(pinoLogger, {\n * category: {\n * position: \"start\",\n * decorator: \"[]\",\n * separator: \".\"\n * }\n * });\n * ```\n *\n * @template CustomLevels The custom log levels supported by the Pino logger.\n * @template UseOnlyCustomLevels Whether to use only custom levels defined\n * in the Pino logger.\n * @param logger The Pino logger instance to forward logs to.\n * @param options Configuration options for the sink adapter.\n * @since 1.0.0\n */\nexport function install<\n CustomLevels extends string,\n UseOnlyCustomLevels extends boolean,\n>(\n logger: Logger<CustomLevels, UseOnlyCustomLevels>,\n options: PinoSinkOptions = {},\n): void {\n configureSync({\n sinks: {\n pino: getPinoSink(logger, options),\n },\n loggers: [\n {\n category: [\"logtape\", \"meta\"],\n sinks: [\"pino\"],\n lowestLevel: \"warning\",\n },\n { category: [], sinks: [\"pino\"] },\n ],\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FA,SAAgB,YAIdA,QACAC,UAA2B,CAAE,GACvB;CACN,MAAM,mBAAmB,QAAQ,2BAEtB,QAAQ,aAAa,WAC5B,QAAQ,WACR,CAAE;CACN,MAAMC,WACJ,mBAAmB,gBAAmB;EACpC,WAAW,gBAAgB,aAAa;EACxC,UAAU,gBAAgB,YAAY;EACtC,WAAW,gBAAgB,aAAa;CACzC;AACH,QAAO,CAACC,WAAsB;EAC5B,IAAI,UAAU;EACd,MAAMC,sBAAiC,CAAE;AACzC,MAAI,UAAU,aAAa,WAAW,OAAO,SAAS,SAAS,GAAG;AAChE,cAAW,SAAS,cAAc,OAC9B,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,MACvB,SACA,SAAS,cAAc,MACvB,UACA,SAAS,cAAc,MACvB,UACA,SAAS,cAAc,MACvB,UACA;AACJ,uBAAoB,KAClB,OAAO,SAAS,KAAK,SAAS,UAAU,CACzC;EACF;AACD,OAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,QAAQ,KAAK,GAAG;AACjD,cAAW,OAAO,QAAQ;AAC1B,OAAI,IAAI,IAAI,OAAO,QAAQ,QAAQ;AACjC,eAAW;AACX,wBAAoB,KAAK,OAAO,QAAQ,IAAI,GAAG;GAChD;EACF;AACD,MAAI,UAAU,aAAa,SAAS,OAAO,SAAS,SAAS,GAAG;AAC9D,cAAW,SAAS,cAAc,OAC9B,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,OACvB,UACA,SAAS,cAAc,MACvB,SACA,SAAS,cAAc,MACvB,UACA,SAAS,cAAc,MACvB,UACA,SAAS,cAAc,MACvB,UACA;AACJ,uBAAoB,KAClB,OAAO,SAAS,KAAK,SAAS,UAAU,CACzC;EACF;AACD,UAAQ,OAAO,OAAf;GACE,KAAK,QACH,QAAO,OAAO,MAAM,OAAO,YAAY,SAAS,oBAAoB;GACtE,KAAK,QACH,QAAO,OAAO,MAAM,OAAO,YAAY,SAAS,oBAAoB;GACtE,KAAK,OACH,QAAO,OAAO,KAAK,OAAO,YAAY,SAAS,oBAAoB;GACrE,KAAK,UACH,QAAO,OAAO,KAAK,OAAO,YAAY,SAAS,oBAAoB;GACrE,KAAK,QACH,QAAO,OAAO,MAAM,OAAO,YAAY,SAAS,oBAAoB;GACtE,KAAK,QACH,QAAO,OAAO,MAAM,OAAO,YAAY,SAAS,oBAAoB;EACvE;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDD,SAAgB,QAIdJ,QACAC,UAA2B,CAAE,GACvB;AACN,eAAc;EACZ,OAAO,EACL,MAAM,YAAY,QAAQ,QAAQ,CACnC;EACD,SAAS,CACP;GACE,UAAU,CAAC,WAAW,MAAO;GAC7B,OAAO,CAAC,MAAO;GACf,aAAa;EACd,GACD;GAAE,UAAU,CAAE;GAAE,OAAO,CAAC,MAAO;EAAE,CAClC;CACF,EAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logtape/adaptor-pino",
3
- "version": "1.1.0-dev.315+fc46f65c",
3
+ "version": "1.1.0-dev.323+146f8194",
4
4
  "description": "Pino adapter for LogTape logging library",
5
5
  "keywords": [
6
6
  "logging",
@@ -21,7 +21,7 @@
21
21
  "repository": {
22
22
  "type": "git",
23
23
  "url": "git+https://github.com/dahlia/logtape.git",
24
- "directory": "adaptor-pino/"
24
+ "directory": "packages/adaptor-pino/"
25
25
  },
26
26
  "bugs": {
27
27
  "url": "https://github.com/dahlia/logtape/issues"
@@ -47,7 +47,7 @@
47
47
  "sideEffects": false,
48
48
  "peerDependencies": {
49
49
  "pino": "^9.7.0",
50
- "@logtape/logtape": "1.1.0-dev.315+fc46f65c"
50
+ "@logtape/logtape": "1.1.0-dev.323+146f8194"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@alinea/suite": "^0.6.3",
@@ -80,8 +80,8 @@ export interface CategoryOptions {
80
80
  * });
81
81
  * ```
82
82
  *
83
- * @typeParam CustomLevels The custom log levels supported by the Pino logger.
84
- * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined
83
+ * @template CustomLevels The custom log levels supported by the Pino logger.
84
+ * @template UseOnlyCustomLevels Whether to use only custom levels defined
85
85
  * in the Pino logger.
86
86
  * @param logger The Pino logger instance to forward logs to.
87
87
  * @param options Configuration options for the sink adapter.
@@ -220,8 +220,8 @@ export function getPinoSink<
220
220
  * });
221
221
  * ```
222
222
  *
223
- * @typeParam CustomLevels The custom log levels supported by the Pino logger.
224
- * @typeParam UseOnlyCustomLevels Whether to use only custom levels defined
223
+ * @template CustomLevels The custom log levels supported by the Pino logger.
224
+ * @template UseOnlyCustomLevels Whether to use only custom levels defined
225
225
  * in the Pino logger.
226
226
  * @param logger The Pino logger instance to forward logs to.
227
227
  * @param options Configuration options for the sink adapter.
package/tsdown.config.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineConfig } from "tsdown";
2
2
 
3
3
  export default defineConfig({
4
- entry: "mod.ts",
4
+ entry: "src/mod.ts",
5
5
  dts: {
6
6
  sourcemap: true,
7
7
  },
File without changes