@venizia/ignis-helpers 0.4.6 → 0.4.7-1

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.
Files changed (300) hide show
  1. package/LICENSE.md +1 -3
  2. package/README.md +4 -5
  3. package/dist/esm/common/redact.d.ts +25 -17
  4. package/dist/esm/common/redact.d.ts.map +1 -1
  5. package/dist/esm/common/redact.js +50 -46
  6. package/dist/esm/common/redact.js.map +1 -1
  7. package/dist/esm/common/resolvers.d.ts +7 -5
  8. package/dist/esm/common/resolvers.d.ts.map +1 -1
  9. package/dist/esm/common/resolvers.js +11 -9
  10. package/dist/esm/common/resolvers.js.map +1 -1
  11. package/dist/esm/core.d.ts +6 -3
  12. package/dist/esm/core.d.ts.map +1 -1
  13. package/dist/esm/core.js +6 -3
  14. package/dist/esm/core.js.map +1 -1
  15. package/dist/esm/modules/base.js +4 -4
  16. package/dist/esm/modules/base.js.map +1 -1
  17. package/dist/esm/modules/cron/helper.js +4 -4
  18. package/dist/esm/modules/cron/helper.js.map +1 -1
  19. package/dist/esm/modules/crypto/algorithms/aes-legacy.algorithm.js +3 -3
  20. package/dist/esm/modules/crypto/algorithms/aes-legacy.algorithm.js.map +1 -1
  21. package/dist/esm/modules/crypto/algorithms/aes.algorithm.js +5 -5
  22. package/dist/esm/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
  23. package/dist/esm/modules/crypto/algorithms/base.algorithm.js +3 -3
  24. package/dist/esm/modules/crypto/algorithms/base.algorithm.js.map +1 -1
  25. package/dist/esm/modules/env/app-env.d.ts.map +1 -1
  26. package/dist/esm/modules/env/app-env.js +2 -2
  27. package/dist/esm/modules/env/app-env.js.map +1 -1
  28. package/dist/esm/modules/logger/common/constants.d.ts +23 -21
  29. package/dist/esm/modules/logger/common/constants.d.ts.map +1 -1
  30. package/dist/esm/modules/logger/common/constants.js +45 -42
  31. package/dist/esm/modules/logger/common/constants.js.map +1 -1
  32. package/dist/esm/modules/logger/factory.d.ts +5 -3
  33. package/dist/esm/modules/logger/factory.d.ts.map +1 -1
  34. package/dist/esm/modules/logger/factory.js +5 -3
  35. package/dist/esm/modules/logger/factory.js.map +1 -1
  36. package/dist/esm/modules/logger/formatting/deep-splat.d.ts +10 -6
  37. package/dist/esm/modules/logger/formatting/deep-splat.d.ts.map +1 -1
  38. package/dist/esm/modules/logger/formatting/deep-splat.js +73 -62
  39. package/dist/esm/modules/logger/formatting/deep-splat.js.map +1 -1
  40. package/dist/esm/modules/logger/formatting/error-prettier.d.ts.map +1 -1
  41. package/dist/esm/modules/logger/formatting/error-prettier.js +8 -6
  42. package/dist/esm/modules/logger/formatting/error-prettier.js.map +1 -1
  43. package/dist/esm/modules/logger/hf/logger.d.ts.map +1 -1
  44. package/dist/esm/modules/logger/hf/logger.js +2 -2
  45. package/dist/esm/modules/logger/hf/logger.js.map +1 -1
  46. package/dist/esm/modules/logger/pino/backing.d.ts +0 -9
  47. package/dist/esm/modules/logger/pino/backing.d.ts.map +1 -1
  48. package/dist/esm/modules/logger/pino/backing.js +3 -8
  49. package/dist/esm/modules/logger/pino/backing.js.map +1 -1
  50. package/dist/esm/modules/logger/pino/destination.d.ts +6 -9
  51. package/dist/esm/modules/logger/pino/destination.d.ts.map +1 -1
  52. package/dist/esm/modules/logger/pino/destination.js +12 -13
  53. package/dist/esm/modules/logger/pino/destination.js.map +1 -1
  54. package/dist/esm/modules/logger/pino/logger.js +2 -2
  55. package/dist/esm/modules/logger/pino/logger.js.map +1 -1
  56. package/dist/esm/modules/logger/resolver.js +2 -2
  57. package/dist/esm/modules/logger/resolver.js.map +1 -1
  58. package/dist/esm/modules/logger/slot.d.ts +39 -18
  59. package/dist/esm/modules/logger/slot.d.ts.map +1 -1
  60. package/dist/esm/modules/logger/slot.js +117 -110
  61. package/dist/esm/modules/logger/slot.js.map +1 -1
  62. package/dist/esm/modules/logger/winston/common/constants.d.ts.map +1 -1
  63. package/dist/esm/modules/logger/winston/common/constants.js +7 -6
  64. package/dist/esm/modules/logger/winston/common/constants.js.map +1 -1
  65. package/dist/esm/modules/logger/winston/define.d.ts +0 -7
  66. package/dist/esm/modules/logger/winston/define.d.ts.map +1 -1
  67. package/dist/esm/modules/logger/winston/define.js +0 -5
  68. package/dist/esm/modules/logger/winston/define.js.map +1 -1
  69. package/dist/esm/modules/logger/winston/formats.d.ts +2 -0
  70. package/dist/esm/modules/logger/winston/formats.d.ts.map +1 -1
  71. package/dist/esm/modules/logger/winston/formats.js +17 -4
  72. package/dist/esm/modules/logger/winston/formats.js.map +1 -1
  73. package/dist/esm/modules/logger/winston/index.d.ts +3 -2
  74. package/dist/esm/modules/logger/winston/index.d.ts.map +1 -1
  75. package/dist/esm/modules/logger/winston/index.js +3 -2
  76. package/dist/esm/modules/logger/winston/index.js.map +1 -1
  77. package/dist/esm/modules/logger/winston/logger-factory.js +4 -4
  78. package/dist/esm/modules/logger/winston/logger-factory.js.map +1 -1
  79. package/dist/esm/modules/network/http-request/base-network-request.helper.js +2 -2
  80. package/dist/esm/modules/network/http-request/base-network-request.helper.js.map +1 -1
  81. package/dist/esm/modules/network/http-request/common/index.d.ts +0 -1
  82. package/dist/esm/modules/network/http-request/common/index.d.ts.map +1 -1
  83. package/dist/esm/modules/network/http-request/common/index.js +0 -1
  84. package/dist/esm/modules/network/http-request/common/index.js.map +1 -1
  85. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts.map +1 -1
  86. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js +4 -2
  87. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js.map +1 -1
  88. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts.map +1 -1
  89. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js +6 -4
  90. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js.map +1 -1
  91. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js +4 -4
  92. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js.map +1 -1
  93. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js +4 -4
  94. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
  95. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js +2 -2
  96. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js.map +1 -1
  97. package/dist/esm/modules/network/utilities/query-string.d.ts +22 -20
  98. package/dist/esm/modules/network/utilities/query-string.d.ts.map +1 -1
  99. package/dist/esm/modules/network/utilities/query-string.js +48 -46
  100. package/dist/esm/modules/network/utilities/query-string.js.map +1 -1
  101. package/dist/esm/modules/network/utilities/url-safety/common/errors.d.ts +0 -10
  102. package/dist/esm/modules/network/utilities/url-safety/common/errors.d.ts.map +1 -1
  103. package/dist/esm/modules/network/utilities/url-safety/common/errors.js +0 -11
  104. package/dist/esm/modules/network/utilities/url-safety/common/errors.js.map +1 -1
  105. package/dist/esm/modules/network/utilities/url-safety/ingest.d.ts.map +1 -1
  106. package/dist/esm/modules/network/utilities/url-safety/ingest.js +2 -1
  107. package/dist/esm/modules/network/utilities/url-safety/ingest.js.map +1 -1
  108. package/dist/esm/modules/network/utilities/url-safety/policy.d.ts +10 -0
  109. package/dist/esm/modules/network/utilities/url-safety/policy.d.ts.map +1 -1
  110. package/dist/esm/modules/network/utilities/url-safety/policy.js +11 -0
  111. package/dist/esm/modules/network/utilities/url-safety/policy.js.map +1 -1
  112. package/dist/esm/modules/pool/abstract.d.ts.map +1 -1
  113. package/dist/esm/modules/pool/abstract.js +4 -2
  114. package/dist/esm/modules/pool/abstract.js.map +1 -1
  115. package/dist/esm/modules/queue/bullmq/helper.d.ts.map +1 -1
  116. package/dist/esm/modules/queue/bullmq/helper.js +6 -6
  117. package/dist/esm/modules/queue/bullmq/helper.js.map +1 -1
  118. package/dist/esm/modules/queue/common/hook.d.ts +14 -12
  119. package/dist/esm/modules/queue/common/hook.d.ts.map +1 -1
  120. package/dist/esm/modules/queue/common/hook.js +21 -19
  121. package/dist/esm/modules/queue/common/hook.js.map +1 -1
  122. package/dist/esm/modules/queue/common/index.d.ts +0 -1
  123. package/dist/esm/modules/queue/common/index.d.ts.map +1 -1
  124. package/dist/esm/modules/queue/common/index.js +0 -1
  125. package/dist/esm/modules/queue/common/index.js.map +1 -1
  126. package/dist/esm/modules/queue/internal/sequential/helper.js +8 -8
  127. package/dist/esm/modules/queue/internal/sequential/helper.js.map +1 -1
  128. package/dist/esm/modules/queue/kafka/base.js +3 -3
  129. package/dist/esm/modules/queue/kafka/base.js.map +1 -1
  130. package/dist/esm/modules/queue/kafka/bundler/index.d.ts +0 -2
  131. package/dist/esm/modules/queue/kafka/bundler/index.d.ts.map +1 -1
  132. package/dist/esm/modules/queue/kafka/bundler/index.js +0 -2
  133. package/dist/esm/modules/queue/kafka/bundler/index.js.map +1 -1
  134. package/dist/esm/modules/queue/kafka/bundler/plugins.d.ts +8 -2
  135. package/dist/esm/modules/queue/kafka/bundler/plugins.d.ts.map +1 -1
  136. package/dist/esm/modules/queue/kafka/bundler/plugins.js +64 -7
  137. package/dist/esm/modules/queue/kafka/bundler/plugins.js.map +1 -1
  138. package/dist/esm/modules/queue/kafka/consumer.d.ts.map +1 -1
  139. package/dist/esm/modules/queue/kafka/consumer.js +26 -24
  140. package/dist/esm/modules/queue/kafka/consumer.js.map +1 -1
  141. package/dist/esm/modules/queue/mqtt/helper.js +10 -10
  142. package/dist/esm/modules/queue/mqtt/helper.js.map +1 -1
  143. package/dist/esm/modules/redis/base/abstract.helper.js +8 -8
  144. package/dist/esm/modules/redis/base/abstract.helper.js.map +1 -1
  145. package/dist/esm/modules/redis/cluster/cluster.helper.js +2 -2
  146. package/dist/esm/modules/redis/cluster/cluster.helper.js.map +1 -1
  147. package/dist/esm/modules/redis/factory.d.ts +13 -9
  148. package/dist/esm/modules/redis/factory.d.ts.map +1 -1
  149. package/dist/esm/modules/redis/factory.js +15 -13
  150. package/dist/esm/modules/redis/factory.js.map +1 -1
  151. package/dist/esm/modules/redis/sentinel/sentinel.helper.js +2 -2
  152. package/dist/esm/modules/redis/sentinel/sentinel.helper.js.map +1 -1
  153. package/dist/esm/modules/redis/single/single.helper.js +2 -2
  154. package/dist/esm/modules/redis/single/single.helper.js.map +1 -1
  155. package/dist/esm/modules/redis/utility.d.ts +13 -11
  156. package/dist/esm/modules/redis/utility.d.ts.map +1 -1
  157. package/dist/esm/modules/redis/utility.js +46 -44
  158. package/dist/esm/modules/redis/utility.js.map +1 -1
  159. package/dist/esm/modules/retry/helper.d.ts.map +1 -1
  160. package/dist/esm/modules/retry/helper.js +6 -4
  161. package/dist/esm/modules/retry/helper.js.map +1 -1
  162. package/dist/esm/modules/secrets/factory.d.ts +5 -3
  163. package/dist/esm/modules/secrets/factory.d.ts.map +1 -1
  164. package/dist/esm/modules/secrets/factory.js +36 -34
  165. package/dist/esm/modules/secrets/factory.js.map +1 -1
  166. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.d.ts.map +1 -1
  167. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js +4 -2
  168. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js.map +1 -1
  169. package/dist/esm/modules/socket/socket-io/server/helper.d.ts.map +1 -1
  170. package/dist/esm/modules/socket/socket-io/server/helper.js +11 -11
  171. package/dist/esm/modules/socket/socket-io/server/helper.js.map +1 -1
  172. package/dist/esm/modules/socket/websocket/emitter/helper.d.ts.map +1 -1
  173. package/dist/esm/modules/socket/websocket/emitter/helper.js +3 -3
  174. package/dist/esm/modules/socket/websocket/emitter/helper.js.map +1 -1
  175. package/dist/esm/modules/socket/websocket/server/delivery.d.ts.map +1 -1
  176. package/dist/esm/modules/socket/websocket/server/delivery.js +5 -6
  177. package/dist/esm/modules/socket/websocket/server/delivery.js.map +1 -1
  178. package/dist/esm/modules/socket/websocket/server/helper.d.ts.map +1 -1
  179. package/dist/esm/modules/socket/websocket/server/helper.js +7 -7
  180. package/dist/esm/modules/socket/websocket/server/helper.js.map +1 -1
  181. package/dist/esm/modules/storage/base.d.ts.map +1 -1
  182. package/dist/esm/modules/storage/base.js +9 -8
  183. package/dist/esm/modules/storage/base.js.map +1 -1
  184. package/dist/esm/modules/storage/bun-s3/helper.d.ts.map +1 -1
  185. package/dist/esm/modules/storage/bun-s3/helper.js +25 -18
  186. package/dist/esm/modules/storage/bun-s3/helper.js.map +1 -1
  187. package/dist/esm/modules/storage/bun-s3/utility.d.ts +95 -77
  188. package/dist/esm/modules/storage/bun-s3/utility.d.ts.map +1 -1
  189. package/dist/esm/modules/storage/bun-s3/utility.js +261 -244
  190. package/dist/esm/modules/storage/bun-s3/utility.js.map +1 -1
  191. package/dist/esm/modules/storage/common/errors.d.ts +0 -4
  192. package/dist/esm/modules/storage/common/errors.d.ts.map +1 -1
  193. package/dist/esm/modules/storage/common/errors.js +0 -10
  194. package/dist/esm/modules/storage/common/errors.js.map +1 -1
  195. package/dist/esm/modules/storage/common/utility.d.ts +11 -5
  196. package/dist/esm/modules/storage/common/utility.d.ts.map +1 -1
  197. package/dist/esm/modules/storage/common/utility.js +30 -17
  198. package/dist/esm/modules/storage/common/utility.js.map +1 -1
  199. package/dist/esm/modules/storage/disk/helper.d.ts.map +1 -1
  200. package/dist/esm/modules/storage/disk/helper.js +18 -9
  201. package/dist/esm/modules/storage/disk/helper.js.map +1 -1
  202. package/dist/esm/modules/tree/builder.d.ts.map +1 -1
  203. package/dist/esm/modules/tree/builder.js +2 -1
  204. package/dist/esm/modules/tree/builder.js.map +1 -1
  205. package/dist/esm/modules/uid/opaque.d.ts.map +1 -1
  206. package/dist/esm/modules/uid/opaque.js +4 -2
  207. package/dist/esm/modules/uid/opaque.js.map +1 -1
  208. package/dist/esm/modules/uid/uuid/helper.d.ts +1 -1
  209. package/dist/esm/modules/uid/uuid/helper.d.ts.map +1 -1
  210. package/dist/esm/modules/uid/uuid/helper.js +7 -7
  211. package/dist/esm/modules/uid/uuid/helper.js.map +1 -1
  212. package/dist/esm/modules/uid/uuid/v4.d.ts +11 -8
  213. package/dist/esm/modules/uid/uuid/v4.d.ts.map +1 -1
  214. package/dist/esm/modules/uid/uuid/v4.js +51 -46
  215. package/dist/esm/modules/uid/uuid/v4.js.map +1 -1
  216. package/dist/esm/modules/uid/uuid/v5.d.ts +17 -14
  217. package/dist/esm/modules/uid/uuid/v5.d.ts.map +1 -1
  218. package/dist/esm/modules/uid/uuid/v5.js +83 -78
  219. package/dist/esm/modules/uid/uuid/v5.js.map +1 -1
  220. package/dist/esm/modules/uid/uuid/v7.d.ts +15 -10
  221. package/dist/esm/modules/uid/uuid/v7.d.ts.map +1 -1
  222. package/dist/esm/modules/uid/uuid/v7.js +88 -79
  223. package/dist/esm/modules/uid/uuid/v7.js.map +1 -1
  224. package/dist/esm/modules/worker-thread/bus/base.js +2 -2
  225. package/dist/esm/modules/worker-thread/bus/base.js.map +1 -1
  226. package/dist/esm/modules/worker-thread/worker/base.d.ts.map +1 -1
  227. package/dist/esm/modules/worker-thread/worker/base.js +4 -3
  228. package/dist/esm/modules/worker-thread/worker/base.js.map +1 -1
  229. package/dist/esm/utilities/error.utility.d.ts +7 -0
  230. package/dist/esm/utilities/error.utility.d.ts.map +1 -0
  231. package/dist/esm/utilities/error.utility.js +9 -0
  232. package/dist/esm/utilities/error.utility.js.map +1 -0
  233. package/dist/esm/utilities/form-body.utility.d.ts +12 -10
  234. package/dist/esm/utilities/form-body.utility.d.ts.map +1 -1
  235. package/dist/esm/utilities/form-body.utility.js +19 -16
  236. package/dist/esm/utilities/form-body.utility.js.map +1 -1
  237. package/dist/esm/utilities/hr-time.utility.d.ts +7 -5
  238. package/dist/esm/utilities/hr-time.utility.d.ts.map +1 -1
  239. package/dist/esm/utilities/hr-time.utility.js +11 -9
  240. package/dist/esm/utilities/hr-time.utility.js.map +1 -1
  241. package/dist/esm/utilities/index.d.ts +2 -2
  242. package/dist/esm/utilities/index.d.ts.map +1 -1
  243. package/dist/esm/utilities/index.js +2 -2
  244. package/dist/esm/utilities/index.js.map +1 -1
  245. package/dist/esm/utilities/module.utility.d.ts.map +1 -1
  246. package/dist/esm/utilities/module.utility.js +4 -2
  247. package/dist/esm/utilities/module.utility.js.map +1 -1
  248. package/dist/esm/utilities/parse.utility.d.ts +89 -43
  249. package/dist/esm/utilities/parse.utility.d.ts.map +1 -1
  250. package/dist/esm/utilities/parse.utility.js +173 -141
  251. package/dist/esm/utilities/parse.utility.js.map +1 -1
  252. package/dist/esm/utilities/performance.utility.d.ts +15 -13
  253. package/dist/esm/utilities/performance.utility.d.ts.map +1 -1
  254. package/dist/esm/utilities/performance.utility.js +34 -29
  255. package/dist/esm/utilities/performance.utility.js.map +1 -1
  256. package/dist/esm/utilities/promise.utility.d.ts +20 -18
  257. package/dist/esm/utilities/promise.utility.d.ts.map +1 -1
  258. package/dist/esm/utilities/promise.utility.js +41 -51
  259. package/dist/esm/utilities/promise.utility.js.map +1 -1
  260. package/dist/esm/utilities/request.utility.d.ts +35 -29
  261. package/dist/esm/utilities/request.utility.d.ts.map +1 -1
  262. package/dist/esm/utilities/request.utility.js +117 -115
  263. package/dist/esm/utilities/request.utility.js.map +1 -1
  264. package/package.json +4 -15
  265. package/dist/esm/modules/logger/winston/formatters/deep-splat.d.ts +0 -4
  266. package/dist/esm/modules/logger/winston/formatters/deep-splat.d.ts.map +0 -1
  267. package/dist/esm/modules/logger/winston/formatters/deep-splat.js +0 -14
  268. package/dist/esm/modules/logger/winston/formatters/deep-splat.js.map +0 -1
  269. package/dist/esm/modules/logger/winston/formatters/index.d.ts +0 -2
  270. package/dist/esm/modules/logger/winston/formatters/index.d.ts.map +0 -1
  271. package/dist/esm/modules/logger/winston/formatters/index.js +0 -2
  272. package/dist/esm/modules/logger/winston/formatters/index.js.map +0 -1
  273. package/dist/esm/modules/network/http-request/common/types.d.ts +0 -2
  274. package/dist/esm/modules/network/http-request/common/types.d.ts.map +0 -1
  275. package/dist/esm/modules/network/http-request/common/types.js +0 -2
  276. package/dist/esm/modules/network/http-request/common/types.js.map +0 -1
  277. package/dist/esm/modules/queue/common/types.d.ts +0 -2
  278. package/dist/esm/modules/queue/common/types.d.ts.map +0 -1
  279. package/dist/esm/modules/queue/common/types.js +0 -2
  280. package/dist/esm/modules/queue/common/types.js.map +0 -1
  281. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.d.ts +0 -4
  282. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.d.ts.map +0 -1
  283. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.js +0 -28
  284. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.js.map +0 -1
  285. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.d.ts +0 -4
  286. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.d.ts.map +0 -1
  287. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.js +0 -26
  288. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.js.map +0 -1
  289. package/dist/esm/modules/storage/minio/helper.d.ts +0 -55
  290. package/dist/esm/modules/storage/minio/helper.d.ts.map +0 -1
  291. package/dist/esm/modules/storage/minio/helper.js +0 -176
  292. package/dist/esm/modules/storage/minio/helper.js.map +0 -1
  293. package/dist/esm/modules/storage/minio/index.d.ts +0 -2
  294. package/dist/esm/modules/storage/minio/index.d.ts.map +0 -1
  295. package/dist/esm/modules/storage/minio/index.js +0 -2
  296. package/dist/esm/modules/storage/minio/index.js.map +0 -1
  297. package/dist/esm/utilities/sleep.utility.d.ts +0 -2
  298. package/dist/esm/utilities/sleep.utility.d.ts.map +0 -1
  299. package/dist/esm/utilities/sleep.utility.js +0 -4
  300. package/dist/esm/utilities/sleep.utility.js.map +0 -1
