@venizia/ignis-helpers 0.4.7-0 → 0.4.7-2

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 (311) hide show
  1. package/LICENSE.md +1 -3
  2. package/README.md +7 -8
  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 +5 -3
  12. package/dist/esm/core.d.ts.map +1 -1
  13. package/dist/esm/core.js +7 -3
  14. package/dist/esm/core.js.map +1 -1
  15. package/dist/esm/modules/base.d.ts +1 -1
  16. package/dist/esm/modules/base.d.ts.map +1 -1
  17. package/dist/esm/modules/base.js +14 -5
  18. package/dist/esm/modules/base.js.map +1 -1
  19. package/dist/esm/modules/cron/helper.js +4 -4
  20. package/dist/esm/modules/cron/helper.js.map +1 -1
  21. package/dist/esm/modules/crypto/algorithms/aes-legacy.algorithm.js +3 -3
  22. package/dist/esm/modules/crypto/algorithms/aes-legacy.algorithm.js.map +1 -1
  23. package/dist/esm/modules/crypto/algorithms/aes.algorithm.js +5 -5
  24. package/dist/esm/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
  25. package/dist/esm/modules/crypto/algorithms/base.algorithm.js +3 -3
  26. package/dist/esm/modules/crypto/algorithms/base.algorithm.js.map +1 -1
  27. package/dist/esm/modules/crypto/algorithms/hash.algorithm.d.ts +15 -5
  28. package/dist/esm/modules/crypto/algorithms/hash.algorithm.d.ts.map +1 -1
  29. package/dist/esm/modules/crypto/algorithms/hash.algorithm.js +16 -4
  30. package/dist/esm/modules/crypto/algorithms/hash.algorithm.js.map +1 -1
  31. package/dist/esm/modules/env/app-env.d.ts.map +1 -1
  32. package/dist/esm/modules/env/app-env.js +2 -2
  33. package/dist/esm/modules/env/app-env.js.map +1 -1
  34. package/dist/esm/modules/logger/base/base.d.ts.map +1 -1
  35. package/dist/esm/modules/logger/base/base.js +3 -3
  36. package/dist/esm/modules/logger/base/base.js.map +1 -1
  37. package/dist/esm/modules/logger/base/console.d.ts +9 -4
  38. package/dist/esm/modules/logger/base/console.d.ts.map +1 -1
  39. package/dist/esm/modules/logger/base/console.js +15 -4
  40. package/dist/esm/modules/logger/base/console.js.map +1 -1
  41. package/dist/esm/modules/logger/common/constants.d.ts +23 -22
  42. package/dist/esm/modules/logger/common/constants.d.ts.map +1 -1
  43. package/dist/esm/modules/logger/common/constants.js +43 -46
  44. package/dist/esm/modules/logger/common/constants.js.map +1 -1
  45. package/dist/esm/modules/logger/common/debug-gate.d.ts +33 -0
  46. package/dist/esm/modules/logger/common/debug-gate.d.ts.map +1 -0
  47. package/dist/esm/modules/logger/common/debug-gate.js +51 -0
  48. package/dist/esm/modules/logger/common/debug-gate.js.map +1 -0
  49. package/dist/esm/modules/logger/common/index.d.ts +1 -0
  50. package/dist/esm/modules/logger/common/index.d.ts.map +1 -1
  51. package/dist/esm/modules/logger/common/index.js +1 -0
  52. package/dist/esm/modules/logger/common/index.js.map +1 -1
  53. package/dist/esm/modules/logger/common/types.d.ts +7 -0
  54. package/dist/esm/modules/logger/common/types.d.ts.map +1 -1
  55. package/dist/esm/modules/logger/common/types.js +16 -0
  56. package/dist/esm/modules/logger/common/types.js.map +1 -1
  57. package/dist/esm/modules/logger/factory.d.ts +29 -10
  58. package/dist/esm/modules/logger/factory.d.ts.map +1 -1
  59. package/dist/esm/modules/logger/factory.js +108 -48
  60. package/dist/esm/modules/logger/factory.js.map +1 -1
  61. package/dist/esm/modules/logger/formatting/deep-splat.d.ts +10 -6
  62. package/dist/esm/modules/logger/formatting/deep-splat.d.ts.map +1 -1
  63. package/dist/esm/modules/logger/formatting/deep-splat.js +73 -62
  64. package/dist/esm/modules/logger/formatting/deep-splat.js.map +1 -1
  65. package/dist/esm/modules/logger/formatting/error-prettier.d.ts.map +1 -1
  66. package/dist/esm/modules/logger/formatting/error-prettier.js +8 -6
  67. package/dist/esm/modules/logger/formatting/error-prettier.js.map +1 -1
  68. package/dist/esm/modules/logger/hf/logger.d.ts.map +1 -1
  69. package/dist/esm/modules/logger/hf/logger.js +5 -5
  70. package/dist/esm/modules/logger/hf/logger.js.map +1 -1
  71. package/dist/esm/modules/logger/index.d.ts +0 -1
  72. package/dist/esm/modules/logger/index.d.ts.map +1 -1
  73. package/dist/esm/modules/logger/index.js +0 -1
  74. package/dist/esm/modules/logger/index.js.map +1 -1
  75. package/dist/esm/modules/logger/pino/backing.d.ts +0 -9
  76. package/dist/esm/modules/logger/pino/backing.d.ts.map +1 -1
  77. package/dist/esm/modules/logger/pino/backing.js +3 -8
  78. package/dist/esm/modules/logger/pino/backing.js.map +1 -1
  79. package/dist/esm/modules/logger/pino/destination.d.ts +6 -9
  80. package/dist/esm/modules/logger/pino/destination.d.ts.map +1 -1
  81. package/dist/esm/modules/logger/pino/destination.js +12 -13
  82. package/dist/esm/modules/logger/pino/destination.js.map +1 -1
  83. package/dist/esm/modules/logger/pino/logger.js +2 -2
  84. package/dist/esm/modules/logger/pino/logger.js.map +1 -1
  85. package/dist/esm/modules/logger/winston/common/constants.d.ts.map +1 -1
  86. package/dist/esm/modules/logger/winston/common/constants.js +7 -6
  87. package/dist/esm/modules/logger/winston/common/constants.js.map +1 -1
  88. package/dist/esm/modules/logger/winston/define.d.ts +0 -7
  89. package/dist/esm/modules/logger/winston/define.d.ts.map +1 -1
  90. package/dist/esm/modules/logger/winston/define.js +0 -5
  91. package/dist/esm/modules/logger/winston/define.js.map +1 -1
  92. package/dist/esm/modules/logger/winston/formats.d.ts +2 -0
  93. package/dist/esm/modules/logger/winston/formats.d.ts.map +1 -1
  94. package/dist/esm/modules/logger/winston/formats.js +17 -4
  95. package/dist/esm/modules/logger/winston/formats.js.map +1 -1
  96. package/dist/esm/modules/logger/winston/index.d.ts +3 -2
  97. package/dist/esm/modules/logger/winston/index.d.ts.map +1 -1
  98. package/dist/esm/modules/logger/winston/index.js +3 -2
  99. package/dist/esm/modules/logger/winston/index.js.map +1 -1
  100. package/dist/esm/modules/logger/winston/logger-factory.js +4 -4
  101. package/dist/esm/modules/logger/winston/logger-factory.js.map +1 -1
  102. package/dist/esm/modules/network/http-request/base-network-request.helper.js +2 -2
  103. package/dist/esm/modules/network/http-request/base-network-request.helper.js.map +1 -1
  104. package/dist/esm/modules/network/http-request/common/index.d.ts +0 -1
  105. package/dist/esm/modules/network/http-request/common/index.d.ts.map +1 -1
  106. package/dist/esm/modules/network/http-request/common/index.js +0 -1
  107. package/dist/esm/modules/network/http-request/common/index.js.map +1 -1
  108. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts.map +1 -1
  109. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js +4 -2
  110. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js.map +1 -1
  111. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts.map +1 -1
  112. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js +6 -4
  113. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js.map +1 -1
  114. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js +4 -4
  115. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js.map +1 -1
  116. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js +4 -4
  117. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
  118. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js +2 -2
  119. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js.map +1 -1
  120. package/dist/esm/modules/network/utilities/query-string.d.ts +22 -20
  121. package/dist/esm/modules/network/utilities/query-string.d.ts.map +1 -1
  122. package/dist/esm/modules/network/utilities/query-string.js +48 -46
  123. package/dist/esm/modules/network/utilities/query-string.js.map +1 -1
  124. package/dist/esm/modules/network/utilities/url-safety/common/errors.d.ts +0 -10
  125. package/dist/esm/modules/network/utilities/url-safety/common/errors.d.ts.map +1 -1
  126. package/dist/esm/modules/network/utilities/url-safety/common/errors.js +0 -11
  127. package/dist/esm/modules/network/utilities/url-safety/common/errors.js.map +1 -1
  128. package/dist/esm/modules/network/utilities/url-safety/policy.d.ts +10 -0
  129. package/dist/esm/modules/network/utilities/url-safety/policy.d.ts.map +1 -1
  130. package/dist/esm/modules/network/utilities/url-safety/policy.js +11 -0
  131. package/dist/esm/modules/network/utilities/url-safety/policy.js.map +1 -1
  132. package/dist/esm/modules/queue/bullmq/helper.d.ts.map +1 -1
  133. package/dist/esm/modules/queue/bullmq/helper.js +6 -6
  134. package/dist/esm/modules/queue/bullmq/helper.js.map +1 -1
  135. package/dist/esm/modules/queue/common/hook.d.ts +14 -12
  136. package/dist/esm/modules/queue/common/hook.d.ts.map +1 -1
  137. package/dist/esm/modules/queue/common/hook.js +21 -19
  138. package/dist/esm/modules/queue/common/hook.js.map +1 -1
  139. package/dist/esm/modules/queue/common/index.d.ts +0 -1
  140. package/dist/esm/modules/queue/common/index.d.ts.map +1 -1
  141. package/dist/esm/modules/queue/common/index.js +0 -1
  142. package/dist/esm/modules/queue/common/index.js.map +1 -1
  143. package/dist/esm/modules/queue/internal/sequential/helper.js +8 -8
  144. package/dist/esm/modules/queue/internal/sequential/helper.js.map +1 -1
  145. package/dist/esm/modules/queue/kafka/base.js +3 -3
  146. package/dist/esm/modules/queue/kafka/base.js.map +1 -1
  147. package/dist/esm/modules/queue/kafka/bundler/index.d.ts +0 -2
  148. package/dist/esm/modules/queue/kafka/bundler/index.d.ts.map +1 -1
  149. package/dist/esm/modules/queue/kafka/bundler/index.js +0 -2
  150. package/dist/esm/modules/queue/kafka/bundler/index.js.map +1 -1
  151. package/dist/esm/modules/queue/kafka/bundler/plugins.d.ts +8 -2
  152. package/dist/esm/modules/queue/kafka/bundler/plugins.d.ts.map +1 -1
  153. package/dist/esm/modules/queue/kafka/bundler/plugins.js +64 -7
  154. package/dist/esm/modules/queue/kafka/bundler/plugins.js.map +1 -1
  155. package/dist/esm/modules/queue/kafka/consumer.d.ts.map +1 -1
  156. package/dist/esm/modules/queue/kafka/consumer.js +22 -22
  157. package/dist/esm/modules/queue/kafka/consumer.js.map +1 -1
  158. package/dist/esm/modules/queue/mqtt/helper.js +10 -10
  159. package/dist/esm/modules/queue/mqtt/helper.js.map +1 -1
  160. package/dist/esm/modules/redis/base/abstract.helper.js +8 -8
  161. package/dist/esm/modules/redis/base/abstract.helper.js.map +1 -1
  162. package/dist/esm/modules/redis/cluster/cluster.helper.js +2 -2
  163. package/dist/esm/modules/redis/cluster/cluster.helper.js.map +1 -1
  164. package/dist/esm/modules/redis/factory.d.ts +13 -9
  165. package/dist/esm/modules/redis/factory.d.ts.map +1 -1
  166. package/dist/esm/modules/redis/factory.js +15 -13
  167. package/dist/esm/modules/redis/factory.js.map +1 -1
  168. package/dist/esm/modules/redis/sentinel/sentinel.helper.js +2 -2
  169. package/dist/esm/modules/redis/sentinel/sentinel.helper.js.map +1 -1
  170. package/dist/esm/modules/redis/single/single.helper.js +2 -2
  171. package/dist/esm/modules/redis/single/single.helper.js.map +1 -1
  172. package/dist/esm/modules/redis/utility.d.ts +13 -11
  173. package/dist/esm/modules/redis/utility.d.ts.map +1 -1
  174. package/dist/esm/modules/redis/utility.js +46 -44
  175. package/dist/esm/modules/redis/utility.js.map +1 -1
  176. package/dist/esm/modules/retry/helper.js +2 -2
  177. package/dist/esm/modules/retry/helper.js.map +1 -1
  178. package/dist/esm/modules/secrets/factory.d.ts +5 -3
  179. package/dist/esm/modules/secrets/factory.d.ts.map +1 -1
  180. package/dist/esm/modules/secrets/factory.js +36 -34
  181. package/dist/esm/modules/secrets/factory.js.map +1 -1
  182. package/dist/esm/modules/socket/socket-io/server/helper.d.ts.map +1 -1
  183. package/dist/esm/modules/socket/socket-io/server/helper.js +11 -11
  184. package/dist/esm/modules/socket/socket-io/server/helper.js.map +1 -1
  185. package/dist/esm/modules/socket/websocket/emitter/helper.d.ts.map +1 -1
  186. package/dist/esm/modules/socket/websocket/emitter/helper.js +3 -3
  187. package/dist/esm/modules/socket/websocket/emitter/helper.js.map +1 -1
  188. package/dist/esm/modules/socket/websocket/server/delivery.d.ts.map +1 -1
  189. package/dist/esm/modules/socket/websocket/server/delivery.js +5 -6
  190. package/dist/esm/modules/socket/websocket/server/delivery.js.map +1 -1
  191. package/dist/esm/modules/socket/websocket/server/helper.d.ts.map +1 -1
  192. package/dist/esm/modules/socket/websocket/server/helper.js +7 -7
  193. package/dist/esm/modules/socket/websocket/server/helper.js.map +1 -1
  194. package/dist/esm/modules/storage/base.js +7 -7
  195. package/dist/esm/modules/storage/base.js.map +1 -1
  196. package/dist/esm/modules/storage/bun-s3/helper.d.ts.map +1 -1
  197. package/dist/esm/modules/storage/bun-s3/helper.js +25 -18
  198. package/dist/esm/modules/storage/bun-s3/helper.js.map +1 -1
  199. package/dist/esm/modules/storage/bun-s3/utility.d.ts +95 -77
  200. package/dist/esm/modules/storage/bun-s3/utility.d.ts.map +1 -1
  201. package/dist/esm/modules/storage/bun-s3/utility.js +261 -239
  202. package/dist/esm/modules/storage/bun-s3/utility.js.map +1 -1
  203. package/dist/esm/modules/storage/common/errors.d.ts +0 -4
  204. package/dist/esm/modules/storage/common/errors.d.ts.map +1 -1
  205. package/dist/esm/modules/storage/common/errors.js +0 -10
  206. package/dist/esm/modules/storage/common/errors.js.map +1 -1
  207. package/dist/esm/modules/storage/common/utility.d.ts +11 -5
  208. package/dist/esm/modules/storage/common/utility.d.ts.map +1 -1
  209. package/dist/esm/modules/storage/common/utility.js +30 -17
  210. package/dist/esm/modules/storage/common/utility.js.map +1 -1
  211. package/dist/esm/modules/uid/uuid/helper.d.ts +1 -1
  212. package/dist/esm/modules/uid/uuid/helper.d.ts.map +1 -1
  213. package/dist/esm/modules/uid/uuid/helper.js +7 -7
  214. package/dist/esm/modules/uid/uuid/helper.js.map +1 -1
  215. package/dist/esm/modules/uid/uuid/v4.d.ts +11 -8
  216. package/dist/esm/modules/uid/uuid/v4.d.ts.map +1 -1
  217. package/dist/esm/modules/uid/uuid/v4.js +51 -46
  218. package/dist/esm/modules/uid/uuid/v4.js.map +1 -1
  219. package/dist/esm/modules/uid/uuid/v5.d.ts +17 -14
  220. package/dist/esm/modules/uid/uuid/v5.d.ts.map +1 -1
  221. package/dist/esm/modules/uid/uuid/v5.js +83 -78
  222. package/dist/esm/modules/uid/uuid/v5.js.map +1 -1
  223. package/dist/esm/modules/uid/uuid/v7.d.ts +15 -10
  224. package/dist/esm/modules/uid/uuid/v7.d.ts.map +1 -1
  225. package/dist/esm/modules/uid/uuid/v7.js +88 -79
  226. package/dist/esm/modules/uid/uuid/v7.js.map +1 -1
  227. package/dist/esm/modules/worker-thread/bus/base.js +2 -2
  228. package/dist/esm/modules/worker-thread/bus/base.js.map +1 -1
  229. package/dist/esm/modules/worker-thread/worker/base.d.ts.map +1 -1
  230. package/dist/esm/modules/worker-thread/worker/base.js +4 -3
  231. package/dist/esm/modules/worker-thread/worker/base.js.map +1 -1
  232. package/dist/esm/utilities/error.utility.d.ts +7 -0
  233. package/dist/esm/utilities/error.utility.d.ts.map +1 -0
  234. package/dist/esm/utilities/error.utility.js +9 -0
  235. package/dist/esm/utilities/error.utility.js.map +1 -0
  236. package/dist/esm/utilities/form-body.utility.d.ts +12 -10
  237. package/dist/esm/utilities/form-body.utility.d.ts.map +1 -1
  238. package/dist/esm/utilities/form-body.utility.js +19 -17
  239. package/dist/esm/utilities/form-body.utility.js.map +1 -1
  240. package/dist/esm/utilities/hr-time.utility.d.ts +7 -5
  241. package/dist/esm/utilities/hr-time.utility.d.ts.map +1 -1
  242. package/dist/esm/utilities/hr-time.utility.js +11 -9
  243. package/dist/esm/utilities/hr-time.utility.js.map +1 -1
  244. package/dist/esm/utilities/index.d.ts +2 -2
  245. package/dist/esm/utilities/index.d.ts.map +1 -1
  246. package/dist/esm/utilities/index.js +2 -2
  247. package/dist/esm/utilities/index.js.map +1 -1
  248. package/dist/esm/utilities/module.utility.d.ts.map +1 -1
  249. package/dist/esm/utilities/module.utility.js +1 -0
  250. package/dist/esm/utilities/module.utility.js.map +1 -1
  251. package/dist/esm/utilities/parse.utility.d.ts +89 -43
  252. package/dist/esm/utilities/parse.utility.d.ts.map +1 -1
  253. package/dist/esm/utilities/parse.utility.js +173 -141
  254. package/dist/esm/utilities/parse.utility.js.map +1 -1
  255. package/dist/esm/utilities/performance.utility.d.ts +15 -13
  256. package/dist/esm/utilities/performance.utility.d.ts.map +1 -1
  257. package/dist/esm/utilities/performance.utility.js +34 -29
  258. package/dist/esm/utilities/performance.utility.js.map +1 -1
  259. package/dist/esm/utilities/promise.utility.d.ts +20 -18
  260. package/dist/esm/utilities/promise.utility.d.ts.map +1 -1
  261. package/dist/esm/utilities/promise.utility.js +41 -51
  262. package/dist/esm/utilities/promise.utility.js.map +1 -1
  263. package/dist/esm/utilities/request.utility.d.ts +35 -29
  264. package/dist/esm/utilities/request.utility.d.ts.map +1 -1
  265. package/dist/esm/utilities/request.utility.js +118 -115
  266. package/dist/esm/utilities/request.utility.js.map +1 -1
  267. package/package.json +4 -15
  268. package/dist/esm/modules/logger/resolver.d.ts +0 -33
  269. package/dist/esm/modules/logger/resolver.d.ts.map +0 -1
  270. package/dist/esm/modules/logger/resolver.js +0 -95
  271. package/dist/esm/modules/logger/resolver.js.map +0 -1
  272. package/dist/esm/modules/logger/slot.d.ts +0 -23
  273. package/dist/esm/modules/logger/slot.d.ts.map +0 -1
  274. package/dist/esm/modules/logger/slot.js +0 -119
  275. package/dist/esm/modules/logger/slot.js.map +0 -1
  276. package/dist/esm/modules/logger/winston/formatters/deep-splat.d.ts +0 -4
  277. package/dist/esm/modules/logger/winston/formatters/deep-splat.d.ts.map +0 -1
  278. package/dist/esm/modules/logger/winston/formatters/deep-splat.js +0 -14
  279. package/dist/esm/modules/logger/winston/formatters/deep-splat.js.map +0 -1
  280. package/dist/esm/modules/logger/winston/formatters/index.d.ts +0 -2
  281. package/dist/esm/modules/logger/winston/formatters/index.d.ts.map +0 -1
  282. package/dist/esm/modules/logger/winston/formatters/index.js +0 -2
  283. package/dist/esm/modules/logger/winston/formatters/index.js.map +0 -1
  284. package/dist/esm/modules/network/http-request/common/types.d.ts +0 -2
  285. package/dist/esm/modules/network/http-request/common/types.d.ts.map +0 -1
  286. package/dist/esm/modules/network/http-request/common/types.js +0 -2
  287. package/dist/esm/modules/network/http-request/common/types.js.map +0 -1
  288. package/dist/esm/modules/queue/common/types.d.ts +0 -2
  289. package/dist/esm/modules/queue/common/types.d.ts.map +0 -1
  290. package/dist/esm/modules/queue/common/types.js +0 -2
  291. package/dist/esm/modules/queue/common/types.js.map +0 -1
  292. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.d.ts +0 -4
  293. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.d.ts.map +0 -1
  294. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.js +0 -28
  295. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.js.map +0 -1
  296. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.d.ts +0 -4
  297. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.d.ts.map +0 -1
  298. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.js +0 -26
  299. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.js.map +0 -1
  300. package/dist/esm/modules/storage/minio/helper.d.ts +0 -55
  301. package/dist/esm/modules/storage/minio/helper.d.ts.map +0 -1
  302. package/dist/esm/modules/storage/minio/helper.js +0 -177
  303. package/dist/esm/modules/storage/minio/helper.js.map +0 -1
  304. package/dist/esm/modules/storage/minio/index.d.ts +0 -2
  305. package/dist/esm/modules/storage/minio/index.d.ts.map +0 -1
  306. package/dist/esm/modules/storage/minio/index.js +0 -2
  307. package/dist/esm/modules/storage/minio/index.js.map +0 -1
  308. package/dist/esm/utilities/sleep.utility.d.ts +0 -2
  309. package/dist/esm/utilities/sleep.utility.d.ts.map +0 -1
  310. package/dist/esm/utilities/sleep.utility.js +0 -4
  311. package/dist/esm/utilities/sleep.utility.js.map +0 -1