@@ -1,71 +1,82 @@
1
- import { redactSecrets, toJsonSafe } from '../../../common/redact.js';
1
+ import { RedactUtility } from '../../../common/redact.js';
2
2
  import util from 'node:util';
3
3
  import { ErrorPrettier } from './error-prettier.js';
4
4
  /** The placeholders `util.format` understands. `%%` is an escape, not a placeholder. */
5
5
  const PLACEHOLDER_PATTERN = /%[sjdifoOc%]/g;
6
6
  /** How deep an object is inspected before it collapses to `[Object]`: Node's default of 2 hides nested data (e.g. wrapped `cause`), 5 reaches it while staying bounded. `APP_ENV_LOGGER_INSPECT_DEPTH` overrides with a NON-NEGATIVE number - no unlimited setting. */
7
7
  const DEFAULT_INSPECT_DEPTH = 5;
8
- const resolveDepth = () => {
9
- const configured = process.env.APP_ENV_LOGGER_INSPECT_DEPTH;
10
- // Not `int()`: it answers 0 for an ABSENT value, which would silently mean "depth 0" - the one setting that hides everything.
11
- if (configured === undefined || configured.trim() === '') {
12
- return DEFAULT_INSPECT_DEPTH;
13
- }
14
- const parsed = Number.parseInt(configured, 10);
15
- // A negative or unparseable value is a misconfiguration, not a request: fall back rather than hand `util.inspect` a depth it reads as "unlimited".
16
- if (Number.isNaN(parsed) || parsed < 0) {
17
- return DEFAULT_INSPECT_DEPTH;
18
- }
19
- return parsed;
20
- };
21
- const buildInspectOptions = () => {
22
- return {
23
- depth: resolveDepth(),
24
- maxArrayLength: null,
25
- maxStringLength: null,
26
- breakLength: Infinity,
27
- };
28
- };
29
- /** Formats like `util.format`, but `%s` inspects to configured depth instead of Node's hard-coded `depth: 0` (no inspect option overrides that), and `%j` is projected into a JSON-safe shape first. Per-placeholder only - handing `%j` the widened STRING would emit a JSON-quoted inspect dump instead of an object. */
30
- export const formatLogMessage = (opts) => {
31
- const { message, args, inspectOptions = buildInspectOptions() } = opts;
32
- const placeholders = (message.match(PLACEHOLDER_PATTERN) ?? []).filter((token) => token !== '%%');
33
- const widened = args.map((arg, index) => {
34
- const placeholder = placeholders[index];
35
- const isInspectable = typeof arg === 'object' && arg !== null;
36
- if (!isInspectable) {
37
- return arg;
38
- }
39
- // `%j` runs JSON.stringify, which answers `[Circular]` for the WHOLE argument when one cycle sits anywhere inside it - a transaction handle in the payload wipes out every other field. It also has no notion of secret keys, and no depth limit of its own. Project the value first, under the same depth cap `%s` gets.
40
- if (placeholder === '%j') {
41
- return toJsonSafe({ value: arg, depth: inspectOptions.depth ?? resolveDepth() });
42
- }
43
- // `%o`, `%O` and arguments with NO placeholder (`util.format` appends those) are redacted but
44
- // left as objects, so `util.formatWithOptions` still renders them the way that placeholder
45
- // means. Pre-inspecting them into a string here would make `%o` print a quoted, escaped string
46
- // instead of an object. Only the redaction is added; the rendering is unchanged.
47
- //
48
- // Before this, `logger.info('login failed', { password })` printed the password verbatim: the
49
- // redactor only ever saw `%s`, while the reference docs recommend `%o` for data objects.
50
- //
51
- // Bounded like the `%s` path below, and for the same reason: an unbounded walk on a very deep
52
- // graph is work whose result the renderer discards, and deep enough it is a `RangeError` on a
53
- // call that could not throw before. `%o` renders at `depth`, so `+2` covers what is shown.
54
- if (placeholder === undefined || placeholder === '%o' || placeholder === '%O') {
55
- return redactSecrets(arg, undefined, (inspectOptions.depth ?? resolveDepth()) + 2);
8
+ export class LogFormatUtility {
9
+ static resolveDepth() {
10
+ const configured = process.env.APP_ENV_LOGGER_INSPECT_DEPTH;
11
+ // Not `ParseUtility.toInt()`: it answers 0 for an ABSENT value, which would silently mean "depth 0" - the one setting that hides everything.
12
+ if (configured === undefined || configured.trim() === '') {
13
+ return DEFAULT_INSPECT_DEPTH;
56
14
  }
57
- if (placeholder !== '%s') {
58
- return arg;
15
+ const parsed = Number.parseInt(configured, 10);
16
+ // A negative or unparseable value is a misconfiguration, not a request: fall back rather than hand `util.inspect` a depth it reads as "unlimited".
17
+ if (Number.isNaN(parsed) || parsed < 0) {
18
+ return DEFAULT_INSPECT_DEPTH;
59
19
  }
60
- // Inspecting an Error dumps every own property - a `jose` failure carries the whole JWT payload, a driver failure the whole query. Project it instead, onto its own line so it never trails off the end of the caller's sentence.
61
- if (arg instanceof Error) {
62
- return `\n${ErrorPrettier.format({ error: arg, inspectOptions })}`;
63
- }
64
- // Bounded to just past what `util.inspect` will actually render. `+2`, not `+1`: at exactly
65
- // `depth + 1` the redactor replaces the last level with a string, and inspect then prints a
66
- // QUOTED `'[Object]'` instead of its own bare `[Object]`.
67
- return util.inspect(redactSecrets(arg, undefined, (inspectOptions.depth ?? resolveDepth()) + 2), inspectOptions);
68
- });
69
- return util.formatWithOptions(inspectOptions, message, ...widened);
70
- };
20
+ return parsed;
21
+ }
22
+ static buildInspectOptions() {
23
+ return {
24
+ depth: LogFormatUtility.resolveDepth(),
25
+ maxArrayLength: null,
26
+ maxStringLength: null,
27
+ breakLength: Infinity,
28
+ };
29
+ }
30
+ /** Formats like `util.format`, but `%s` inspects to configured depth instead of Node's hard-coded `depth: 0` (no inspect option overrides that), and `%j` is projected into a JSON-safe shape first. Per-placeholder only - handing `%j` the widened STRING would emit a JSON-quoted inspect dump instead of an object. */
31
+ static formatMessage(opts) {
32
+ const { message, args, inspectOptions = LogFormatUtility.buildInspectOptions() } = opts;
33
+ const placeholders = (message.match(PLACEHOLDER_PATTERN) ?? []).filter((token) => token !== '%%');
34
+ const widened = args.map((arg, index) => {
35
+ const placeholder = placeholders[index];
36
+ const isInspectable = typeof arg === 'object' && arg !== null;
37
+ if (!isInspectable) {
38
+ return arg;
39
+ }
40
+ // `%j` runs JSON.stringify, which answers `[Circular]` for the WHOLE argument when one cycle sits anywhere inside it - a transaction handle in the payload wipes out every other field. It also has no notion of secret keys, and no depth limit of its own. Project the value first, under the same depth cap `%s` gets.
41
+ if (placeholder === '%j') {
42
+ return RedactUtility.toJsonSafe({
43
+ value: arg,
44
+ depth: inspectOptions.depth ?? LogFormatUtility.resolveDepth(),
45
+ });
46
+ }
47
+ // `%o`, `%O` and arguments with NO placeholder (`util.format` appends those) are redacted but
48
+ // left as objects, so `util.formatWithOptions` still renders them the way that placeholder
49
+ // means. Pre-inspecting them into a string here would make `%o` print a quoted, escaped string
50
+ // instead of an object. Only the redaction is added; the rendering is unchanged.
51
+ //
52
+ // Before this, `logger.info('login failed', { password })` printed the password verbatim: the
53
+ // redactor only ever saw `%s`, while the reference docs recommend `%o` for data objects.
54
+ //
55
+ // Bounded like the `%s` path below, and for the same reason: an unbounded walk on a very deep
56
+ // graph is work whose result the renderer discards, and deep enough it is a `RangeError` on a
57
+ // call that could not throw before. `%o` renders at `depth`, so `+2` covers what is shown.
58
+ if (placeholder === undefined || placeholder === '%o' || placeholder === '%O') {
59
+ return RedactUtility.redactSecrets({
60
+ value: arg,
61
+ depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,
62
+ });
63
+ }
64
+ if (placeholder !== '%s') {
65
+ return arg;
66
+ }
67
+ // Inspecting an Error dumps every own property - a `jose` failure carries the whole JWT payload, a driver failure the whole query. Project it instead, onto its own line so it never trails off the end of the caller's sentence.
68
+ if (arg instanceof Error) {
69
+ return `\n${ErrorPrettier.format({ error: arg, inspectOptions })}`;
70
+ }
71
+ // Bounded to just past what `util.inspect` will actually render. `+2`, not `+1`: at exactly
72
+ // `depth + 1` the redactor replaces the last level with a string, and inspect then prints a
73
+ // QUOTED `'[Object]'` instead of its own bare `[Object]`.
74
+ return util.inspect(RedactUtility.redactSecrets({
75
+ value: arg,
76
+ depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,
77
+ }), inspectOptions);
78
+ });
79
+ return util.formatWithOptions(inspectOptions, message, ...widened);
80
+ }
81
+ }
71
82
  //# sourceMappingURL=deep-splat.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deep-splat.js","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/deep-splat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,wFAAwF;AACxF,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAE5C,uQAAuQ;AACvQ,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,MAAM,YAAY,GAAG,GAAW,EAAE;IAChC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;IAE5D,8HAA8H;IA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,IAAI,EAAE,CAAC;YACzB,OAAO,UAAU,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,cAAc,CAAC,KAAK,IAAI,YAAY,EAAE,EAAE,CAAC,CAAC;QACnF,CAAC;QAED,8FAA8F;QAC9F,2FAA2F;QAC3F,+FAA+F;QAC/F,iFAAiF;QACjF,EAAE;QACF,8FAA8F;QAC9F,yFAAyF;QACzF,EAAE;QACF,8FAA8F;QAC9F,8FAA8F;QAC9F,2FAA2F;QAC3F,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YAC9E,OAAO,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC,cAAc,CAAC,KAAK,IAAI,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACrF,CAAC;QAED,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,kOAAkO;QAClO,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;YACzB,OAAO,KAAK,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC;QACrE,CAAC;QAED,4FAA4F;QAC5F,4FAA4F;QAC5F,0DAA0D;QAC1D,OAAO,IAAI,CAAC,OAAO,CACjB,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC,cAAc,CAAC,KAAK,IAAI,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC,EAC3E,cAAc,CACf,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;AACrE,CAAC,CAAC","sourcesContent":["import { redactSecrets, toJsonSafe } from '@/common/redact';\nimport util from 'node:util';\nimport { ErrorPrettier } from './error-prettier';\n\n/** The placeholders `util.format` understands. `%%` is an escape, not a placeholder. */\nconst PLACEHOLDER_PATTERN = /%[sjdifoOc%]/g;\n\n/** How deep an object is inspected before it collapses to `[Object]`: Node's default of 2 hides nested data (e.g. wrapped `cause`), 5 reaches it while staying bounded. `APP_ENV_LOGGER_INSPECT_DEPTH` overrides with a NON-NEGATIVE number - no unlimited setting. */\nconst DEFAULT_INSPECT_DEPTH = 5;\n\nconst resolveDepth = (): number => {\n const configured = process.env.APP_ENV_LOGGER_INSPECT_DEPTH;\n\n // Not `int()`: it answers 0 for an ABSENT value, which would silently mean \"depth 0\" - the one setting that hides everything.\n if (configured === undefined || configured.trim() === '') {\n return DEFAULT_INSPECT_DEPTH;\n }\n\n const parsed = Number.parseInt(configured, 10);\n\n // A negative or unparseable value is a misconfiguration, not a request: fall back rather than hand `util.inspect` a depth it reads as \"unlimited\".\n if (Number.isNaN(parsed) || parsed < 0) {\n return DEFAULT_INSPECT_DEPTH;\n }\n\n return parsed;\n};\n\nconst buildInspectOptions = (): util.InspectOptions => {\n return {\n depth: resolveDepth(),\n maxArrayLength: null,\n maxStringLength: null,\n breakLength: Infinity,\n };\n};\n\n/** Formats like `util.format`, but `%s` inspects to configured depth instead of Node's hard-coded `depth: 0` (no inspect option overrides that), and `%j` is projected into a JSON-safe shape first. Per-placeholder only - handing `%j` the widened STRING would emit a JSON-quoted inspect dump instead of an object. */\nexport const formatLogMessage = (opts: {\n message: string;\n args: Array<unknown>;\n inspectOptions?: util.InspectOptions;\n}): string => {\n const { message, args, inspectOptions = buildInspectOptions() } = opts;\n\n const placeholders = (message.match(PLACEHOLDER_PATTERN) ?? []).filter((token) => token !== '%%');\n\n const widened = args.map((arg, index) => {\n const placeholder = placeholders[index];\n const isInspectable = typeof arg === 'object' && arg !== null;\n\n if (!isInspectable) {\n return arg;\n }\n\n // `%j` runs JSON.stringify, which answers `[Circular]` for the WHOLE argument when one cycle sits anywhere inside it - a transaction handle in the payload wipes out every other field. It also has no notion of secret keys, and no depth limit of its own. Project the value first, under the same depth cap `%s` gets.\n if (placeholder === '%j') {\n return toJsonSafe({ value: arg, depth: inspectOptions.depth ?? resolveDepth() });\n }\n\n // `%o`, `%O` and arguments with NO placeholder (`util.format` appends those) are redacted but\n // left as objects, so `util.formatWithOptions` still renders them the way that placeholder\n // means. Pre-inspecting them into a string here would make `%o` print a quoted, escaped string\n // instead of an object. Only the redaction is added; the rendering is unchanged.\n //\n // Before this, `logger.info('login failed', { password })` printed the password verbatim: the\n // redactor only ever saw `%s`, while the reference docs recommend `%o` for data objects.\n //\n // Bounded like the `%s` path below, and for the same reason: an unbounded walk on a very deep\n // graph is work whose result the renderer discards, and deep enough it is a `RangeError` on a\n // call that could not throw before. `%o` renders at `depth`, so `+2` covers what is shown.\n if (placeholder === undefined || placeholder === '%o' || placeholder === '%O') {\n return redactSecrets(arg, undefined, (inspectOptions.depth ?? resolveDepth()) + 2);\n }\n\n if (placeholder !== '%s') {\n return arg;\n }\n\n // Inspecting an Error dumps every own property - a `jose` failure carries the whole JWT payload, a driver failure the whole query. Project it instead, onto its own line so it never trails off the end of the caller's sentence.\n if (arg instanceof Error) {\n return `\\n${ErrorPrettier.format({ error: arg, inspectOptions })}`;\n }\n\n // Bounded to just past what `util.inspect` will actually render. `+2`, not `+1`: at exactly\n // `depth + 1` the redactor replaces the last level with a string, and inspect then prints a\n // QUOTED `'[Object]'` instead of its own bare `[Object]`.\n return util.inspect(\n redactSecrets(arg, undefined, (inspectOptions.depth ?? resolveDepth()) + 2),\n inspectOptions,\n );\n });\n\n return util.formatWithOptions(inspectOptions, message, ...widened);\n};\n"]}
1
+ {"version":3,"file":"deep-splat.js","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/deep-splat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,wFAAwF;AACxF,MAAM,mBAAmB,GAA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gB,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC;aACrE,CAAC,EACF,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;IACrE,CAAC;CACF","sourcesContent":["import { RedactUtility } from '@/common/redact';\nimport util from 'node:util';\nimport { ErrorPrettier } from './error-prettier';\n\n/** The placeholders `util.format` understands. `%%` is an escape, not a placeholder. */\nconst PLACEHOLDER_PATTERN = /%[sjdifoOc%]/g;\n\n/** How deep an object is inspected before it collapses to `[Object]`: Node's default of 2 hides nested data (e.g. wrapped `cause`), 5 reaches it while staying bounded. `APP_ENV_LOGGER_INSPECT_DEPTH` overrides with a NON-NEGATIVE number - no unlimited setting. */\nconst DEFAULT_INSPECT_DEPTH = 5;\n\nexport class LogFormatUtility {\n private static resolveDepth(): number {\n const configured = process.env.APP_ENV_LOGGER_INSPECT_DEPTH;\n\n // Not `ParseUtility.toInt()`: it answers 0 for an ABSENT value, which would silently mean \"depth 0\" - the one setting that hides everything.\n if (configured === undefined || configured.trim() === '') {\n return DEFAULT_INSPECT_DEPTH;\n }\n\n const parsed = Number.parseInt(configured, 10);\n\n // A negative or unparseable value is a misconfiguration, not a request: fall back rather than hand `util.inspect` a depth it reads as \"unlimited\".\n if (Number.isNaN(parsed) || parsed < 0) {\n return DEFAULT_INSPECT_DEPTH;\n }\n\n return parsed;\n }\n\n private static buildInspectOptions(): util.InspectOptions {\n return {\n depth: LogFormatUtility.resolveDepth(),\n maxArrayLength: null,\n maxStringLength: null,\n breakLength: Infinity,\n };\n }\n\n /** Formats like `util.format`, but `%s` inspects to configured depth instead of Node's hard-coded `depth: 0` (no inspect option overrides that), and `%j` is projected into a JSON-safe shape first. Per-placeholder only - handing `%j` the widened STRING would emit a JSON-quoted inspect dump instead of an object. */\n static formatMessage(opts: {\n message: string;\n args: Array<unknown>;\n inspectOptions?: util.InspectOptions;\n }): string {\n const { message, args, inspectOptions = LogFormatUtility.buildInspectOptions() } = opts;\n\n const placeholders = (message.match(PLACEHOLDER_PATTERN) ?? []).filter(\n (token) => token !== '%%',\n );\n\n const widened = args.map((arg, index) => {\n const placeholder = placeholders[index];\n const isInspectable = typeof arg === 'object' && arg !== null;\n\n if (!isInspectable) {\n return arg;\n }\n\n // `%j` runs JSON.stringify, which answers `[Circular]` for the WHOLE argument when one cycle sits anywhere inside it - a transaction handle in the payload wipes out every other field. It also has no notion of secret keys, and no depth limit of its own. Project the value first, under the same depth cap `%s` gets.\n if (placeholder === '%j') {\n return RedactUtility.toJsonSafe({\n value: arg,\n depth: inspectOptions.depth ?? LogFormatUtility.resolveDepth(),\n });\n }\n\n // `%o`, `%O` and arguments with NO placeholder (`util.format` appends those) are redacted but\n // left as objects, so `util.formatWithOptions` still renders them the way that placeholder\n // means. Pre-inspecting them into a string here would make `%o` print a quoted, escaped string\n // instead of an object. Only the redaction is added; the rendering is unchanged.\n //\n // Before this, `logger.info('login failed', { password })` printed the password verbatim: the\n // redactor only ever saw `%s`, while the reference docs recommend `%o` for data objects.\n //\n // Bounded like the `%s` path below, and for the same reason: an unbounded walk on a very deep\n // graph is work whose result the renderer discards, and deep enough it is a `RangeError` on a\n // call that could not throw before. `%o` renders at `depth`, so `+2` covers what is shown.\n if (placeholder === undefined || placeholder === '%o' || placeholder === '%O') {\n return RedactUtility.redactSecrets({\n value: arg,\n depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,\n });\n }\n\n if (placeholder !== '%s') {\n return arg;\n }\n\n // Inspecting an Error dumps every own property - a `jose` failure carries the whole JWT payload, a driver failure the whole query. Project it instead, onto its own line so it never trails off the end of the caller's sentence.\n if (arg instanceof Error) {\n return `\\n${ErrorPrettier.format({ error: arg, inspectOptions })}`;\n }\n\n // Bounded to just past what `util.inspect` will actually render. `+2`, not `+1`: at exactly\n // `depth + 1` the redactor replaces the last level with a string, and inspect then prints a\n // QUOTED `'[Object]'` instead of its own bare `[Object]`.\n return util.inspect(\n RedactUtility.redactSecrets({\n value: arg,\n depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,\n }),\n inspectOptions,\n );\n });\n\n return util.formatWithOptions(inspectOptions, message, ...widened);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"error-prettier.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/error-prettier.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE9D,0GAA0G;AAC1G,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2GAA2G;IAC3G,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,kIAAkI;IAClI,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+FAA+F;IAC/F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qKAAqK;IACrK,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,yFAAyF;IACzF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,+IAA+I;IAC/I,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;CAC/B;AAED,yGAAyG;AACzG,qBAAa,aAAa;IACxB,qDAAqD;IACrD,MAAM,CAAC,QAAQ,CAAC,uBAAuB,KAAK;IAE5C,kGAAkG;IAClG,MAAM,CAAC,QAAQ,CAAC,wBAAwB,MAAM;IAE9C,iGA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,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC;KACtC,GAAG,MAAM;CAmBX"}
1
+ {"version":3,"file":"error-prettier.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/error-prettier.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE9D,0GAA0G;AAC1G,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2GAA2G;IAC3G,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,kIAAkI;IAClI,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+FAA+F;IAC/F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qKAAqK;IACrK,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,yFAAyF;IACzF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,+IAA+I;IAC/I,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;CAC/B;AAED,yGAAyG;AACzG,qBAAa,aAAa;IACxB,qDAAqD;IACrD,MAAM,CAAC,QAAQ,CAAC,uBAAuB,KA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MAAM,CAAC,IAAI,EAAE;QAClB,KAAK,EAAE,OAAO,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC;KACtC,GAAG,MAAM;CAmBX"}
@@ -1,4 +1,4 @@
1
- import { redactSecrets } from '../../../common/redact.js';
1
+ import { RedactUtility } from '../../../common/redact.js';
2
2
  import { MessageCode } from '../../error/index.js';
3
3
  import util from 'node:util';
4
4
  import { LoggerFormats } from '../common/index.js';
@@ -173,7 +173,9 @@ export class ErrorPrettier {
173
173
  }
174
174
  // Nothing recognizable: inspect it (redacted) so an unmodelled shape still reaches the log.
175
175
  if (Object.keys(summary).length === 0) {
176
- return { message: util.inspect(redactSecrets(value), this.INSPECT_OPTIONS) };
176
+ return {
177
+ message: util.inspect(RedactUtility.redactSecrets({ value }), this.INSPECT_OPTIONS),
178
+ };
177
179
  }
178
180
  return summary;
179
181
  }
@@ -238,7 +240,7 @@ export class ErrorPrettier {
238
240
  payload.message = summary.message;
239
241
  }
240
242
  if (summary.args !== undefined) {
241
- payload.args = redactSecrets(summary.args);
243
+ payload.args = RedactUtility.redactSecrets({ value: summary.args });
242
244
  }
243
245
  // An ApplicationError has no own `code` and a driver error has no `normalized`, so one field never hides the other.
244
246
  const code = messageCode !== undefined && messageCode !== ''
@@ -258,7 +260,7 @@ export class ErrorPrettier {
258
260
  }
259
261
  const context = extra ?? summary.extra;
260
262
  if (context !== undefined && Object.keys(context).length > 0) {
261
- payload.extra = redactSecrets(context);
263
+ payload.extra = RedactUtility.redactSecrets({ value: context });
262
264
  }
263
265
  if (summary.cause !== undefined) {
264
266
  payload.cause = summary.cause;
@@ -281,7 +283,7 @@ export class ErrorPrettier {
281
283
  }
282
284
  // Straight after the message: the reader is looking at `%{field}` and needs the value now, not below the stack.
283
285
  if (summary.args !== undefined) {
284
- lines.push(`args: ${util.inspect(redactSecrets(summary.args), inspectOptions)}`);
286
+ lines.push(`args: ${util.inspect(RedactUtility.redactSecrets({ value: summary.args }), inspectOptions)}`);
285
287
  }
286
288
  this.pushAggregatedErrors({ node: summary, lines });
287
289
  let cause = summary.cause;
@@ -309,7 +311,7 @@ export class ErrorPrettier {
309
311
  // An explicit `extra` wins; otherwise fall back to the one the error carries itself.
310
312
  const context = extra ?? summary.extra;
311
313
  if (context !== undefined && Object.keys(context).length > 0) {
312
- lines.push(`extra: ${util.inspect(redactSecrets(context), inspectOptions)}`);
314
+ lines.push(`extra: ${util.inspect(RedactUtility.redactSecrets({ value: context }), inspectOptions)}`);
313
315
  }
314
316
  if (summary.stack !== undefined) {
315
317
  lines.push(`stack:\n${summary.stack}`);
@@ -1 +1 @@
1
- {"version":3,"file":"error-prettier.js","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/error-prettier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAsB,MAAM,WAAW,CAAC;AAyB9D,yGAAyG;AACzG,MAAM,OAAO,aAAa;IACxB,qDAAqD;aACrC,4BAAuB,GAAG,CAAC,CAAC;IAE5C,kGAAkG;aAClF,6BAAwB,GAAG,EAAE,CAAC;IAE9C,iGAAiG;aACzE,oBAAe,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,CAAU,CAAC;IAE7F,yEAAyE;aACjD,kBAAa,GAAG,SAAS,CAAC;IAElD,4FAA4F;aACpE,6BAAwB,GAAG,mBAAmB,CAAC;IAEvE,8SAA8S;aACtR,gCAA2B,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Ac,GAAG,IAAI,CAAC,eAAe,GACtC,GAAG,IAAI,CAAC;QAET,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC,CAAC;QAExE,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,aAAa,CAAC,IAAI,EAAE,CAAC;YACtD,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1D,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;IAC1E,CAAC","sourcesContent":["import { redactSecrets } from '@/common/redact';\nimport { MessageCode } from '@/modules/error';\nimport util from 'node:util';\nimport { LoggerFormats, type TLoggerFormat } from '../common';\n\n/** Useful-only projection of an error: a driver's `query`/`params` repeat the message and are dropped. */\nexport interface IErrorSummary {\n name?: string;\n message?: string;\n /** The error's OWN code - a driver's `23505`, a gRPC `14`. Belongs with the name, not with the message. */\n code?: string | number;\n /** An `ApplicationError`'s `normalized.code` - the identifier an application filters on. `MessageCode.DEFAULT` never surfaces. */\n messageCode?: string;\n /** Frames ONLY - V8's `Error: <message>` header is stripped so the message is not repeated. */\n stack?: string;\n hint?: string;\n detail?: string;\n table?: string;\n constraint?: string;\n /** Values for the `%{placeholder}` tokens left unresolved in `message` - i18n resolves them downstream, so the log must carry them or the message names no field. */\n args?: Record<string, unknown>;\n /** An `ApplicationError`'s caller context - the one unmodelled payload worth keeping. */\n extra?: Record<string, unknown>;\n cause?: IErrorSummary;\n /** Every reason an `AggregateError` collected. Its own message names none of them, so without this the log says only that something failed. */\n errors?: Array<IErrorSummary>;\n}\n\n/** Turns a thrown value into something a human can read in a console - log this, never the raw error. */\nexport class ErrorPrettier {\n /** Bounds a pathological or cyclic `cause` chain. */\n static readonly DEFAULT_MAX_CAUSE_DEPTH = 5;\n\n /** The throw site is near the top; the tail is identical framework plumbing for every request. */\n static readonly DEFAULT_MAX_STACK_FRAMES = 10;\n\n /** Driver diagnostics that are actionable and absent from `message` - `pg` supplies all four. */\n private static readonly DIAGNOSTIC_KEYS = ['hint', 'detail', 'table', 'constraint'] as const;\n\n /** A stack frame line in every V8 stack: ` at fn (file:line:col)`. */\n private static readonly FRAME_PATTERN = /^\\s+at /;\n\n /** A frame inside an installed package - `node_modules/` covers bun's `.bun/` store too. */\n private static readonly DEPENDENCY_FRAME_PATTERN = /node_modules[/\\\\]/;\n\n /** `getError` sits on top of every `ApplicationError` stack and names no call site. Installed, it is also the FIRST dependency frame, so the keep-the-first rule would preserve exactly the wrong one. Anchored on `inversion` so an application's own `modules/error/app-error` is not swallowed with it. */\n private static readonly ERROR_FACTORY_FRAME_PATTERN =\n /inversion[/\\\\].*modules[/\\\\]error[/\\\\]app-error/;\n\n /** Issues rendered from a ZodError before the rest are counted off. */\n private static readonly MAX_ZOD_ISSUES = 10;\n\n /** Members of an `AggregateError` rendered before the rest are counted off. */\n private static readonly MAX_AGGREGATED_ERRORS = 10;\n\n private static readonly INSPECT_OPTIONS: util.InspectOptions = {\n depth: 5,\n maxArrayLength: null,\n maxStringLength: null,\n breakLength: Infinity,\n };\n\n private static extractFrames(opts: { stack: unknown; maxFrames: number }): string | undefined {\n const { stack, maxFrames } = opts;\n\n if (typeof stack !== 'string') {\n return undefined;\n }\n\n const frames: Array<string> = [];\n let keptDependencyFrame = false;\n let omitted = 0;\n\n // Hand-rolled over split+filter+slice: it stops at maxFrames instead of walking the whole stack.\n const lines = stack.split('\\n');\n for (const line of lines) {\n if (!this.FRAME_PATTERN.test(line)) {\n continue;\n }\n\n // Not counted as omitted: a factory frame is noise, and reporting it would imply signal was dropped.\n if (this.ERROR_FACTORY_FRAME_PATTERN.test(line)) {\n continue;\n }\n\n // The FIRST dependency frame is often the throw site (drizzle, jose); every later one is plumbing.\n const isDependencyFrame = this.DEPENDENCY_FRAME_PATTERN.test(line);\n\n if (isDependencyFrame && keptDependencyFrame) {\n omitted += 1;\n continue;\n }\n\n keptDependencyFrame = keptDependencyFrame || isDependencyFrame;\n frames.push(line);\n\n if (frames.length === maxFrames) {\n break;\n }\n }\n\n // Emit nothing rather than the header, which would repeat the message.\n if (frames.length === 0) {\n return undefined;\n }\n\n // Never truncate silently - a reader must know frames are missing, not assume the stack ended.\n return omitted > 0\n ? `${frames.join('\\n')}\\n ... ${omitted} dependency frames`\n : frames.join('\\n');\n }\n\n /** A ZodError's `message` is its issue array as pretty JSON - dozens of lines for one bad field. Render `path: reason` instead. */\n private static compressZodMessage(opts: { message: string }): string {\n const { message } = opts;\n\n let issues: unknown;\n\n try {\n issues = JSON.parse(message);\n } catch {\n // Not the JSON form (an already-formatted or hand-built ZodError) - leave it alone.\n return message;\n }\n\n if (!Array.isArray(issues) || issues.length === 0) {\n return message;\n }\n\n const lines = issues.slice(0, this.MAX_ZOD_ISSUES).map((issue) => {\n const entry = issue as { path?: Array<string | number>; message?: string; code?: string };\n const path =\n Array.isArray(entry.path) && entry.path.length > 0 ? entry.path.join('.') : '(root)';\n\n return `${path}: ${entry.message ?? entry.code ?? 'invalid'}`;\n });\n\n const remaining = issues.length - lines.length;\n\n return remaining > 0 ? `${lines.join('\\n')}\\n... and ${remaining} more` : lines.join('\\n');\n }\n\n private static summarizeNode(opts: {\n value: unknown;\n depthLeft: number;\n seen: WeakSet<object>;\n isRoot: boolean;\n includeStack: boolean;\n maxStackFrames: number;\n }): IErrorSummary {\n const { value, depthLeft, seen, isRoot, includeStack, maxStackFrames } = opts;\n\n // A primitive - a string thrown as `cause`, a numeric code - is its own message.\n if (typeof value !== 'object' || value === null) {\n return { message: String(value) };\n }\n\n if (seen.has(value)) {\n return { message: '[Circular]' };\n }\n seen.add(value);\n\n const source = value as Record<string, unknown>;\n const summary: IErrorSummary = {};\n\n if (typeof source.name === 'string') {\n summary.name = source.name;\n }\n\n if (typeof source.message === 'string') {\n summary.message =\n source.name === 'ZodError'\n ? this.compressZodMessage({ message: source.message })\n : source.message;\n }\n\n if (typeof source.code === 'string' || typeof source.code === 'number') {\n summary.code = source.code;\n }\n\n const normalized =\n typeof source.normalized === 'object' && source.normalized !== null\n ? (source.normalized as { code?: unknown; args?: unknown })\n : undefined;\n\n // `MessageCode.resolve` stamps DEFAULT on every codeless error, so surfacing it blindly would put a meaningless line on every log.\n if (typeof normalized?.code === 'string' && normalized.code !== MessageCode.DEFAULT) {\n summary.messageCode = normalized.code;\n }\n\n // Root only: a cause's frames point into the same libraries and add no location the root lacks.\n if (isRoot && includeStack) {\n const frames = this.extractFrames({ stack: source.stack, maxFrames: maxStackFrames });\n if (frames !== undefined) {\n summary.stack = frames;\n }\n }\n\n for (const key of this.DIAGNOSTIC_KEYS) {\n const diagnostic = source[key];\n if (typeof diagnostic === 'string' && diagnostic.length > 0) {\n summary[key] = diagnostic;\n }\n }\n\n // Root only: the args fill the ROOT's message; a cause's belong to a message this block does not print.\n if (isRoot && typeof normalized?.args === 'object' && normalized.args !== null) {\n const args = normalized.args as Record<string, unknown>;\n if (Object.keys(args).length > 0) {\n summary.args = args;\n }\n }\n\n // Root only: `extra` is what a throw site deliberately attached, so a direct log call keeps it.\n if (isRoot && typeof source.extra === 'object' && source.extra !== null) {\n const extra = source.extra as Record<string, unknown>;\n if (Object.keys(extra).length > 0) {\n summary.extra = extra;\n }\n }\n\n if (source.cause !== undefined && source.cause !== null && depthLeft > 0) {\n summary.cause = this.summarizeNode({\n value: source.cause,\n depthLeft: depthLeft - 1,\n seen,\n isRoot: false,\n includeStack,\n maxStackFrames,\n });\n }\n\n // A protocol client reports one member per thing that failed; the wrapper carries only a generic sentence.\n if (Array.isArray(source.errors) && source.errors.length > 0 && depthLeft > 0) {\n const members = source.errors.slice(0, this.MAX_AGGREGATED_ERRORS).map((member) =>\n this.summarizeNode({\n value: member,\n depthLeft: depthLeft - 1,\n seen,\n isRoot: false,\n includeStack,\n maxStackFrames,\n }),\n );\n\n const remaining = source.errors.length - members.length;\n if (remaining > 0) {\n members.push({ message: `... and ${remaining} more` });\n }\n\n summary.errors = members;\n }\n\n // Nothing recognizable: inspect it (redacted) so an unmodelled shape still reaches the log.\n if (Object.keys(summary).length === 0) {\n return { message: util.inspect(redactSecrets(value), this.INSPECT_OPTIONS) };\n }\n\n return summary;\n }\n\n private static pushDiagnostics(opts: { node: IErrorSummary; lines: Array<string> }): void {\n const { node, lines } = opts;\n\n for (const key of this.DIAGNOSTIC_KEYS) {\n const diagnostic = node[key];\n if (diagnostic !== undefined) {\n lines.push(`${key}: ${diagnostic}`);\n }\n }\n }\n\n /** Under whichever node collected them - a wrapped `AggregateError` is the common shape. */\n private static pushAggregatedErrors(opts: { node: IErrorSummary; lines: Array<string> }): void {\n const { node, lines } = opts;\n\n node.errors?.forEach((member, index) => {\n const memberCode = member.code ?? member.messageCode;\n const code = memberCode === undefined ? '' : ` (code ${memberCode})`;\n lines.push(`errors[${index}]: ${member.message ?? ''}${code}`);\n this.pushDiagnostics({ node: member, lines });\n });\n }\n\n /** Reduces any thrown value to {@link IErrorSummary} - always a summary, never a bare primitive. */\n static summarize(opts: {\n error: unknown;\n includeStack?: boolean;\n maxCauseDepth?: number;\n maxStackFrames?: number;\n }): IErrorSummary {\n const {\n error,\n includeStack = true,\n maxCauseDepth = this.DEFAULT_MAX_CAUSE_DEPTH,\n maxStackFrames = this.DEFAULT_MAX_STACK_FRAMES,\n } = opts;\n\n return this.summarizeNode({\n value: error,\n depthLeft: maxCauseDepth,\n seen: new WeakSet(),\n isRoot: true,\n includeStack,\n maxStackFrames,\n });\n }\n\n /** Resolved per call, not at module load, so a test passes a value instead of mutating the environment. */\n private static resolveFormat(configured?: TLoggerFormat): TLoggerFormat {\n if (configured !== undefined) {\n return configured;\n }\n\n const fromEnv = process.env.APP_ENV_LOGGER_FORMAT;\n\n return fromEnv !== undefined && LoggerFormats.isValid(fromEnv) ? fromEnv : LoggerFormats.TEXT;\n }\n\n /** `JSON.stringify` throws on a cycle, and `format` runs inside the error handler - a throw there turns a handled failure into an unhandled one. `redactSecrets` breaks cycles on its own, but it is switched off by `APP_ENV_LOGGER_DO_REDACT=false`, so structural safety cannot lean on it. A repeated reference reads as `[Circular]` too: the first occurrence still carries the data. */\n private static safeStringify(payload: Record<string, unknown>): string {\n const seen = new WeakSet<object>();\n\n return JSON.stringify(payload, (_key, value: unknown) => {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n\n if (seen.has(value)) {\n return '[Circular]';\n }\n\n seen.add(value);\n return value;\n });\n }\n\n /** One line, so a log monitor keeps the error as ONE record instead of one per bullet. */\n private static renderJson(opts: {\n summary: IErrorSummary;\n messageCode?: string;\n extra?: Record<string, unknown>;\n }): string {\n const { summary, messageCode, extra } = opts;\n\n const payload: Record<string, unknown> = {};\n\n if (summary.message !== undefined) {\n payload.message = summary.message;\n }\n\n if (summary.args !== undefined) {\n payload.args = redactSecrets(summary.args);\n }\n\n // An ApplicationError has no own `code` and a driver error has no `normalized`, so one field never hides the other.\n const code =\n messageCode !== undefined && messageCode !== ''\n ? messageCode\n : (summary.messageCode ?? summary.code);\n if (code !== undefined) {\n payload.code = code;\n }\n\n // A bare `Error` says nothing; the text block drops it for the same reason.\n if (summary.name !== undefined && summary.name !== 'Error') {\n payload.name = summary.name;\n }\n\n for (const key of this.DIAGNOSTIC_KEYS) {\n if (summary[key] !== undefined) {\n payload[key] = summary[key];\n }\n }\n\n const context = extra ?? summary.extra;\n if (context !== undefined && Object.keys(context).length > 0) {\n payload.extra = redactSecrets(context);\n }\n\n if (summary.cause !== undefined) {\n payload.cause = summary.cause;\n }\n\n if (summary.errors !== undefined) {\n payload.errors = summary.errors;\n }\n\n // An ARRAY, not the newline-joined string `text` prints: a monitor can count and slice frames.\n if (summary.stack !== undefined) {\n payload.stack = summary.stack.split('\\n').map((frame) => frame.trim());\n }\n\n return this.safeStringify(payload);\n }\n\n private static renderText(opts: {\n summary: IErrorSummary;\n messageCode?: string;\n extra?: Record<string, unknown>;\n inspectOptions: util.InspectOptions;\n }): string {\n const { summary, messageCode, extra, inspectOptions } = opts;\n\n const lines: Array<string> = [];\n\n // What happened, then why, then who/where - a reader stops as soon as they have the answer.\n if (summary.message !== undefined) {\n lines.push(`message: ${summary.message}`);\n }\n\n // Straight after the message: the reader is looking at `%{field}` and needs the value now, not below the stack.\n if (summary.args !== undefined) {\n lines.push(`args: ${util.inspect(redactSecrets(summary.args), inspectOptions)}`);\n }\n\n this.pushAggregatedErrors({ node: summary, lines });\n\n let cause = summary.cause;\n while (cause !== undefined) {\n const causeCode = cause.code ?? cause.messageCode;\n const code = causeCode === undefined ? '' : ` (code ${causeCode})`;\n lines.push(`cause: ${cause.message ?? ''}${code}`);\n this.pushDiagnostics({ node: cause, lines });\n this.pushAggregatedErrors({ node: cause, lines });\n cause = cause.cause;\n }\n\n const identity = [summary.name, summary.code === undefined ? '' : `(code ${summary.code})`]\n .filter(Boolean)\n .join(' ');\n\n // A bare `name: Error` says nothing; keep the line only when it is specific or carries a code.\n if (identity !== '' && identity !== 'Error') {\n lines.push(`name: ${identity}`);\n }\n\n // The caller's code wins; otherwise the error's own, so a direct log call keeps its identifier too.\n const code =\n messageCode !== undefined && messageCode !== '' ? messageCode : summary.messageCode;\n if (code !== undefined) {\n lines.push(`code: ${code}`);\n }\n\n this.pushDiagnostics({ node: summary, lines });\n\n // An explicit `extra` wins; otherwise fall back to the one the error carries itself.\n const context = extra ?? summary.extra;\n\n if (context !== undefined && Object.keys(context).length > 0) {\n lines.push(`extra: ${util.inspect(redactSecrets(context), inspectOptions)}`);\n }\n\n if (summary.stack !== undefined) {\n lines.push(`stack:\\n${summary.stack}`);\n }\n\n return lines.map((line) => `- ${line}`).join('\\n');\n }\n\n /** Renders {@link summarize}. `text` returns a block whose newlines survive `%s`; `json` returns one line. */\n static format(opts: {\n error: unknown;\n messageCode?: string;\n extra?: Record<string, unknown>;\n includeStack?: boolean;\n maxStackFrames?: number;\n format?: TLoggerFormat;\n inspectOptions?: util.InspectOptions;\n }): string {\n const {\n error,\n messageCode,\n extra,\n includeStack = true,\n maxStackFrames,\n format,\n inspectOptions = this.INSPECT_OPTIONS,\n } = opts;\n\n const summary = this.summarize({ error, includeStack, maxStackFrames });\n\n if (this.resolveFormat(format) === LoggerFormats.JSON) {\n return this.renderJson({ summary, messageCode, extra });\n }\n\n return this.renderText({ summary, messageCode, extra, inspectOptions });\n }\n}\n"]}
1
+ {"version":3,"file":"error-prettier.js","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/error-prettier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAsB,MAAM,WAAW,CAAC;AAyB9D,yGAAyG;AACzG,MAAM,OAAO,aAAa;IACxB,qDAAqD;aACrC,4BAAuB,GAAG,CAAC,CAAC;IAE5C,kGAAkG;aAClF,6BAAwB,GAAG,EAAE,CAAC;IAE9C,iGAAiG;aACzE,oBAAe,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,CAAU,CAAC;IAE7F,yEAAyE;aACjD,kBAAa,GAAG,SAAS,CAAC;IAElD,4FAA4F;aACpE,6BAAwB,GAAG,mBAAmB,CAAC;IAEvE,8SAA8S;aACtR,gCAA2B,GACjD,iDAAiD,CAAC;IAEpD,uEAAuE;aAC/C,mBAAc,GAAG,EAAE,CAAC;IAE5C,+EAA+E;aACvD,0BAAqB,GAAG,EAAE,CAAC;aAE3B,oBAAe,GAAwB;QAC7D,KAAK,EAAE,CAAC;QACR,cAAc,EAAE,IAAI;QACpB,eAAe,EAAE,IAAI;QACrB,WAAW,EAAE,QAAQ;KACtB,CAAC;IAEM,MAAM,CAAC,aAAa,CAAC,IAA2C;QACtE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,C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,aAAa,CAAC,MAAM,CAAC,KAAK,aAAa,CAAC,IAAI,EAAE,CAAC;YACtD,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1D,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;IAC1E,CAAC","sourcesContent":["import { RedactUtility } from '@/common/redact';\nimport { MessageCode } from '@/modules/error';\nimport util from 'node:util';\nimport { LoggerFormats, type TLoggerFormat } from '../common';\n\n/** Useful-only projection of an error: a driver's `query`/`params` repeat the message and are dropped. */\nexport interface IErrorSummary {\n name?: string;\n message?: string;\n /** The error's OWN code - a driver's `23505`, a gRPC `14`. Belongs with the name, not with the message. */\n code?: string | number;\n /** An `ApplicationError`'s `normalized.code` - the identifier an application filters on. `MessageCode.DEFAULT` never surfaces. */\n messageCode?: string;\n /** Frames ONLY - V8's `Error: <message>` header is stripped so the message is not repeated. */\n stack?: string;\n hint?: string;\n detail?: string;\n table?: string;\n constraint?: string;\n /** Values for the `%{placeholder}` tokens left unresolved in `message` - i18n resolves them downstream, so the log must carry them or the message names no field. */\n args?: Record<string, unknown>;\n /** An `ApplicationError`'s caller context - the one unmodelled payload worth keeping. */\n extra?: Record<string, unknown>;\n cause?: IErrorSummary;\n /** Every reason an `AggregateError` collected. Its own message names none of them, so without this the log says only that something failed. */\n errors?: Array<IErrorSummary>;\n}\n\n/** Turns a thrown value into something a human can read in a console - log this, never the raw error. */\nexport class ErrorPrettier {\n /** Bounds a pathological or cyclic `cause` chain. */\n static readonly DEFAULT_MAX_CAUSE_DEPTH = 5;\n\n /** The throw site is near the top; the tail is identical framework plumbing for every request. */\n static readonly DEFAULT_MAX_STACK_FRAMES = 10;\n\n /** Driver diagnostics that are actionable and absent from `message` - `pg` supplies all four. */\n private static readonly DIAGNOSTIC_KEYS = ['hint', 'detail', 'table', 'constraint'] as const;\n\n /** A stack frame line in every V8 stack: ` at fn (file:line:col)`. */\n private static readonly FRAME_PATTERN = /^\\s+at /;\n\n /** A frame inside an installed package - `node_modules/` covers bun's `.bun/` store too. */\n private static readonly DEPENDENCY_FRAME_PATTERN = /node_modules[/\\\\]/;\n\n /** `getError` sits on top of every `ApplicationError` stack and names no call site. Installed, it is also the FIRST dependency frame, so the keep-the-first rule would preserve exactly the wrong one. Anchored on `inversion` so an application's own `modules/error/app-error` is not swallowed with it. */\n private static readonly ERROR_FACTORY_FRAME_PATTERN =\n /inversion[/\\\\].*modules[/\\\\]error[/\\\\]app-error/;\n\n /** Issues rendered from a ZodError before the rest are counted off. */\n private static readonly MAX_ZOD_ISSUES = 10;\n\n /** Members of an `AggregateError` rendered before the rest are counted off. */\n private static readonly MAX_AGGREGATED_ERRORS = 10;\n\n private static readonly INSPECT_OPTIONS: util.InspectOptions = {\n depth: 5,\n maxArrayLength: null,\n maxStringLength: null,\n breakLength: Infinity,\n };\n\n private static extractFrames(opts: { stack: unknown; maxFrames: number }): string | undefined {\n const { stack, maxFrames } = opts;\n\n if (typeof stack !== 'string') {\n return undefined;\n }\n\n const frames: Array<string> = [];\n let keptDependencyFrame = false;\n let omitted = 0;\n\n // Hand-rolled over split+filter+slice: it stops at maxFrames instead of walking the whole stack.\n const lines = stack.split('\\n');\n for (const line of lines) {\n if (!this.FRAME_PATTERN.test(line)) {\n continue;\n }\n\n // Not counted as omitted: a factory frame is noise, and reporting it would imply signal was dropped.\n if (this.ERROR_FACTORY_FRAME_PATTERN.test(line)) {\n continue;\n }\n\n // The FIRST dependency frame is often the throw site (drizzle, jose); every later one is plumbing.\n const isDependencyFrame = this.DEPENDENCY_FRAME_PATTERN.test(line);\n\n if (isDependencyFrame && keptDependencyFrame) {\n omitted += 1;\n continue;\n }\n\n keptDependencyFrame = keptDependencyFrame || isDependencyFrame;\n frames.push(line);\n\n if (frames.length === maxFrames) {\n break;\n }\n }\n\n // Emit nothing rather than the header, which would repeat the message.\n if (frames.length === 0) {\n return undefined;\n }\n\n // Never truncate silently - a reader must know frames are missing, not assume the stack ended.\n return omitted > 0\n ? `${frames.join('\\n')}\\n ... ${omitted} dependency frames`\n : frames.join('\\n');\n }\n\n /** A ZodError's `message` is its issue array as pretty JSON - dozens of lines for one bad field. Render `path: reason` instead. */\n private static compressZodMessage(opts: { message: string }): string {\n const { message } = opts;\n\n let issues: unknown;\n\n try {\n issues = JSON.parse(message);\n } catch {\n // Not the JSON form (an already-formatted or hand-built ZodError) - leave it alone.\n return message;\n }\n\n if (!Array.isArray(issues) || issues.length === 0) {\n return message;\n }\n\n const lines = issues.slice(0, this.MAX_ZOD_ISSUES).map((issue) => {\n const entry = issue as { path?: Array<string | number>; message?: string; code?: string };\n const path =\n Array.isArray(entry.path) && entry.path.length > 0 ? entry.path.join('.') : '(root)';\n\n return `${path}: ${entry.message ?? entry.code ?? 'invalid'}`;\n });\n\n const remaining = issues.length - lines.length;\n\n return remaining > 0 ? `${lines.join('\\n')}\\n... and ${remaining} more` : lines.join('\\n');\n }\n\n private static summarizeNode(opts: {\n value: unknown;\n depthLeft: number;\n seen: WeakSet<object>;\n isRoot: boolean;\n includeStack: boolean;\n maxStackFrames: number;\n }): IErrorSummary {\n const { value, depthLeft, seen, isRoot, includeStack, maxStackFrames } = opts;\n\n // A primitive - a string thrown as `cause`, a numeric code - is its own message.\n if (typeof value !== 'object' || value === null) {\n return { message: String(value) };\n }\n\n if (seen.has(value)) {\n return { message: '[Circular]' };\n }\n seen.add(value);\n\n const source = value as Record<string, unknown>;\n const summary: IErrorSummary = {};\n\n if (typeof source.name === 'string') {\n summary.name = source.name;\n }\n\n if (typeof source.message === 'string') {\n summary.message =\n source.name === 'ZodError'\n ? this.compressZodMessage({ message: source.message })\n : source.message;\n }\n\n if (typeof source.code === 'string' || typeof source.code === 'number') {\n summary.code = source.code;\n }\n\n const normalized =\n typeof source.normalized === 'object' && source.normalized !== null\n ? (source.normalized as { code?: unknown; args?: unknown })\n : undefined;\n\n // `MessageCode.resolve` stamps DEFAULT on every codeless error, so surfacing it blindly would put a meaningless line on every log.\n if (typeof normalized?.code === 'string' && normalized.code !== MessageCode.DEFAULT) {\n summary.messageCode = normalized.code;\n }\n\n // Root only: a cause's frames point into the same libraries and add no location the root lacks.\n if (isRoot && includeStack) {\n const frames = this.extractFrames({ stack: source.stack, maxFrames: maxStackFrames });\n if (frames !== undefined) {\n summary.stack = frames;\n }\n }\n\n for (const key of this.DIAGNOSTIC_KEYS) {\n const diagnostic = source[key];\n if (typeof diagnostic === 'string' && diagnostic.length > 0) {\n summary[key] = diagnostic;\n }\n }\n\n // Root only: the args fill the ROOT's message; a cause's belong to a message this block does not print.\n if (isRoot && typeof normalized?.args === 'object' && normalized.args !== null) {\n const args = normalized.args as Record<string, unknown>;\n if (Object.keys(args).length > 0) {\n summary.args = args;\n }\n }\n\n // Root only: `extra` is what a throw site deliberately attached, so a direct log call keeps it.\n if (isRoot && typeof source.extra === 'object' && source.extra !== null) {\n const extra = source.extra as Record<string, unknown>;\n if (Object.keys(extra).length > 0) {\n summary.extra = extra;\n }\n }\n\n if (source.cause !== undefined && source.cause !== null && depthLeft > 0) {\n summary.cause = this.summarizeNode({\n value: source.cause,\n depthLeft: depthLeft - 1,\n seen,\n isRoot: false,\n includeStack,\n maxStackFrames,\n });\n }\n\n // A protocol client reports one member per thing that failed; the wrapper carries only a generic sentence.\n if (Array.isArray(source.errors) && source.errors.length > 0 && depthLeft > 0) {\n const members = source.errors.slice(0, this.MAX_AGGREGATED_ERRORS).map((member) =>\n this.summarizeNode({\n value: member,\n depthLeft: depthLeft - 1,\n seen,\n isRoot: false,\n includeStack,\n maxStackFrames,\n }),\n );\n\n const remaining = source.errors.length - members.length;\n if (remaining > 0) {\n members.push({ message: `... and ${remaining} more` });\n }\n\n summary.errors = members;\n }\n\n // Nothing recognizable: inspect it (redacted) so an unmodelled shape still reaches the log.\n if (Object.keys(summary).length === 0) {\n return {\n message: util.inspect(RedactUtility.redactSecrets({ value }), this.INSPECT_OPTIONS),\n };\n }\n\n return summary;\n }\n\n private static pushDiagnostics(opts: { node: IErrorSummary; lines: Array<string> }): void {\n const { node, lines } = opts;\n\n for (const key of this.DIAGNOSTIC_KEYS) {\n const diagnostic = node[key];\n if (diagnostic !== undefined) {\n lines.push(`${key}: ${diagnostic}`);\n }\n }\n }\n\n /** Under whichever node collected them - a wrapped `AggregateError` is the common shape. */\n private static pushAggregatedErrors(opts: { node: IErrorSummary; lines: Array<string> }): void {\n const { node, lines } = opts;\n\n node.errors?.forEach((member, index) => {\n const memberCode = member.code ?? member.messageCode;\n const code = memberCode === undefined ? '' : ` (code ${memberCode})`;\n lines.push(`errors[${index}]: ${member.message ?? ''}${code}`);\n this.pushDiagnostics({ node: member, lines });\n });\n }\n\n /** Reduces any thrown value to {@link IErrorSummary} - always a summary, never a bare primitive. */\n static summarize(opts: {\n error: unknown;\n includeStack?: boolean;\n maxCauseDepth?: number;\n maxStackFrames?: number;\n }): IErrorSummary {\n const {\n error,\n includeStack = true,\n maxCauseDepth = this.DEFAULT_MAX_CAUSE_DEPTH,\n maxStackFrames = this.DEFAULT_MAX_STACK_FRAMES,\n } = opts;\n\n return this.summarizeNode({\n value: error,\n depthLeft: maxCauseDepth,\n seen: new WeakSet(),\n isRoot: true,\n includeStack,\n maxStackFrames,\n });\n }\n\n /** Resolved per call, not at module load, so a test passes a value instead of mutating the environment. */\n private static resolveFormat(configured?: TLoggerFormat): TLoggerFormat {\n if (configured !== undefined) {\n return configured;\n }\n\n const fromEnv = process.env.APP_ENV_LOGGER_FORMAT;\n\n return fromEnv !== undefined && LoggerFormats.isValid(fromEnv) ? fromEnv : LoggerFormats.TEXT;\n }\n\n /** `JSON.stringify` throws on a cycle, and `format` runs inside the error handler - a throw there turns a handled failure into an unhandled one. `redactSecrets` breaks cycles on its own, but it is switched off by `APP_ENV_LOGGER_DO_REDACT=false`, so structural safety cannot lean on it. A repeated reference reads as `[Circular]` too: the first occurrence still carries the data. */\n private static safeStringify(payload: Record<string, unknown>): string {\n const seen = new WeakSet<object>();\n\n return JSON.stringify(payload, (_key, value: unknown) => {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n\n if (seen.has(value)) {\n return '[Circular]';\n }\n\n seen.add(value);\n return value;\n });\n }\n\n /** One line, so a log monitor keeps the error as ONE record instead of one per bullet. */\n private static renderJson(opts: {\n summary: IErrorSummary;\n messageCode?: string;\n extra?: Record<string, unknown>;\n }): string {\n const { summary, messageCode, extra } = opts;\n\n const payload: Record<string, unknown> = {};\n\n if (summary.message !== undefined) {\n payload.message = summary.message;\n }\n\n if (summary.args !== undefined) {\n payload.args = RedactUtility.redactSecrets({ value: summary.args });\n }\n\n // An ApplicationError has no own `code` and a driver error has no `normalized`, so one field never hides the other.\n const code =\n messageCode !== undefined && messageCode !== ''\n ? messageCode\n : (summary.messageCode ?? summary.code);\n if (code !== undefined) {\n payload.code = code;\n }\n\n // A bare `Error` says nothing; the text block drops it for the same reason.\n if (summary.name !== undefined && summary.name !== 'Error') {\n payload.name = summary.name;\n }\n\n for (const key of this.DIAGNOSTIC_KEYS) {\n if (summary[key] !== undefined) {\n payload[key] = summary[key];\n }\n }\n\n const context = extra ?? summary.extra;\n if (context !== undefined && Object.keys(context).length > 0) {\n payload.extra = RedactUtility.redactSecrets({ value: context });\n }\n\n if (summary.cause !== undefined) {\n payload.cause = summary.cause;\n }\n\n if (summary.errors !== undefined) {\n payload.errors = summary.errors;\n }\n\n // An ARRAY, not the newline-joined string `text` prints: a monitor can count and slice frames.\n if (summary.stack !== undefined) {\n payload.stack = summary.stack.split('\\n').map((frame) => frame.trim());\n }\n\n return this.safeStringify(payload);\n }\n\n private static renderText(opts: {\n summary: IErrorSummary;\n messageCode?: string;\n extra?: Record<string, unknown>;\n inspectOptions: util.InspectOptions;\n }): string {\n const { summary, messageCode, extra, inspectOptions } = opts;\n\n const lines: Array<string> = [];\n\n // What happened, then why, then who/where - a reader stops as soon as they have the answer.\n if (summary.message !== undefined) {\n lines.push(`message: ${summary.message}`);\n }\n\n // Straight after the message: the reader is looking at `%{field}` and needs the value now, not below the stack.\n if (summary.args !== undefined) {\n lines.push(\n `args: ${util.inspect(RedactUtility.redactSecrets({ value: summary.args }), inspectOptions)}`,\n );\n }\n\n this.pushAggregatedErrors({ node: summary, lines });\n\n let cause = summary.cause;\n while (cause !== undefined) {\n const causeCode = cause.code ?? cause.messageCode;\n const code = causeCode === undefined ? '' : ` (code ${causeCode})`;\n lines.push(`cause: ${cause.message ?? ''}${code}`);\n this.pushDiagnostics({ node: cause, lines });\n this.pushAggregatedErrors({ node: cause, lines });\n cause = cause.cause;\n }\n\n const identity = [summary.name, summary.code === undefined ? '' : `(code ${summary.code})`]\n .filter(Boolean)\n .join(' ');\n\n // A bare `name: Error` says nothing; keep the line only when it is specific or carries a code.\n if (identity !== '' && identity !== 'Error') {\n lines.push(`name: ${identity}`);\n }\n\n // The caller's code wins; otherwise the error's own, so a direct log call keeps its identifier too.\n const code =\n messageCode !== undefined && messageCode !== '' ? messageCode : summary.messageCode;\n if (code !== undefined) {\n lines.push(`code: ${code}`);\n }\n\n this.pushDiagnostics({ node: summary, lines });\n\n // An explicit `extra` wins; otherwise fall back to the one the error carries itself.\n const context = extra ?? summary.extra;\n\n if (context !== undefined && Object.keys(context).length > 0) {\n lines.push(\n `extra: ${util.inspect(RedactUtility.redactSecrets({ value: context }), inspectOptions)}`,\n );\n }\n\n if (summary.stack !== undefined) {\n lines.push(`stack:\\n${summary.stack}`);\n }\n\n return lines.map((line) => `- ${line}`).join('\\n');\n }\n\n /** Renders {@link summarize}. `text` returns a block whose newlines survive `%s`; `json` returns one line. */\n static format(opts: {\n error: unknown;\n messageCode?: string;\n extra?: Record<string, unknown>;\n includeStack?: boolean;\n maxStackFrames?: number;\n format?: TLoggerFormat;\n inspectOptions?: util.InspectOptions;\n }): string {\n const {\n error,\n messageCode,\n extra,\n includeStack = true,\n maxStackFrames,\n format,\n inspectOptions = this.INSPECT_OPTIONS,\n } = opts;\n\n const summary = this.summarize({ error, includeStack, maxStackFrames });\n\n if (this.resolveFormat(format) === LoggerFormats.JSON) {\n return this.renderJson({ summary, messageCode, extra });\n }\n\n return this.renderText({ summary, messageCode, extra, inspectOptions });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/hf/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,KAAK,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAkBtF,4KAA4K;AAC5K,qBAAa,QAAS,SAAQ,cAAc;IAC1C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACxD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAiC;IACnE,OAAO,CAAC,MAAM,CAAC,KAAK,CAA+B;IACnD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAiC;IAE5D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAElC,OAAO;IAQP,OAAO,CAAC,MAAM,CAAC,WAAW;IAS1B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IASnC,6HAA6H;IAC7H,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU;IAcjD,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAQjC,OAAO,CAAC,UAAU;IAoBlB,OAAO,CAAC,WAAW;IASnB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAOhD,I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AAC,QAAQ,CAAC,IAAI,CAAa;IAElC,OAAO;IAQP,OAAO,CAAC,MAAM,CAAC,WAAW;IAS1B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IASnC,6HAA6H;IAC7H,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU;IAcjD,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAQjC,OAAO,CAAC,UAAU;IAoBlB,OAAO,CAAC,WAAW;IAYnB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAOhD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI/C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI/C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAIhD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAIhD,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAChE,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,GAAG,IAAI;IAerD,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAGjC"}
@@ -1,6 +1,6 @@
1
1
  import { AbstractLogger } from '../base/index.js';
2
2
  import { LogLevels, SHOULD_LOG_DEBUG } from '../common/index.js';
3
- import { formatLogMessage } from '../formatting/index.js';
3
+ import { LogFormatUtility } from '../formatting/index.js';
4
4
  import { BUFFER_SIZE, ENTRY_SIZE, HF_LEVEL_CODES, HF_MESSAGE_MAX_BYTES, HF_SCOPE_MAX_BYTES, MESSAGE_CACHE_CAP, OFFSET_LEVEL, OFFSET_MESSAGE, OFFSET_MESSAGE_LENGTH, OFFSET_SCOPE, OFFSET_SCOPE_LENGTH, } from './common/index.js';
5
5
  import { HfLogRing } from './ring.js';
6
6
  /** Ring-buffer logger for hot paths; extends AbstractLogger, NOT BaseLogger - BaseLogger's string-sink plumbing is exactly the cost this implementation exists to avoid. */
@@ -70,7 +70,7 @@ export class HfLogger extends AbstractLogger {
70
70
  writeString(levelCode, message, args) {
71
71
  if (args.length > 0) {
72
72
  // Slow path, documented: args are formatted (deep inspection + redaction) - never dropped.
73
- this.writeEntry(levelCode, HfLogger.textEncoder.encode(formatLogMessage({ message, args })));
73
+ this.writeEntry(levelCode, HfLogger.textEncoder.encode(LogFormatUtility.formatMessage({ message, args })));
74
74
  return;
75
75
  }
76
76
  this.writeEntry(levelCode, HfLogger.encodeMessage(message));
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../../src/modules/logger/hf/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAgB,SAAS,EAAE,gBAAgB,EAAkB,MAAM,WAAW,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,GAEpB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,4KAA4K;AAC5K,MAAM,OAAO,QAAS,SAAQ,cAAc;aAClB,gBAAW,GAAG,IAAI,WAAW,EAAE,CAAC;aAChC,eAAU,GAAG,IAAI,GAAG,EAAsB,CAAC;aACpD,UAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;aACpC,iBAAY,GAAG,IAAI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e,EAAE,GAAG,IAAe;QACvC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IAID,GAAG,CAAC,KAAgB,EAAE,OAA4B,EAAE,GAAG,IAAe;QACpE,IAAI,KAAK,KAAK,SAAS,CAAC,KAAK,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACnD,OAAO;QACT,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,KAAK,CAAC;YACpD,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC;YACvB,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC;QACxB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAC3C,OAAO;QACT,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,GAAG,CAAC,UAAkB;QACpB,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,UAAU,EAAE,CAAC,CAAC;IACrD,CAAC","sourcesContent":["import { type AnyType } from '@/common/types';\nimport { AbstractLogger } from '../base';\nimport { type ILogger, LogLevels, SHOULD_LOG_DEBUG, type TLogLevel } from '../common';\nimport { formatLogMessage } from '../formatting';\nimport {\n BUFFER_SIZE,\n ENTRY_SIZE,\n HF_LEVEL_CODES,\n HF_MESSAGE_MAX_BYTES,\n HF_SCOPE_MAX_BYTES,\n MESSAGE_CACHE_CAP,\n OFFSET_LEVEL,\n OFFSET_MESSAGE,\n OFFSET_MESSAGE_LENGTH,\n OFFSET_SCOPE,\n OFFSET_SCOPE_LENGTH,\n type TRingState,\n} from './common';\nimport { HfLogRing } from './ring';\n\n/** Ring-buffer logger for hot paths; extends AbstractLogger, NOT BaseLogger - BaseLogger's string-sink plumbing is exactly the cost this implementation exists to avoid. */\nexport class HfLogger extends AbstractLogger {\n private static readonly textEncoder = new TextEncoder();\n private static readonly scopeCache = new Map<string, Uint8Array>();\n private static cache = new Map<string, HfLogger>();\n private static messageCache = new Map<string, Uint8Array>();\n\n private readonly scope: string;\n private readonly scopeBytes: Uint8Array;\n private readonly scopeLength: number;\n // Resolved once at construction (get() has already allocated the ring): saves a call and a null-check per log on a path budgeted in nanoseconds.\n private readonly ring: TRingState;\n\n private constructor(scope: string) {\n super();\n this.scope = scope;\n this.scopeBytes = HfLogger.encodeScope(scope);\n this.scopeLength = this.scopeBytes.length;\n this.ring = HfLogRing.get();\n }\n\n private static encodeScope(scope: string): Uint8Array {\n let bytes = HfLogger.scopeCache.get(scope);\n if (!bytes) {\n bytes = HfLogger.textEncoder.encode(scope).subarray(0, HF_SCOPE_MAX_BYTES);\n HfLogger.scopeCache.set(scope, bytes);\n }\n return bytes;\n }\n\n static get(scope: string): HfLogger {\n let logger = this.cache.get(scope);\n if (!logger) {\n logger = new HfLogger(scope); // first logger allocates the ring - never at import\n this.cache.set(scope, logger);\n }\n return logger;\n }\n\n /** Pre-encode a message at initialization time; the cache is FIFO-bounded so dynamic strings can't grow it without limit. */\n static encodeMessage(message: string): Uint8Array {\n const cached = this.messageCache.get(message);\n if (cached) {\n return cached;\n }\n\n const bytes = HfLogger.textEncoder.encode(message);\n if (this.messageCache.size >= MESSAGE_CACHE_CAP) {\n this.evictOldestMessage();\n }\n this.messageCache.set(message, bytes);\n return bytes;\n }\n\n private static evictOldestMessage(): void {\n const oldest = this.messageCache.keys().next().value;\n if (oldest === undefined) {\n return;\n }\n this.messageCache.delete(oldest);\n }\n\n private writeEntry(levelCode: number, messageBytes: Uint8Array): void {\n const ring = this.ring;\n const slot = ring.writeIndex++ & (BUFFER_SIZE - 1);\n const offset = slot * ENTRY_SIZE;\n ring.f64[offset >> 3] = performance.timeOrigin + performance.now();\n const bytes = ring.bytes;\n bytes[offset + OFFSET_LEVEL] = levelCode;\n bytes[offset + OFFSET_SCOPE_LENGTH] = this.scopeLength;\n bytes.set(this.scopeBytes, offset + OFFSET_SCOPE);\n const messageLength =\n messageBytes.length < HF_MESSAGE_MAX_BYTES ? messageBytes.length : HF_MESSAGE_MAX_BYTES;\n bytes[offset + OFFSET_MESSAGE_LENGTH] = messageLength;\n bytes.set(\n messageLength === messageBytes.length\n ? messageBytes\n : messageBytes.subarray(0, messageLength),\n offset + OFFSET_MESSAGE,\n );\n }\n\n private writeString(levelCode: number, message: string, args: Array<AnyType>): void {\n if (args.length > 0) {\n // Slow path, documented: args are formatted (deep inspection + redaction) - never dropped.\n this.writeEntry(levelCode, HfLogger.textEncoder.encode(formatLogMessage({ message, args })));\n return;\n }\n this.writeEntry(levelCode, HfLogger.encodeMessage(message));\n }\n\n debug(message: string, ...args: AnyType[]): void {\n if (!SHOULD_LOG_DEBUG) {\n return;\n }\n this.writeString(HF_LEVEL_CODES.debug, message, args);\n }\n\n info(message: string, ...args: AnyType[]): void {\n this.writeString(HF_LEVEL_CODES.info, message, args);\n }\n\n warn(message: string, ...args: AnyType[]): void {\n this.writeString(HF_LEVEL_CODES.warn, message, args);\n }\n\n error(message: string, ...args: AnyType[]): void {\n this.writeString(HF_LEVEL_CODES.error, message, args);\n }\n\n emerg(message: string, ...args: AnyType[]): void {\n this.writeString(HF_LEVEL_CODES.emerg, message, args);\n }\n\n log(level: TLogLevel, message: string, ...args: AnyType[]): void;\n log(level: TLogLevel, messageBytes: Uint8Array): void;\n log(level: TLogLevel, message: string | Uint8Array, ...args: AnyType[]): void {\n if (level === LogLevels.DEBUG && !SHOULD_LOG_DEBUG) {\n return;\n }\n const levelCode = Object.hasOwn(HF_LEVEL_CODES, level)\n ? HF_LEVEL_CODES[level]\n : HF_LEVEL_CODES.info;\n if (typeof message === 'string') {\n this.writeString(levelCode, message, args);\n return;\n }\n this.writeEntry(levelCode, message);\n }\n\n for(methodName: string): ILogger {\n return HfLogger.get(`${this.scope}-${methodName}`);\n }\n}\n"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../../src/modules/logger/hf/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAgB,SAAS,EAAE,gBAAgB,EAAkB,MAAM,WAAW,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,GAEpB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,4KAA4K;AAC5K,MAAM,OAAO,QAAS,SAAQ,cAAc;aAClB,gBAAW,GAAG,IAAI,WAAW,EAAE,CAAC;aAChC,eAAU,GAAG,IAAI,GAAG,EAAsB,CAAC;aACpD,UAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;aACpC,iBAAY,GAAG,IAAI,GAAG,EAAsB,CAAC;IAQ5D,YAAoB,KAAa;QAC/B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC;IAC9B,CAAC;IAEO,MAAM,CAAC,WAAW,CAAC,KAAa;QACtC,IAAI,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,GAA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C;QACD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,KAAK,CAAC;YACpD,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC;YACvB,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC;QACxB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAC3C,OAAO;QACT,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,GAAG,CAAC,UAAkB;QACpB,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,UAAU,EAAE,CAAC,CAAC;IACrD,CAAC","sourcesContent":["import { type AnyType } from '@/common/types';\nimport { AbstractLogger } from '../base';\nimport { type ILogger, LogLevels, SHOULD_LOG_DEBUG, type TLogLevel } from '../common';\nimport { LogFormatUtility } from '../formatting';\nimport {\n BUFFER_SIZE,\n ENTRY_SIZE,\n HF_LEVEL_CODES,\n HF_MESSAGE_MAX_BYTES,\n HF_SCOPE_MAX_BYTES,\n MESSAGE_CACHE_CAP,\n OFFSET_LEVEL,\n OFFSET_MESSAGE,\n OFFSET_MESSAGE_LENGTH,\n OFFSET_SCOPE,\n OFFSET_SCOPE_LENGTH,\n type TRingState,\n} from './common';\nimport { HfLogRing } from './ring';\n\n/** Ring-buffer logger for hot paths; extends AbstractLogger, NOT BaseLogger - BaseLogger's string-sink plumbing is exactly the cost this implementation exists to avoid. */\nexport class HfLogger extends AbstractLogger {\n private static readonly textEncoder = new TextEncoder();\n private static readonly scopeCache = new Map<string, Uint8Array>();\n private static cache = new Map<string, HfLogger>();\n private static messageCache = new Map<string, Uint8Array>();\n\n private readonly scope: string;\n private readonly scopeBytes: Uint8Array;\n private readonly scopeLength: number;\n // Resolved once at construction (get() has already allocated the ring): saves a call and a null-check per log on a path budgeted in nanoseconds.\n private readonly ring: TRingState;\n\n private constructor(scope: string) {\n super();\n this.scope = scope;\n this.scopeBytes = HfLogger.encodeScope(scope);\n this.scopeLength = this.scopeBytes.length;\n this.ring = HfLogRing.get();\n }\n\n private static encodeScope(scope: string): Uint8Array {\n let bytes = HfLogger.scopeCache.get(scope);\n if (!bytes) {\n bytes = HfLogger.textEncoder.encode(scope).subarray(0, HF_SCOPE_MAX_BYTES);\n HfLogger.scopeCache.set(scope, bytes);\n }\n return bytes;\n }\n\n static get(scope: string): HfLogger {\n let logger = this.cache.get(scope);\n if (!logger) {\n logger = new HfLogger(scope); // first logger allocates the ring - never at import\n this.cache.set(scope, logger);\n }\n return logger;\n }\n\n /** Pre-encode a message at initialization time; the cache is FIFO-bounded so dynamic strings can't grow it without limit. */\n static encodeMessage(message: string): Uint8Array {\n const cached = this.messageCache.get(message);\n if (cached) {\n return cached;\n }\n\n const bytes = HfLogger.textEncoder.encode(message);\n if (this.messageCache.size >= MESSAGE_CACHE_CAP) {\n this.evictOldestMessage();\n }\n this.messageCache.set(message, bytes);\n return bytes;\n }\n\n private static evictOldestMessage(): void {\n const oldest = this.messageCache.keys().next().value;\n if (oldest === undefined) {\n return;\n }\n this.messageCache.delete(oldest);\n }\n\n private writeEntry(levelCode: number, messageBytes: Uint8Array): void {\n const ring = this.ring;\n const slot = ring.writeIndex++ & (BUFFER_SIZE - 1);\n const offset = slot * ENTRY_SIZE;\n ring.f64[offset >> 3] = performance.timeOrigin + performance.now();\n const bytes = ring.bytes;\n bytes[offset + OFFSET_LEVEL] = levelCode;\n bytes[offset + OFFSET_SCOPE_LENGTH] = this.scopeLength;\n bytes.set(this.scopeBytes, offset + OFFSET_SCOPE);\n const messageLength =\n messageBytes.length < HF_MESSAGE_MAX_BYTES ? messageBytes.length : HF_MESSAGE_MAX_BYTES;\n bytes[offset + OFFSET_MESSAGE_LENGTH] = messageLength;\n bytes.set(\n messageLength === messageBytes.length\n ? messageBytes\n : messageBytes.subarray(0, messageLength),\n offset + OFFSET_MESSAGE,\n );\n }\n\n private writeString(levelCode: number, message: string, args: Array<AnyType>): void {\n if (args.length > 0) {\n // Slow path, documented: args are formatted (deep inspection + redaction) - never dropped.\n this.writeEntry(\n levelCode,\n HfLogger.textEncoder.encode(LogFormatUtility.formatMessage({ message, args })),\n );\n return;\n }\n this.writeEntry(levelCode, HfLogger.encodeMessage(message));\n }\n\n debug(message: string, ...args: AnyType[]): void {\n if (!SHOULD_LOG_DEBUG) {\n return;\n }\n this.writeString(HF_LEVEL_CODES.debug, message, args);\n }\n\n info(message: string, ...args: AnyType[]): void {\n this.writeString(HF_LEVEL_CODES.info, message, args);\n }\n\n warn(message: string, ...args: AnyType[]): void {\n this.writeString(HF_LEVEL_CODES.warn, message, args);\n }\n\n error(message: string, ...args: AnyType[]): void {\n this.writeString(HF_LEVEL_CODES.error, message, args);\n }\n\n emerg(message: string, ...args: AnyType[]): void {\n this.writeString(HF_LEVEL_CODES.emerg, message, args);\n }\n\n log(level: TLogLevel, message: string, ...args: AnyType[]): void;\n log(level: TLogLevel, messageBytes: Uint8Array): void;\n log(level: TLogLevel, message: string | Uint8Array, ...args: AnyType[]): void {\n if (level === LogLevels.DEBUG && !SHOULD_LOG_DEBUG) {\n return;\n }\n const levelCode = Object.hasOwn(HF_LEVEL_CODES, level)\n ? HF_LEVEL_CODES[level]\n : HF_LEVEL_CODES.info;\n if (typeof message === 'string') {\n this.writeString(levelCode, message, args);\n return;\n }\n this.writeEntry(levelCode, message);\n }\n\n for(methodName: string): ILogger {\n return HfLogger.get(`${this.scope}-${methodName}`);\n }\n}\n"]}
@@ -18,13 +18,4 @@ export declare class PinoBackingLogger {
18
18
  }): void;
19
19
  private static closeTransport;
20
20
  }
21
- export declare const buildPinoOptions: () => {
22
- name: string;
23
- level: import("../index.js").TLogLevel;
24
- customLevels: Record<"emerg", number>;
25
- };
26
- export declare const getPinoBackingLogger: () => TPinoInstance;
27
- export declare const setPinoBackingLogger: (opts: {
28
- instance: TPinoInstance;
29
- }) => void;
30
21
  //# sourceMappingURL=backing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"backing.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/backing.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAGlE,oGAAoG;AACpG,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA4B;IACnD,6NAA6N;IAC7N,OAAO,CAAC,MAAM,CAAC,SAAS,CAAqC;IAE7D,8KAA8K;IAC9K,MAAM,CAAC,YAAY;;;;;IAQnB,sQAAsQ;IACtQ,MAAM,CAAC,GAAG,IAAI,aAAa;IAY3B,4QAA4Q;IAC5Q,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,aAAa,CAAA;KAAE,GAAG,IAAI;IAUnD,OAAO,CAAC,MAAM,CAAC,cAAc;CAW9B;AAID,eAAO,MAAM,gBAAgB;;;;CAAyC,CAAC;AAEvE,eAAO,MAAM,oBAAoB,QAAO,aAAwC,CAAC;AAEjF,eAAO,MAAM,oBAAoB,GAAI,MAAM;IAAE,QAAQ,EAAE,aAAa,CAAA;CAAE,KAAG,IAC5C,CAAC"}
1
+ {"version":3,"file":"backing.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/backing.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAGlE,oGAAoG;AACpG,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA4B;IACnD,6NAA6N;IAC7N,OAAO,CAAC,MAAM,CAAC,SAAS,CAAqC;IAE7D,8KAA8K;IAC9K,MAAM,CAAC,YAAY;;;;;IAQnB,sQAAsQ;IACtQ,MAAM,CAAC,GAAG,IAAI,aAAa;IAY3B,4QAA4Q;IAC5Q,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,aAAa,CAAA;KAAE,GAAG,IAAI;IAUnD,OAAO,CAAC,MAAM,CAAC,cAAc;CAW9B"}
@@ -1,6 +1,6 @@
1
1
  import { Defaults } from '../../../common/constants/index.js';
2
2
  import pino from 'pino';
3
- import { resolveLoggerLevel } from '../common/index.js';
3
+ import { LoggerConfigUtility } from '../common/index.js';
4
4
  import { PINO_CUSTOM_LEVELS } from './common/index.js';
5
5
  import { PinoDestination } from './destination.js';
6
6
  /** Owns the single pino instance every scope writes through, and the transport thread behind it. */
@@ -9,14 +9,14 @@ export class PinoBackingLogger {
9
9
  static buildOptions() {
10
10
  return {
11
11
  name: Defaults.APPLICATION_NAME,
12
- level: resolveLoggerLevel({ configured: process.env.APP_ENV_LOGGER_LEVEL }),
12
+ level: LoggerConfigUtility.resolveLevel({ configured: process.env.APP_ENV_LOGGER_LEVEL }),
13
13
  customLevels: PINO_CUSTOM_LEVELS,
14
14
  };
15
15
  }
16
16
  /** Lazy, env-driven singleton, built once and reused by every scope entirely synchronously - the very first log line already targets the real env-configured destination, no stdout bootstrap. `set()` is the only way to replace it; this getter never resets it. */
17
17
  static get() {
18
18
  if (!PinoBackingLogger.instance) {
19
- const destination = PinoDestination.build(PinoDestination.resolvePlan());
19
+ const destination = PinoDestination.build({ plan: PinoDestination.resolvePlan() });
20
20
  PinoBackingLogger.instance = pino(PinoBackingLogger.buildOptions(), destination);
21
21
  PinoBackingLogger.transport = destination;
22
22
  }
@@ -43,9 +43,4 @@ export class PinoBackingLogger {
43
43
  }
44
44
  }
45
45
  }
46
- // Published names, kept so `@venizia/ignis-helpers/pino` consumers do not have to move; the class
47
- // above is the implementation and the entry point for new code.
48
- export const buildPinoOptions = () => PinoBackingLogger.buildOptions();
49
- export const getPinoBackingLogger = () => PinoBackingLogger.get();
50
- export const setPinoBackingLogger = (opts) => PinoBackingLogger.set(opts);
51
46
  //# sourceMappingURL=backing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"backing.js","sourceRoot":"","sources":["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GAAG,SAAS,CAAC;IAC1C,CAAC;IAEO,MAAM,CAAC,cAAc;QAC3B,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACF,iBAAiB,CAAC,SAAqB,CAAC,GAAG,EAAE,CAAC;QACjD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,kEAAkE,EAAE,KAAK,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;CACF;AAED,kGAAkG;AAClG,gEAAgE;AAChE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC;AAEvE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAkB,EAAE,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;AAEjF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAiC,EAAQ,EAAE,CAC9E,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import { Defaults } from '@/common/constants';\nimport { type AnyType } from '@/common/types';\nimport pino from 'pino';\nimport { resolveLoggerLevel } from '../common';\n\nimport { PINO_CUSTOM_LEVELS, type TPinoInstance } from './common';\nimport { PinoDestination } from './destination';\n\n/** Owns the single pino instance every scope writes through, and the transport thread behind it. */\nexport class PinoBackingLogger {\n private static instance: TPinoInstance | undefined;\n /** The `ThreadStream` behind `instance`, held ONLY when built via a transport (pretty/roll) and `undefined` for `stdout` or an injected instance - tracked so a replacement can close the worker instead of orphaning it. */\n private static transport: pino.DestinationStream | undefined;\n\n /** Pure: pino constructor options derived from env at CALL time. Public so tests can build a REAL instance against an in-memory destination, without the impure singleton. */\n static buildOptions() {\n return {\n name: Defaults.APPLICATION_NAME,\n level: resolveLoggerLevel({ configured: process.env.APP_ENV_LOGGER_LEVEL }),\n customLevels: PINO_CUSTOM_LEVELS,\n };\n }\n\n /** Lazy, env-driven singleton, built once and reused by every scope entirely synchronously - the very first log line already targets the real env-configured destination, no stdout bootstrap. `set()` is the only way to replace it; this getter never resets it. */\n static get(): TPinoInstance {\n if (!PinoBackingLogger.instance) {\n const destination = PinoDestination.build(PinoDestination.resolvePlan());\n PinoBackingLogger.instance = pino(\n PinoBackingLogger.buildOptions(),\n destination,\n ) as TPinoInstance;\n PinoBackingLogger.transport = destination;\n }\n return PinoBackingLogger.instance;\n }\n\n /** Replaces the singleton outright: an outgoing transport-backed instance (pretty/roll) is a `ThreadStream` on a live worker thread, so this flushes then `.end()`s it first rather than orphaning the worker; failures are logged via `console.error`, never swallowed. */\n static set(opts: { instance: TPinoInstance }): void {\n if (PinoBackingLogger.instance) {\n PinoBackingLogger.instance.flush();\n PinoBackingLogger.closeTransport();\n }\n\n PinoBackingLogger.instance = opts.instance;\n PinoBackingLogger.transport = undefined;\n }\n\n private static closeTransport(): void {\n if (!PinoBackingLogger.transport) {\n return;\n }\n\n try {\n (PinoBackingLogger.transport as AnyType).end();\n } catch (error) {\n console.error('[setPinoBackingLogger] Failed to close previous transport stream', error);\n }\n }\n}\n\n// Published names, kept so `@venizia/ignis-helpers/pino` consumers do not have to move; the class\n// above is the implementation and the entry point for new code.\nexport const buildPinoOptions = () => PinoBackingLogger.buildOptions();\n\nexport const getPinoBackingLogger = (): TPinoInstance => PinoBackingLogger.get();\n\nexport const setPinoBackingLogger = (opts: { instance: TPinoInstance }): void =>\n PinoBackingLogger.set(opts);\n"]}
1
+ {"version":3,"file":"backing.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/backing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAsB,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CA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,OAAO,CAAC,KAAK,CAAC,kEAAkE,EAAE,KAAK,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;CACF","sourcesContent":["import { Defaults } from '@/common/constants';\nimport { type AnyType } from '@/common/types';\nimport pino from 'pino';\nimport { LoggerConfigUtility } from '../common';\n\nimport { PINO_CUSTOM_LEVELS, type TPinoInstance } from './common';\nimport { PinoDestination } from './destination';\n\n/** Owns the single pino instance every scope writes through, and the transport thread behind it. */\nexport class PinoBackingLogger {\n private static instance: TPinoInstance | undefined;\n /** The `ThreadStream` behind `instance`, held ONLY when built via a transport (pretty/roll) and `undefined` for `stdout` or an injected instance - tracked so a replacement can close the worker instead of orphaning it. */\n private static transport: pino.DestinationStream | undefined;\n\n /** Pure: pino constructor options derived from env at CALL time. Public so tests can build a REAL instance against an in-memory destination, without the impure singleton. */\n static buildOptions() {\n return {\n name: Defaults.APPLICATION_NAME,\n level: LoggerConfigUtility.resolveLevel({ configured: process.env.APP_ENV_LOGGER_LEVEL }),\n customLevels: PINO_CUSTOM_LEVELS,\n };\n }\n\n /** Lazy, env-driven singleton, built once and reused by every scope entirely synchronously - the very first log line already targets the real env-configured destination, no stdout bootstrap. `set()` is the only way to replace it; this getter never resets it. */\n static get(): TPinoInstance {\n if (!PinoBackingLogger.instance) {\n const destination = PinoDestination.build({ plan: PinoDestination.resolvePlan() });\n PinoBackingLogger.instance = pino(\n PinoBackingLogger.buildOptions(),\n destination,\n ) as TPinoInstance;\n PinoBackingLogger.transport = destination;\n }\n return PinoBackingLogger.instance;\n }\n\n /** Replaces the singleton outright: an outgoing transport-backed instance (pretty/roll) is a `ThreadStream` on a live worker thread, so this flushes then `.end()`s it first rather than orphaning the worker; failures are logged via `console.error`, never swallowed. */\n static set(opts: { instance: TPinoInstance }): void {\n if (PinoBackingLogger.instance) {\n PinoBackingLogger.instance.flush();\n PinoBackingLogger.closeTransport();\n }\n\n PinoBackingLogger.instance = opts.instance;\n PinoBackingLogger.transport = undefined;\n }\n\n private static closeTransport(): void {\n if (!PinoBackingLogger.transport) {\n return;\n }\n\n try {\n (PinoBackingLogger.transport as AnyType).end();\n } catch (error) {\n console.error('[setPinoBackingLogger] Failed to close previous transport stream', error);\n }\n }\n}\n"]}
@@ -22,7 +22,9 @@ export declare class PinoDestination {
22
22
  private static readonly DEFAULT_FREQUENCY;
23
23
  private static readonly DEFAULT_MAX_FILES;
24
24
  /** `APP_ENV_LOGGER_FILE_FREQUENCY` -> pino-roll's `frequency`; an unrecognized value warns and falls back rather than throwing, so the app still boots. */
25
- static mapFrequency(value?: string): TFrequency;
25
+ static mapFrequency(opts: {
26
+ value?: string;
27
+ }): TFrequency;
26
28
  /** `null` means "not a recognized shape" - the caller decides what default to fall back to. */
27
29
  private static parseMaxFilesValue;
28
30
  /** `APP_ENV_LOGGER_FILE_MAX_FILES` -> pino-roll's `limit.count`: `'<n>d'` scales by frequency (hourly: days*24), a bare integer is a literal count, unrecognized falls back to `'5d'`. */
@@ -33,13 +35,8 @@ export declare class PinoDestination {
33
35
  /** Pure: which destination pino should write to, derived from `APP_ENV_LOGGER_*` at CALL time. `DATE_PATTERN` is deliberately not read - pino-roll has no equivalent. */
34
36
  static resolvePlan(): TDestinationPlan;
35
37
  /** `pino.transport()` is SYNCHRONOUS - it returns a `ThreadStream` that BUFFERS writes until its worker thread loads, so no async gating is needed; `ModuleUtility.assertInstalled` runs first so a missing optional peer fails loudly here, not as an opaque worker-thread crash. */
36
- static build(plan: TDestinationPlan): pino.DestinationStream | undefined;
38
+ static build(opts: {
39
+ plan: TDestinationPlan;
40
+ }): pino.DestinationStream | undefined;
37
41
  }
38
- export declare const mapFrequency: (value?: string) => TFrequency;
39
- export declare const mapMaxFilesToCount: (opts: {
40
- value?: string;
41
- frequency: TFrequency;
42
- }) => number;
43
- export declare const resolveDestinationPlan: () => TDestinationPlan;
44
- export declare const buildDestination: (plan: TDestinationPlan) => pino.DestinationStream | undefined;
45
42
  //# sourceMappingURL=destination.d.ts.map