@@ -1,37 +1,70 @@
1
- import { getError } from '@venizia/ignis-inversion';
2
- import { createRequire } from 'node:module';
3
1
  import { AbstractLogger } from './base/abstract.js';
4
- import { LoggerResolver } from './resolver.js';
5
- /** Stable wrapper the factory hands out; the delegate resolves lazily (first log call or `use()`), never at construction, so no provider loads until needed. Mutual reference with LoggerFactory is by design - hence the `no-use-before-define` disables. */
2
+ import { ConsoleLogger } from './base/console.js';
3
+ import { LoggerDebugGate } from './common/debug-gate.js';
4
+ import { LogLevels } from './common/types.js';
5
+ /**
6
+ * Stable wrapper the factory hands out. The delegate is resolved on the first log call or by `use()`, never at
7
+ * construction, so no provider is touched until a line is written. The wrapper also applies the factory's level to every
8
+ * provider the same way. Mutual reference with LoggerFactory is by design - hence the `no-use-before-define` disables.
9
+ */
6
10
  class LoggerDelegator extends AbstractLogger {
7
11
  constructor(scope) {
8
12
  super();
9
13
  this.scope = scope;
14
+ this._generation = -1;
10
15
  }
16
+ /** Takes the new provider's logger for this scope at once: the wrappers of this copy do not wait for their next line. */
11
17
  repoint(provider) {
12
18
  this._delegate = provider.get(this.scope);
19
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
20
+ this._generation = LoggerFactory.currentGeneration();
13
21
  }
22
+ /** The provider's logger for this scope, taken again whenever any copy of the module chose another provider (one integer compare per line). */
14
23
  delegate() {
15
24
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
16
- return (this._delegate ??= LoggerFactory.currentProvider().get(this.scope));
25
+ const generation = LoggerFactory.currentGeneration();
26
+ if (!this._delegate || this._generation !== generation) {
27
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
28
+ this._delegate = LoggerFactory.currentProvider().get(this.scope);
29
+ this._generation = generation;
30
+ }
31
+ return this._delegate;
32
+ }
33
+ /** The level the application set, else the shared debug gate for `debug`: a provider that has no gate of its own is gated the same way. */
34
+ isEnabled(level) {
35
+ if (level === LogLevels.DEBUG && !LoggerDebugGate.isOpen()) {
36
+ return false;
37
+ }
38
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
39
+ const threshold = LoggerFactory.currentLevel();
40
+ return threshold === undefined || LogLevels.isEnabled({ level, threshold });
41
+ }
42
+ /** The one place a level method passes its line to the provider, after the one level check. */
43
+ forward(opts) {
44
+ const { method, message, args } = opts;
45
+ if (this.isEnabled(method)) {
46
+ this.delegate()[method](message, ...args);
47
+ }
17
48
  }
18
49
  debug(message, ...args) {
19
- this.delegate().debug(message, ...args);
50
+ this.forward({ method: LogLevels.DEBUG, message, args });
20
51
  }
21
52
  info(message, ...args) {
22
- this.delegate().info(message, ...args);
53
+ this.forward({ method: LogLevels.INFO, message, args });
23
54
  }
24
55
  warn(message, ...args) {
25
- this.delegate().warn(message, ...args);
56
+ this.forward({ method: LogLevels.WARN, message, args });
26
57
  }
27
58
  error(message, ...args) {
28
- this.delegate().error(message, ...args);
59
+ this.forward({ method: LogLevels.ERROR, message, args });
29
60
  }
30
61
  emerg(message, ...args) {
31
- this.delegate().emerg(message, ...args);
62
+ this.forward({ method: LogLevels.EMERG, message, args });
32
63
  }
33
64
  log(level, message, ...args) {
34
- this.delegate().log(level, message, ...args);
65
+ if (this.isEnabled(level)) {
66
+ this.delegate().log(level, message, ...args);
67
+ }
35
68
  }
36
69
  for(methodName) {
37
70
  const childScope = this.scope !== '' ? `${this.scope}-${methodName}` : methodName;
@@ -39,52 +72,85 @@ class LoggerDelegator extends AbstractLogger {
39
72
  return LoggerFactory.getLogger([childScope]);
40
73
  }
41
74
  }
42
- /** A bundle can carry two copies of this module - the application's ESM import and core's CJS require. The provider lives in this globalThis slot so `use()` in one copy is seen by the other. */
75
+ /** A bundle can carry two copies of this module - the application's ESM import and core's CJS require. The chosen provider, the level and a counter of choices live in these globalThis slots so `use()` in one copy is seen, on the next line, by the loggers of the other. */
43
76
  const PROVIDER_SLOT = Symbol.for('ignis:logger-provider');
44
- /** Provider-agnostic acquisition path. Exactly ONE provider is ever loaded - the one registered via `use()`, or the winston default at first unregistered log call. */
77
+ const LEVEL_SLOT = Symbol.for('ignis:logger-level');
78
+ const GENERATION_SLOT = Symbol.for('ignis:logger-generation');
79
+ /**
80
+ * The one way to get a logger, and the same everywhere: the server, a script and a browser. It names no provider: the
81
+ * default is the console (`ConsoleLogger`), and an application chooses another with `use()`. It imports nothing from
82
+ * node, so it is part of the browser-pure `core` entry.
83
+ */
45
84
  export class LoggerFactory {
46
85
  static { this.cache = new Map(); }
47
- /** Register the application's provider. Re-points every wrapper issued so far. */
86
+ /**
87
+ * Choose the application's provider and/or the level. A provider re-points every wrapper issued so far. The level
88
+ * (a `LogLevels` value the application passes) is applied by the wrapper to every provider alike, and it also
89
+ * decides whether `debug` lines are written at all: `debug` turns the gate on, anything above it turns it off,
90
+ * whatever the environment says. A level that is not a `LogLevels` value (a typo, an uppercase name from the
91
+ * environment) is ignored: it must never open debug.
92
+ */
48
93
  static use(opts) {
49
- this.provider = opts.provider;
50
- Reflect.set(globalThis, PROVIDER_SLOT, opts.provider);
51
- const cacheValues = this.cache.values();
52
- for (const wrapper of cacheValues) {
53
- wrapper.repoint(opts.provider);
94
+ const { provider, level } = opts;
95
+ if (level !== undefined && LogLevels.isValid(level)) {
96
+ Reflect.set(globalThis, LEVEL_SLOT, level);
97
+ LoggerDebugGate.force({
98
+ isOpen: LogLevels.isEnabled({ level: LogLevels.DEBUG, threshold: level }),
99
+ });
100
+ }
101
+ if (provider === undefined) {
102
+ return;
103
+ }
104
+ Reflect.set(globalThis, PROVIDER_SLOT, provider);
105
+ this.bumpGeneration();
106
+ for (const wrapper of this.cache.values()) {
107
+ wrapper.repoint(provider);
54
108
  }
55
109
  }
56
- static currentProvider() {
57
- if (!this.provider) {
58
- this.provider = this.sharedProvider() ?? this.loadDefaultProvider();
59
- Reflect.set(globalThis, PROVIDER_SLOT, this.provider);
110
+ /** Choose `provider` only when the application has not chosen one: a framework's startup default, never an override. */
111
+ static useUnlessChosen(opts) {
112
+ if (!this.isChosen()) {
113
+ this.use({ provider: opts.provider });
60
114
  }
61
- return this.provider;
62
115
  }
63
- /** The provider another copy of this module registered, if any. */
116
+ /** Whether an application (or a framework default through `useUnlessChosen`) has chosen a provider. */
117
+ static isChosen() {
118
+ return this.sharedProvider() !== undefined;
119
+ }
120
+ /** The slot is the only record of the choice, so a `use()` or a `reset()` in any copy of the module is seen by all. */
121
+ static currentProvider() {
122
+ return this.sharedProvider() ?? ConsoleLogger;
123
+ }
124
+ /** Moves whenever a provider is chosen or reset, in any copy: a wrapper that cached its logger takes it again. */
125
+ static currentGeneration() {
126
+ const generation = Reflect.get(globalThis, GENERATION_SLOT);
127
+ return generation ?? 0;
128
+ }
129
+ static bumpGeneration() {
130
+ Reflect.set(globalThis, GENERATION_SLOT, this.currentGeneration() + 1);
131
+ }
132
+ /** The level the application set, or `undefined`: then every provider applies its own gate. */
133
+ static currentLevel() {
134
+ const level = Reflect.get(globalThis, LEVEL_SLOT);
135
+ return level;
136
+ }
137
+ /** The provider chosen by any copy of this module, if any. */
64
138
  static sharedProvider() {
65
139
  const shared = Reflect.get(globalThis, PROVIDER_SLOT);
66
140
  return shared;
67
141
  }
68
- // winston is an optional peer; compiled binaries must register a provider explicitly because only a class reference carries a provider into a bundle.
69
- static loadDefaultProvider() {
70
- try {
71
- return createRequire(__filename)('./winston').WinstonLogger;
72
- }
73
- catch (error) {
74
- throw getError({
75
- message: [
76
- '[LoggerFactory] No logger provider is registered and the default (winston) could not be loaded.',
77
- 'Either install it: `bun add winston winston-transport winston-daily-rotate-file`,',
78
- 'or register a provider at your entrypoint: `LoggerFactory.use({ provider })` with a class',
79
- "from '@venizia/ignis-helpers/winston' or '@venizia/ignis-helpers/pino'.",
80
- 'Compiled binaries (bun build --compile) MUST register explicitly.',
81
- `Cause: ${error instanceof Error ? error.message : String(error)}`,
82
- ].join(' '),
83
- });
142
+ /** Back to the default provider and no level, and every wrapper takes the console again: for a test, or a host that starts over. */
143
+ static reset() {
144
+ Reflect.deleteProperty(globalThis, PROVIDER_SLOT);
145
+ Reflect.deleteProperty(globalThis, LEVEL_SLOT);
146
+ LoggerDebugGate.force({ isOpen: undefined });
147
+ this.bumpGeneration();
148
+ for (const wrapper of this.cache.values()) {
149
+ wrapper.repoint(ConsoleLogger);
84
150
  }
85
151
  }
86
152
  static getLogger(scopes) {
87
- const scope = scopes.join('-');
153
+ const scope = scopes.filter((part) => part.length > 0).join('-');
88
154
  let cached = this.cache.get(scope);
89
155
  if (!cached) {
90
156
  cached = new LoggerDelegator(scope);
@@ -93,10 +159,4 @@ export class LoggerFactory {
93
159
  return cached;
94
160
  }
95
161
  }
96
- /** Provider-following facade: always resolves through the registered provider. */
97
- export const ApplicationLogger = {
98
- get: (scope) => LoggerFactory.getLogger([scope]),
99
- };
100
- // Runs whenever LoggerFactory is imported as a value - which core's Container and every application entrypoint already do. This is what makes BaseHelper resolve real loggers on the server while its own import graph stays browser-pure.
101
- LoggerResolver.use({ resolver: (opts) => LoggerFactory.getLogger(opts.scopes) });
102
162
  //# sourceMappingURL=factory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/modules/logger/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,8PAA8P;AAC9P,MAAM,eAAgB,SAAQ,cAAc;IAG1C,YAA6B,KAAa;QACxC,KAAK,EAAE,CAAC;QADmB,UAAK,GAAL,KAAK,CAAQ;IAE1C,CAAC;IAED,OAAO,CAAC,QAAyB;QAC/B,IAA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ACH,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC,aAAa,CAAC;QAC9D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE;oBACP,iGAAiG;oBACjG,mFAAmF;oBACnF,2FAA2F;oBAC3F,yEAAyE;oBACzE,mEAAmE;oBACnE,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;iBACnE,CAAC,IAAI,CAAC,GAAG,CAAC;aACZ,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAAgB;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;;AAGH,kFAAkF;AAClF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,GAAG,EAAE,CAAC,KAAa,EAAW,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;CAClE,CAAC;AAEF,2OAA2O;AAC3O,cAAc,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC","sourcesContent":["import { type AnyType } from '@/common/types';\nimport { getError } from '@venizia/ignis-inversion';\nimport { createRequire } from 'node:module';\nimport { AbstractLogger } from './base/abstract';\nimport { type ILogger, type ILoggerProvider, type TLogLevel } from './common/types';\nimport { LoggerResolver } from './resolver';\n\n/** Stable wrapper the factory hands out; the delegate resolves lazily (first log call or `use()`), never at construction, so no provider loads until needed. Mutual reference with LoggerFactory is by design - hence the `no-use-before-define` disables. */\nclass LoggerDelegator extends AbstractLogger {\n private _delegate?: ILogger;\n\n constructor(private readonly scope: string) {\n super();\n }\n\n repoint(provider: ILoggerProvider): void {\n this._delegate = provider.get(this.scope);\n }\n\n private delegate(): ILogger {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return (this._delegate ??= LoggerFactory.currentProvider().get(this.scope));\n }\n\n debug(message: string, ...args: AnyType[]) {\n this.delegate().debug(message, ...args);\n }\n\n info(message: string, ...args: AnyType[]) {\n this.delegate().info(message, ...args);\n }\n\n warn(message: string, ...args: AnyType[]) {\n this.delegate().warn(message, ...args);\n }\n\n error(message: string, ...args: AnyType[]) {\n this.delegate().error(message, ...args);\n }\n\n emerg(message: string, ...args: AnyType[]) {\n this.delegate().emerg(message, ...args);\n }\n\n log(level: TLogLevel, message: string, ...args: AnyType[]) {\n this.delegate().log(level, message, ...args);\n }\n\n for(methodName: string): ILogger {\n const childScope = this.scope !== '' ? `${this.scope}-${methodName}` : methodName;\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return LoggerFactory.getLogger([childScope]);\n }\n}\n\n/** A bundle can carry two copies of this module - the application's ESM import and core's CJS require. The provider lives in this globalThis slot so `use()` in one copy is seen by the other. */\nconst PROVIDER_SLOT = Symbol.for('ignis:logger-provider');\n\n/** Provider-agnostic acquisition path. Exactly ONE provider is ever loaded - the one registered via `use()`, or the winston default at first unregistered log call. */\nexport class LoggerFactory {\n private static provider?: ILoggerProvider;\n private static cache = new Map<string, LoggerDelegator>();\n\n /** Register the application's provider. Re-points every wrapper issued so far. */\n static use(opts: { provider: ILoggerProvider }): void {\n this.provider = opts.provider;\n Reflect.set(globalThis, PROVIDER_SLOT, opts.provider);\n const cacheValues = this.cache.values();\n for (const wrapper of cacheValues) {\n wrapper.repoint(opts.provider);\n }\n }\n\n static currentProvider(): ILoggerProvider {\n if (!this.provider) {\n this.provider = this.sharedProvider() ?? this.loadDefaultProvider();\n Reflect.set(globalThis, PROVIDER_SLOT, this.provider);\n }\n\n return this.provider;\n }\n\n /** The provider another copy of this module registered, if any. */\n private static sharedProvider(): ILoggerProvider | undefined {\n const shared: ILoggerProvider | undefined = Reflect.get(globalThis, PROVIDER_SLOT);\n return shared;\n }\n\n // winston is an optional peer; compiled binaries must register a provider explicitly because only a class reference carries a provider into a bundle.\n private static loadDefaultProvider(): ILoggerProvider {\n try {\n return createRequire(__filename)('./winston').WinstonLogger;\n } catch (error) {\n throw getError({\n message: [\n '[LoggerFactory] No logger provider is registered and the default (winston) could not be loaded.',\n 'Either install it: `bun add winston winston-transport winston-daily-rotate-file`,',\n 'or register a provider at your entrypoint: `LoggerFactory.use({ provider })` with a class',\n \"from '@venizia/ignis-helpers/winston' or '@venizia/ignis-helpers/pino'.\",\n 'Compiled binaries (bun build --compile) MUST register explicitly.',\n `Cause: ${error instanceof Error ? error.message : String(error)}`,\n ].join(' '),\n });\n }\n }\n\n static getLogger(scopes: string[]): ILogger {\n const scope = scopes.join('-');\n let cached = this.cache.get(scope);\n\n if (!cached) {\n cached = new LoggerDelegator(scope);\n this.cache.set(scope, cached);\n }\n\n return cached;\n }\n}\n\n/** Provider-following facade: always resolves through the registered provider. */\nexport const ApplicationLogger = {\n get: (scope: string): ILogger => LoggerFactory.getLogger([scope]),\n};\n\n// Runs whenever LoggerFactory is imported as a value - which core's Container and every application entrypoint already do. This is what makes BaseHelper resolve real loggers on the server while its own import graph stays browser-pure.\nLoggerResolver.use({ resolver: (opts) => LoggerFactory.getLogger(opts.scopes) });\n"]}
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/modules/logger/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CA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,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QACnF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,oIAAoI;IACpI,MAAM,CAAC,KAAK;QACV,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QAClD,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAC/C,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAAgB;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjE,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC","sourcesContent":["import { type AnyType } from '@/common/types';\nimport { AbstractLogger } from './base/abstract';\nimport { ConsoleLogger } from './base/console';\nimport { LoggerDebugGate } from './common/debug-gate';\nimport { type ILogger, type ILoggerProvider, LogLevels, type TLogLevel } from './common/types';\n\n/**\n * Stable wrapper the factory hands out. The delegate is resolved on the first log call or by `use()`, never at\n * construction, so no provider is touched until a line is written. The wrapper also applies the factory's level to every\n * provider the same way. Mutual reference with LoggerFactory is by design - hence the `no-use-before-define` disables.\n */\nclass LoggerDelegator extends AbstractLogger {\n private _delegate?: ILogger;\n private _generation = -1;\n\n constructor(private readonly scope: string) {\n super();\n }\n\n /** Takes the new provider's logger for this scope at once: the wrappers of this copy do not wait for their next line. */\n repoint(provider: ILoggerProvider): void {\n this._delegate = provider.get(this.scope);\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n this._generation = LoggerFactory.currentGeneration();\n }\n\n /** The provider's logger for this scope, taken again whenever any copy of the module chose another provider (one integer compare per line). */\n private delegate(): ILogger {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const generation = LoggerFactory.currentGeneration();\n\n if (!this._delegate || this._generation !== generation) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n this._delegate = LoggerFactory.currentProvider().get(this.scope);\n this._generation = generation;\n }\n\n return this._delegate;\n }\n\n /** The level the application set, else the shared debug gate for `debug`: a provider that has no gate of its own is gated the same way. */\n private isEnabled(level: TLogLevel): boolean {\n if (level === LogLevels.DEBUG && !LoggerDebugGate.isOpen()) {\n return false;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const threshold = LoggerFactory.currentLevel();\n return threshold === undefined || LogLevels.isEnabled({ level, threshold });\n }\n\n /** The one place a level method passes its line to the provider, after the one level check. */\n private forward(opts: {\n method: 'debug' | 'info' | 'warn' | 'error' | 'emerg';\n message: string;\n args: AnyType[];\n }): void {\n const { method, message, args } = opts;\n\n if (this.isEnabled(method)) {\n this.delegate()[method](message, ...args);\n }\n }\n\n debug(message: string, ...args: AnyType[]) {\n this.forward({ method: LogLevels.DEBUG, message, args });\n }\n\n info(message: string, ...args: AnyType[]) {\n this.forward({ method: LogLevels.INFO, message, args });\n }\n\n warn(message: string, ...args: AnyType[]) {\n this.forward({ method: LogLevels.WARN, message, args });\n }\n\n error(message: string, ...args: AnyType[]) {\n this.forward({ method: LogLevels.ERROR, message, args });\n }\n\n emerg(message: string, ...args: AnyType[]) {\n this.forward({ method: LogLevels.EMERG, message, args });\n }\n\n log(level: TLogLevel, message: string, ...args: AnyType[]) {\n if (this.isEnabled(level)) {\n this.delegate().log(level, message, ...args);\n }\n }\n\n for(methodName: string): ILogger {\n const childScope = this.scope !== '' ? `${this.scope}-${methodName}` : methodName;\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return LoggerFactory.getLogger([childScope]);\n }\n}\n\n/** A bundle can carry two copies of this module - the application's ESM import and core's CJS require. The chosen provider, the level and a counter of choices live in these globalThis slots so `use()` in one copy is seen, on the next line, by the loggers of the other. */\nconst PROVIDER_SLOT = Symbol.for('ignis:logger-provider');\nconst LEVEL_SLOT = Symbol.for('ignis:logger-level');\nconst GENERATION_SLOT = Symbol.for('ignis:logger-generation');\n\n/**\n * The one way to get a logger, and the same everywhere: the server, a script and a browser. It names no provider: the\n * default is the console (`ConsoleLogger`), and an application chooses another with `use()`. It imports nothing from\n * node, so it is part of the browser-pure `core` entry.\n */\nexport class LoggerFactory {\n private static cache = new Map<string, LoggerDelegator>();\n\n /**\n * Choose the application's provider and/or the level. A provider re-points every wrapper issued so far. The level\n * (a `LogLevels` value the application passes) is applied by the wrapper to every provider alike, and it also\n * decides whether `debug` lines are written at all: `debug` turns the gate on, anything above it turns it off,\n * whatever the environment says. A level that is not a `LogLevels` value (a typo, an uppercase name from the\n * environment) is ignored: it must never open debug.\n */\n static use(opts: { provider?: ILoggerProvider; level?: TLogLevel }): void {\n const { provider, level } = opts;\n\n if (level !== undefined && LogLevels.isValid(level)) {\n Reflect.set(globalThis, LEVEL_SLOT, level);\n LoggerDebugGate.force({\n isOpen: LogLevels.isEnabled({ level: LogLevels.DEBUG, threshold: level }),\n });\n }\n\n if (provider === undefined) {\n return;\n }\n\n Reflect.set(globalThis, PROVIDER_SLOT, provider);\n this.bumpGeneration();\n for (const wrapper of this.cache.values()) {\n wrapper.repoint(provider);\n }\n }\n\n /** Choose `provider` only when the application has not chosen one: a framework's startup default, never an override. */\n static useUnlessChosen(opts: { provider: ILoggerProvider }): void {\n if (!this.isChosen()) {\n this.use({ provider: opts.provider });\n }\n }\n\n /** Whether an application (or a framework default through `useUnlessChosen`) has chosen a provider. */\n static isChosen(): boolean {\n return this.sharedProvider() !== undefined;\n }\n\n /** The slot is the only record of the choice, so a `use()` or a `reset()` in any copy of the module is seen by all. */\n static currentProvider(): ILoggerProvider {\n return this.sharedProvider() ?? ConsoleLogger;\n }\n\n /** Moves whenever a provider is chosen or reset, in any copy: a wrapper that cached its logger takes it again. */\n static currentGeneration(): number {\n const generation: number | undefined = Reflect.get(globalThis, GENERATION_SLOT);\n return generation ?? 0;\n }\n\n private static bumpGeneration(): void {\n Reflect.set(globalThis, GENERATION_SLOT, this.currentGeneration() + 1);\n }\n\n /** The level the application set, or `undefined`: then every provider applies its own gate. */\n static currentLevel(): TLogLevel | undefined {\n const level: TLogLevel | undefined = Reflect.get(globalThis, LEVEL_SLOT);\n return level;\n }\n\n /** The provider chosen by any copy of this module, if any. */\n private static sharedProvider(): ILoggerProvider | undefined {\n const shared: ILoggerProvider | undefined = Reflect.get(globalThis, PROVIDER_SLOT);\n return shared;\n }\n\n /** Back to the default provider and no level, and every wrapper takes the console again: for a test, or a host that starts over. */\n static reset(): void {\n Reflect.deleteProperty(globalThis, PROVIDER_SLOT);\n Reflect.deleteProperty(globalThis, LEVEL_SLOT);\n LoggerDebugGate.force({ isOpen: undefined });\n this.bumpGeneration();\n for (const wrapper of this.cache.values()) {\n wrapper.repoint(ConsoleLogger);\n }\n }\n\n static getLogger(scopes: string[]): ILogger {\n const scope = scopes.filter((part) => part.length > 0).join('-');\n let cached = this.cache.get(scope);\n\n if (!cached) {\n cached = new LoggerDelegator(scope);\n this.cache.set(scope, cached);\n }\n\n return cached;\n }\n}\n"]}
@@ -1,8 +1,12 @@
1
1
  import util from 'node:util';
2
- /** 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. */
3
- export declare const formatLogMessage: (opts: {
4
- message: string;
5
- args: Array<unknown>;
6
- inspectOptions?: util.InspectOptions;
7
- }) => string;
2
+ export declare class LogFormatUtility {
3
+ private static resolveDepth;
4
+ private static buildInspectOptions;
5
+ /** 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. */
6
+ static formatMessage(opts: {
7
+ message: string;
8
+ args: Array<unknown>;
9
+ inspectOptions?: util.InspectOptions;
10
+ }): string;
11
+ }
8
12
  //# sourceMappingURL=deep-splat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deep-splat.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/deep-splat.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAoC7B,2TAA2T;AAC3T,eAAO,MAAM,gBAAgB,GAAI,MAAM;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC;CACtC,KAAG,MAoDH,CAAC"}
1
+ {"version":3,"file":"deep-splat.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/deep-splat.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,YAAY;IAkB3B,OAAO,CAAC,MAAM,CAAC,mBAAmB;IASlC,2TAA2T;IAC3T,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE;QACzB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC;KACtC,GAAG,MAAM;CAgEX"}
@@ -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,aA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Ac,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
+ {"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,EAAE,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC;YACrE,CAAC;YAED,4FAA4F;YAC5F,4FAA4F;YAC5F,0DAA0D;YAC1D,OAAO,IAAI,CAAC,OAAO,CACjB,aAAa,CAAC,aAAa,CAAC;gBAC1B,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,CAAC,cAAc,CAAC,KAAK,IAAI,gBAAgB,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,E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;IAU5B,+XAA+X;IAC/X,OAAO,CAAC,MAAM,CAAC,aAAa;IAiB5B,0FAA0F;IAC1F,OAAO,CAAC,MAAM,CAAC,UAAU;IA0DzB,OAAO,CAAC,MAAM,CAAC,UAAU;IAgEzB,8GAA8G;IAC9G,MAAM,CAAC,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
+ {"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,KAA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AAC;KACzB,GAAG,aAAa;IAkBjB,2GAA2G;IAC3G,OAAO,CAAC,MAAM,CAAC,aAAa;IAU5B,+XAA+X;IAC/X,OAAO,CAAC,MAAM,CAAC,aAAa;IAiB5B,0FAA0F;IAC1F,OAAO,CAAC,MAAM,CAAC,UAAU;IA0DzB,OAAO,CAAC,MAAM,CAAC,UAAU;IAoEzB,8GAA8G;IAC9G,MAAM,CAAC,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}`);