@spinajs/log 2.0.481 → 2.0.482

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 (304) hide show
  1. package/README.md +744 -0
  2. package/lib/cjs/archive/LogArchiveService.d.ts +75 -0
  3. package/lib/cjs/archive/LogArchiveService.d.ts.map +1 -0
  4. package/lib/cjs/archive/LogArchiveService.js +189 -0
  5. package/lib/cjs/archive/LogArchiveService.js.map +1 -0
  6. package/lib/cjs/archive/archive-strategy.d.ts +32 -0
  7. package/lib/cjs/archive/archive-strategy.d.ts.map +1 -0
  8. package/lib/cjs/archive/archive-strategy.js +43 -0
  9. package/lib/cjs/archive/archive-strategy.js.map +1 -0
  10. package/lib/cjs/archive/context.d.ts +50 -0
  11. package/lib/cjs/archive/context.d.ts.map +1 -0
  12. package/lib/cjs/archive/context.js +3 -0
  13. package/lib/cjs/archive/context.js.map +1 -0
  14. package/lib/cjs/archive/index.d.ts +10 -0
  15. package/lib/cjs/archive/index.d.ts.map +1 -0
  16. package/lib/cjs/archive/index.js +26 -0
  17. package/lib/cjs/archive/index.js.map +1 -0
  18. package/lib/cjs/archive/retention-strategy.d.ts +26 -0
  19. package/lib/cjs/archive/retention-strategy.d.ts.map +1 -0
  20. package/lib/cjs/archive/retention-strategy.js +42 -0
  21. package/lib/cjs/archive/retention-strategy.js.map +1 -0
  22. package/lib/cjs/archive/strategies/AgeLogRetentionStrategy.d.ts +10 -0
  23. package/lib/cjs/archive/strategies/AgeLogRetentionStrategy.d.ts.map +1 -0
  24. package/lib/cjs/archive/strategies/AgeLogRetentionStrategy.js +46 -0
  25. package/lib/cjs/archive/strategies/AgeLogRetentionStrategy.js.map +1 -0
  26. package/lib/cjs/archive/strategies/CountLogRetentionStrategy.d.ts +10 -0
  27. package/lib/cjs/archive/strategies/CountLogRetentionStrategy.d.ts.map +1 -0
  28. package/lib/cjs/archive/strategies/CountLogRetentionStrategy.js +42 -0
  29. package/lib/cjs/archive/strategies/CountLogRetentionStrategy.js.map +1 -0
  30. package/lib/cjs/archive/strategies/CronLogArchiveStrategy.d.ts +15 -0
  31. package/lib/cjs/archive/strategies/CronLogArchiveStrategy.d.ts.map +1 -0
  32. package/lib/cjs/archive/strategies/CronLogArchiveStrategy.js +52 -0
  33. package/lib/cjs/archive/strategies/CronLogArchiveStrategy.js.map +1 -0
  34. package/lib/cjs/archive/strategies/SizeLogArchiveStrategy.d.ts +18 -0
  35. package/lib/cjs/archive/strategies/SizeLogArchiveStrategy.d.ts.map +1 -0
  36. package/lib/cjs/archive/strategies/SizeLogArchiveStrategy.js +63 -0
  37. package/lib/cjs/archive/strategies/SizeLogArchiveStrategy.js.map +1 -0
  38. package/lib/cjs/archive/strategies/util.d.ts +28 -0
  39. package/lib/cjs/archive/strategies/util.d.ts.map +1 -0
  40. package/lib/cjs/archive/strategies/util.js +59 -0
  41. package/lib/cjs/archive/strategies/util.js.map +1 -0
  42. package/lib/cjs/bootstrap.d.ts.map +1 -1
  43. package/lib/cjs/bootstrap.js +24 -1
  44. package/lib/cjs/bootstrap.js.map +1 -1
  45. package/lib/cjs/callsite.d.ts +26 -0
  46. package/lib/cjs/callsite.d.ts.map +1 -0
  47. package/lib/cjs/callsite.js +60 -0
  48. package/lib/cjs/callsite.js.map +1 -0
  49. package/lib/cjs/config/log.d.ts +96 -0
  50. package/lib/cjs/config/log.d.ts.map +1 -0
  51. package/lib/cjs/config/log.js +75 -0
  52. package/lib/cjs/config/log.js.map +1 -0
  53. package/lib/cjs/context.browser.d.ts +46 -0
  54. package/lib/cjs/context.browser.d.ts.map +1 -0
  55. package/lib/cjs/context.browser.js +85 -0
  56. package/lib/cjs/context.browser.js.map +1 -0
  57. package/lib/cjs/context.d.ts +61 -0
  58. package/lib/cjs/context.d.ts.map +1 -0
  59. package/lib/cjs/context.js +92 -0
  60. package/lib/cjs/context.js.map +1 -0
  61. package/lib/cjs/filters/LevelFilter.d.ts +24 -0
  62. package/lib/cjs/filters/LevelFilter.d.ts.map +1 -0
  63. package/lib/cjs/filters/LevelFilter.js +39 -0
  64. package/lib/cjs/filters/LevelFilter.js.map +1 -0
  65. package/lib/cjs/filters/MatchFilter.d.ts +30 -0
  66. package/lib/cjs/filters/MatchFilter.d.ts.map +1 -0
  67. package/lib/cjs/filters/MatchFilter.js +65 -0
  68. package/lib/cjs/filters/MatchFilter.js.map +1 -0
  69. package/lib/cjs/filters/RateLimitFilter.d.ts +37 -0
  70. package/lib/cjs/filters/RateLimitFilter.d.ts.map +1 -0
  71. package/lib/cjs/filters/RateLimitFilter.js +70 -0
  72. package/lib/cjs/filters/RateLimitFilter.js.map +1 -0
  73. package/lib/cjs/filters/index.d.ts +4 -0
  74. package/lib/cjs/filters/index.d.ts.map +1 -0
  75. package/lib/cjs/filters/index.js +20 -0
  76. package/lib/cjs/filters/index.js.map +1 -0
  77. package/lib/cjs/index.browser.d.ts +14 -0
  78. package/lib/cjs/index.browser.d.ts.map +1 -0
  79. package/lib/cjs/index.browser.js +46 -0
  80. package/lib/cjs/index.browser.js.map +1 -0
  81. package/lib/cjs/index.d.ts +8 -0
  82. package/lib/cjs/index.d.ts.map +1 -1
  83. package/lib/cjs/index.js +8 -0
  84. package/lib/cjs/index.js.map +1 -1
  85. package/lib/cjs/log.d.ts +60 -1
  86. package/lib/cjs/log.d.ts.map +1 -1
  87. package/lib/cjs/log.js +294 -32
  88. package/lib/cjs/log.js.map +1 -1
  89. package/lib/cjs/perf/LogMetricSink.d.ts +28 -0
  90. package/lib/cjs/perf/LogMetricSink.d.ts.map +1 -0
  91. package/lib/cjs/perf/LogMetricSink.js +120 -0
  92. package/lib/cjs/perf/LogMetricSink.js.map +1 -0
  93. package/lib/cjs/perf/measure.d.ts +9 -0
  94. package/lib/cjs/perf/measure.d.ts.map +1 -0
  95. package/lib/cjs/perf/measure.js +21 -0
  96. package/lib/cjs/perf/measure.js.map +1 -0
  97. package/lib/cjs/perf.d.ts +9 -0
  98. package/lib/cjs/perf.d.ts.map +1 -0
  99. package/lib/cjs/perf.js +18 -0
  100. package/lib/cjs/perf.js.map +1 -0
  101. package/lib/cjs/schemas/log.configuration.d.ts +151 -18
  102. package/lib/cjs/schemas/log.configuration.d.ts.map +1 -1
  103. package/lib/cjs/schemas/log.configuration.js +154 -21
  104. package/lib/cjs/schemas/log.configuration.js.map +1 -1
  105. package/lib/cjs/targets/BrowserConsoleTarget.d.ts +48 -0
  106. package/lib/cjs/targets/BrowserConsoleTarget.d.ts.map +1 -0
  107. package/lib/cjs/targets/BrowserConsoleTarget.js +48 -0
  108. package/lib/cjs/targets/BrowserConsoleTarget.js.map +1 -0
  109. package/lib/cjs/targets/ColoredConsoleTarget.d.ts.map +1 -1
  110. package/lib/cjs/targets/ColoredConsoleTarget.js +21 -12
  111. package/lib/cjs/targets/ColoredConsoleTarget.js.map +1 -1
  112. package/lib/cjs/targets/FileTarget.d.ts +96 -20
  113. package/lib/cjs/targets/FileTarget.d.ts.map +1 -1
  114. package/lib/cjs/targets/FileTarget.js +188 -225
  115. package/lib/cjs/targets/FileTarget.js.map +1 -1
  116. package/lib/cjs/targets/JsonFileTarget.d.ts +19 -0
  117. package/lib/cjs/targets/JsonFileTarget.d.ts.map +1 -0
  118. package/lib/cjs/targets/JsonFileTarget.js +44 -0
  119. package/lib/cjs/targets/JsonFileTarget.js.map +1 -0
  120. package/lib/cjs/targets/JsonTarget.d.ts +27 -0
  121. package/lib/cjs/targets/JsonTarget.d.ts.map +1 -0
  122. package/lib/cjs/targets/JsonTarget.js +46 -0
  123. package/lib/cjs/targets/JsonTarget.js.map +1 -0
  124. package/lib/cjs/targets/MemoryTarget.d.ts +33 -0
  125. package/lib/cjs/targets/MemoryTarget.d.ts.map +1 -0
  126. package/lib/cjs/targets/MemoryTarget.js +63 -0
  127. package/lib/cjs/targets/MemoryTarget.js.map +1 -0
  128. package/lib/cjs/targets/index.d.ts +7 -0
  129. package/lib/cjs/targets/index.d.ts.map +1 -1
  130. package/lib/cjs/targets/index.js +7 -0
  131. package/lib/cjs/targets/index.js.map +1 -1
  132. package/lib/cjs/targets/wrappers/AutoFlushTarget.d.ts +37 -0
  133. package/lib/cjs/targets/wrappers/AutoFlushTarget.d.ts.map +1 -0
  134. package/lib/cjs/targets/wrappers/AutoFlushTarget.js +48 -0
  135. package/lib/cjs/targets/wrappers/AutoFlushTarget.js.map +1 -0
  136. package/lib/cjs/targets/wrappers/FallbackGroupTarget.d.ts +45 -0
  137. package/lib/cjs/targets/wrappers/FallbackGroupTarget.d.ts.map +1 -0
  138. package/lib/cjs/targets/wrappers/FallbackGroupTarget.js +94 -0
  139. package/lib/cjs/targets/wrappers/FallbackGroupTarget.js.map +1 -0
  140. package/lib/cjs/targets/wrappers/RetryingTarget.d.ts +44 -0
  141. package/lib/cjs/targets/wrappers/RetryingTarget.d.ts.map +1 -0
  142. package/lib/cjs/targets/wrappers/RetryingTarget.js +61 -0
  143. package/lib/cjs/targets/wrappers/RetryingTarget.js.map +1 -0
  144. package/lib/cjs/targets/wrappers/SplitGroupTarget.d.ts +30 -0
  145. package/lib/cjs/targets/wrappers/SplitGroupTarget.d.ts.map +1 -0
  146. package/lib/cjs/targets/wrappers/SplitGroupTarget.js +52 -0
  147. package/lib/cjs/targets/wrappers/SplitGroupTarget.js.map +1 -0
  148. package/lib/cjs/traceparent.d.ts +63 -0
  149. package/lib/cjs/traceparent.d.ts.map +1 -0
  150. package/lib/cjs/traceparent.js +107 -0
  151. package/lib/cjs/traceparent.js.map +1 -0
  152. package/lib/mjs/archive/LogArchiveService.d.ts +75 -0
  153. package/lib/mjs/archive/LogArchiveService.d.ts.map +1 -0
  154. package/lib/mjs/archive/LogArchiveService.js +186 -0
  155. package/lib/mjs/archive/LogArchiveService.js.map +1 -0
  156. package/lib/mjs/archive/archive-strategy.d.ts +32 -0
  157. package/lib/mjs/archive/archive-strategy.d.ts.map +1 -0
  158. package/lib/mjs/archive/archive-strategy.js +39 -0
  159. package/lib/mjs/archive/archive-strategy.js.map +1 -0
  160. package/lib/mjs/archive/context.d.ts +50 -0
  161. package/lib/mjs/archive/context.d.ts.map +1 -0
  162. package/lib/mjs/archive/context.js +2 -0
  163. package/lib/mjs/archive/context.js.map +1 -0
  164. package/lib/mjs/archive/index.d.ts +10 -0
  165. package/lib/mjs/archive/index.d.ts.map +1 -0
  166. package/lib/mjs/archive/index.js +10 -0
  167. package/lib/mjs/archive/index.js.map +1 -0
  168. package/lib/mjs/archive/retention-strategy.d.ts +26 -0
  169. package/lib/mjs/archive/retention-strategy.d.ts.map +1 -0
  170. package/lib/mjs/archive/retention-strategy.js +38 -0
  171. package/lib/mjs/archive/retention-strategy.js.map +1 -0
  172. package/lib/mjs/archive/strategies/AgeLogRetentionStrategy.d.ts +10 -0
  173. package/lib/mjs/archive/strategies/AgeLogRetentionStrategy.d.ts.map +1 -0
  174. package/lib/mjs/archive/strategies/AgeLogRetentionStrategy.js +43 -0
  175. package/lib/mjs/archive/strategies/AgeLogRetentionStrategy.js.map +1 -0
  176. package/lib/mjs/archive/strategies/CountLogRetentionStrategy.d.ts +10 -0
  177. package/lib/mjs/archive/strategies/CountLogRetentionStrategy.d.ts.map +1 -0
  178. package/lib/mjs/archive/strategies/CountLogRetentionStrategy.js +39 -0
  179. package/lib/mjs/archive/strategies/CountLogRetentionStrategy.js.map +1 -0
  180. package/lib/mjs/archive/strategies/CronLogArchiveStrategy.d.ts +15 -0
  181. package/lib/mjs/archive/strategies/CronLogArchiveStrategy.d.ts.map +1 -0
  182. package/lib/mjs/archive/strategies/CronLogArchiveStrategy.js +49 -0
  183. package/lib/mjs/archive/strategies/CronLogArchiveStrategy.js.map +1 -0
  184. package/lib/mjs/archive/strategies/SizeLogArchiveStrategy.d.ts +18 -0
  185. package/lib/mjs/archive/strategies/SizeLogArchiveStrategy.d.ts.map +1 -0
  186. package/lib/mjs/archive/strategies/SizeLogArchiveStrategy.js +60 -0
  187. package/lib/mjs/archive/strategies/SizeLogArchiveStrategy.js.map +1 -0
  188. package/lib/mjs/archive/strategies/util.d.ts +28 -0
  189. package/lib/mjs/archive/strategies/util.d.ts.map +1 -0
  190. package/lib/mjs/archive/strategies/util.js +54 -0
  191. package/lib/mjs/archive/strategies/util.js.map +1 -0
  192. package/lib/mjs/bootstrap.d.ts.map +1 -1
  193. package/lib/mjs/bootstrap.js +25 -2
  194. package/lib/mjs/bootstrap.js.map +1 -1
  195. package/lib/mjs/callsite.d.ts +26 -0
  196. package/lib/mjs/callsite.d.ts.map +1 -0
  197. package/lib/mjs/callsite.js +57 -0
  198. package/lib/mjs/callsite.js.map +1 -0
  199. package/lib/mjs/config/log.d.ts +96 -0
  200. package/lib/mjs/config/log.d.ts.map +1 -0
  201. package/lib/mjs/config/log.js +72 -0
  202. package/lib/mjs/config/log.js.map +1 -0
  203. package/lib/mjs/context.browser.d.ts +46 -0
  204. package/lib/mjs/context.browser.d.ts.map +1 -0
  205. package/lib/mjs/context.browser.js +81 -0
  206. package/lib/mjs/context.browser.js.map +1 -0
  207. package/lib/mjs/context.d.ts +61 -0
  208. package/lib/mjs/context.d.ts.map +1 -0
  209. package/lib/mjs/context.js +88 -0
  210. package/lib/mjs/context.js.map +1 -0
  211. package/lib/mjs/filters/LevelFilter.d.ts +24 -0
  212. package/lib/mjs/filters/LevelFilter.d.ts.map +1 -0
  213. package/lib/mjs/filters/LevelFilter.js +36 -0
  214. package/lib/mjs/filters/LevelFilter.js.map +1 -0
  215. package/lib/mjs/filters/MatchFilter.d.ts +30 -0
  216. package/lib/mjs/filters/MatchFilter.d.ts.map +1 -0
  217. package/lib/mjs/filters/MatchFilter.js +62 -0
  218. package/lib/mjs/filters/MatchFilter.js.map +1 -0
  219. package/lib/mjs/filters/RateLimitFilter.d.ts +37 -0
  220. package/lib/mjs/filters/RateLimitFilter.d.ts.map +1 -0
  221. package/lib/mjs/filters/RateLimitFilter.js +67 -0
  222. package/lib/mjs/filters/RateLimitFilter.js.map +1 -0
  223. package/lib/mjs/filters/index.d.ts +4 -0
  224. package/lib/mjs/filters/index.d.ts.map +1 -0
  225. package/lib/mjs/filters/index.js +4 -0
  226. package/lib/mjs/filters/index.js.map +1 -0
  227. package/lib/mjs/index.browser.d.ts +14 -0
  228. package/lib/mjs/index.browser.d.ts.map +1 -0
  229. package/lib/mjs/index.browser.js +30 -0
  230. package/lib/mjs/index.browser.js.map +1 -0
  231. package/lib/mjs/index.d.ts +8 -0
  232. package/lib/mjs/index.d.ts.map +1 -1
  233. package/lib/mjs/index.js +8 -0
  234. package/lib/mjs/index.js.map +1 -1
  235. package/lib/mjs/log.d.ts +60 -1
  236. package/lib/mjs/log.d.ts.map +1 -1
  237. package/lib/mjs/log.js +295 -33
  238. package/lib/mjs/log.js.map +1 -1
  239. package/lib/mjs/perf/LogMetricSink.d.ts +28 -0
  240. package/lib/mjs/perf/LogMetricSink.d.ts.map +1 -0
  241. package/lib/mjs/perf/LogMetricSink.js +117 -0
  242. package/lib/mjs/perf/LogMetricSink.js.map +1 -0
  243. package/lib/mjs/perf/measure.d.ts +9 -0
  244. package/lib/mjs/perf/measure.d.ts.map +1 -0
  245. package/lib/mjs/perf/measure.js +18 -0
  246. package/lib/mjs/perf/measure.js.map +1 -0
  247. package/lib/mjs/perf.d.ts +9 -0
  248. package/lib/mjs/perf.d.ts.map +1 -0
  249. package/lib/mjs/perf.js +15 -0
  250. package/lib/mjs/perf.js.map +1 -0
  251. package/lib/mjs/schemas/log.configuration.d.ts +151 -18
  252. package/lib/mjs/schemas/log.configuration.d.ts.map +1 -1
  253. package/lib/mjs/schemas/log.configuration.js +154 -21
  254. package/lib/mjs/schemas/log.configuration.js.map +1 -1
  255. package/lib/mjs/targets/BrowserConsoleTarget.d.ts +48 -0
  256. package/lib/mjs/targets/BrowserConsoleTarget.d.ts.map +1 -0
  257. package/lib/mjs/targets/BrowserConsoleTarget.js +45 -0
  258. package/lib/mjs/targets/BrowserConsoleTarget.js.map +1 -0
  259. package/lib/mjs/targets/ColoredConsoleTarget.d.ts.map +1 -1
  260. package/lib/mjs/targets/ColoredConsoleTarget.js +21 -9
  261. package/lib/mjs/targets/ColoredConsoleTarget.js.map +1 -1
  262. package/lib/mjs/targets/FileTarget.d.ts +96 -20
  263. package/lib/mjs/targets/FileTarget.d.ts.map +1 -1
  264. package/lib/mjs/targets/FileTarget.js +191 -192
  265. package/lib/mjs/targets/FileTarget.js.map +1 -1
  266. package/lib/mjs/targets/JsonFileTarget.d.ts +19 -0
  267. package/lib/mjs/targets/JsonFileTarget.d.ts.map +1 -0
  268. package/lib/mjs/targets/JsonFileTarget.js +41 -0
  269. package/lib/mjs/targets/JsonFileTarget.js.map +1 -0
  270. package/lib/mjs/targets/JsonTarget.d.ts +27 -0
  271. package/lib/mjs/targets/JsonTarget.d.ts.map +1 -0
  272. package/lib/mjs/targets/JsonTarget.js +43 -0
  273. package/lib/mjs/targets/JsonTarget.js.map +1 -0
  274. package/lib/mjs/targets/MemoryTarget.d.ts +33 -0
  275. package/lib/mjs/targets/MemoryTarget.d.ts.map +1 -0
  276. package/lib/mjs/targets/MemoryTarget.js +60 -0
  277. package/lib/mjs/targets/MemoryTarget.js.map +1 -0
  278. package/lib/mjs/targets/index.d.ts +7 -0
  279. package/lib/mjs/targets/index.d.ts.map +1 -1
  280. package/lib/mjs/targets/index.js +7 -0
  281. package/lib/mjs/targets/index.js.map +1 -1
  282. package/lib/mjs/targets/wrappers/AutoFlushTarget.d.ts +37 -0
  283. package/lib/mjs/targets/wrappers/AutoFlushTarget.d.ts.map +1 -0
  284. package/lib/mjs/targets/wrappers/AutoFlushTarget.js +45 -0
  285. package/lib/mjs/targets/wrappers/AutoFlushTarget.js.map +1 -0
  286. package/lib/mjs/targets/wrappers/FallbackGroupTarget.d.ts +45 -0
  287. package/lib/mjs/targets/wrappers/FallbackGroupTarget.d.ts.map +1 -0
  288. package/lib/mjs/targets/wrappers/FallbackGroupTarget.js +91 -0
  289. package/lib/mjs/targets/wrappers/FallbackGroupTarget.js.map +1 -0
  290. package/lib/mjs/targets/wrappers/RetryingTarget.d.ts +44 -0
  291. package/lib/mjs/targets/wrappers/RetryingTarget.d.ts.map +1 -0
  292. package/lib/mjs/targets/wrappers/RetryingTarget.js +58 -0
  293. package/lib/mjs/targets/wrappers/RetryingTarget.js.map +1 -0
  294. package/lib/mjs/targets/wrappers/SplitGroupTarget.d.ts +30 -0
  295. package/lib/mjs/targets/wrappers/SplitGroupTarget.d.ts.map +1 -0
  296. package/lib/mjs/targets/wrappers/SplitGroupTarget.js +49 -0
  297. package/lib/mjs/targets/wrappers/SplitGroupTarget.js.map +1 -0
  298. package/lib/mjs/traceparent.d.ts +63 -0
  299. package/lib/mjs/traceparent.d.ts.map +1 -0
  300. package/lib/mjs/traceparent.js +100 -0
  301. package/lib/mjs/traceparent.js.map +1 -0
  302. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  303. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  304. package/package.json +25 -15
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /**
3
+ * Default configuration shipped with @spinajs/log ( Node only ).
4
+ *
5
+ * Everything the log package can be tuned with lives here, so the configuration
6
+ * module surfaces a single, discoverable list of what can be changed:
7
+ *
8
+ * 1. a DEFAULT fs provider `fs-log-default` rooted at the working process
9
+ * directory, so FileTarget works without any user fs configuration,
10
+ * 2. `logger.file` - the default FileTarget options ( buffer / rotation /
11
+ * retention tunables ). FileTarget merges these UNDER any per-target
12
+ * `options`, and a user project config ( loaded last ) overrides them - the
13
+ * same override chain every other spinajs package uses.
14
+ *
15
+ * Config files are merged with array concatenation, so the provider entry is
16
+ * APPENDED to any providers the user configures.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.LOG_FILE_DEFAULTS = void 0;
20
+ const DEFAULT_FS_PROVIDER = "fs-log-default";
21
+ /**
22
+ * Canonical default FileTarget options. This is the SINGLE source of truth for
23
+ * every log tunable - change a default HERE, never inline in the target or a
24
+ * strategy. It is exported ( not just embedded in the config below ) so the
25
+ * FileTarget can fall back to the exact same values when the config file is not
26
+ * discovered ( eg. isolated unit tests ), and so tests share one definition.
27
+ */
28
+ exports.LOG_FILE_DEFAULTS = {
29
+ /** fs provider holding the active log file. */
30
+ fs: DEFAULT_FS_PROVIDER,
31
+ /** Zip the archived file when it is moved to the archive. */
32
+ compress: false,
33
+ /** Rotate the active log once it grows past this many bytes ( 1 MB ). */
34
+ maxSize: 1024 * 1024,
35
+ /** Flush the in-memory buffer after this many messages. */
36
+ maxBufferSize: 100,
37
+ /** Hard cap on buffered messages; oldest are dropped past this so a down sink cannot OOM. */
38
+ maxQueueSize: 100000,
39
+ /** Periodic flush tick in milliseconds, so a partial buffer is not held. */
40
+ flushInterval: 1000,
41
+ /** How often ( seconds ) SizeLogArchiveStrategy checks the active log size. */
42
+ archiveInterval: 60,
43
+ /** Rotation trigger strategy ( decides WHEN to archive ). */
44
+ archiveStrategy: "SizeLogArchiveStrategy",
45
+ /** Retention strategies applied in order after each rotation. */
46
+ retentionStrategies: ["CountLogRetentionStrategy"],
47
+ /** Archives to keep ( CountLogRetentionStrategy ), oldest deleted first. */
48
+ maxArchiveFiles: 5,
49
+ /** Max archive age in seconds ( AgeLogRetentionStrategy ), 7 days. */
50
+ maxAge: 7 * 24 * 60 * 60,
51
+ };
52
+ const log = {
53
+ fs: {
54
+ defaultProvider: DEFAULT_FS_PROVIDER,
55
+ providers: [
56
+ {
57
+ name: DEFAULT_FS_PROVIDER,
58
+ service: "fsNative",
59
+ basePath: process.cwd(),
60
+ },
61
+ ],
62
+ },
63
+ logger: {
64
+ file: exports.LOG_FILE_DEFAULTS,
65
+ perf: {
66
+ enabled: true,
67
+ thresholds: { "orm.query": 200, "http.request": 1000, default: 0 },
68
+ overThresholdLevel: "warn",
69
+ underThresholdLevel: "trace",
70
+ logCounters: false,
71
+ },
72
+ },
73
+ };
74
+ exports.default = log;
75
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/config/log.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAE7C;;;;;;GAMG;AACU,QAAA,iBAAiB,GAAG;IAC/B,+CAA+C;IAC/C,EAAE,EAAE,mBAAmB;IAEvB,6DAA6D;IAC7D,QAAQ,EAAE,KAAK;IAEf,yEAAyE;IACzE,OAAO,EAAE,IAAI,GAAG,IAAI;IAEpB,2DAA2D;IAC3D,aAAa,EAAE,GAAG;IAElB,6FAA6F;IAC7F,YAAY,EAAE,MAAM;IAEpB,4EAA4E;IAC5E,aAAa,EAAE,IAAI;IAEnB,+EAA+E;IAC/E,eAAe,EAAE,EAAE;IAEnB,6DAA6D;IAC7D,eAAe,EAAE,wBAAwB;IAEzC,iEAAiE;IACjE,mBAAmB,EAAE,CAAC,2BAA2B,CAAC;IAElD,4EAA4E;IAC5E,eAAe,EAAE,CAAC;IAElB,sEAAsE;IACtE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;CACzB,CAAC;AAEF,MAAM,GAAG,GAAG;IACV,EAAE,EAAE;QACF,eAAe,EAAE,mBAAmB;QACpC,SAAS,EAAE;YACT;gBACE,IAAI,EAAE,mBAAmB;gBACzB,OAAO,EAAE,UAAU;gBACnB,QAAQ,EAAE,OAAO,CAAC,GAAG,EAAE;aACxB;SACF;KACF;IACD,MAAM,EAAE;QACN,IAAI,EAAE,yBAAiB;QACvB,IAAI,EAAE;YACJ,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE;YAClE,kBAAkB,EAAE,MAAM;YAC1B,mBAAmB,EAAE,OAAO;YAC5B,WAAW,EAAE,KAAK;SACnB;KACF;CACF,CAAC;AAEF,kBAAe,GAAG,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Browser fallback for {@link LogContext}. The browser has no
3
+ * `node:async_hooks` / AsyncLocalStorage, so this keeps a single module-level
4
+ * `current` object and swaps it synchronously around `with`.
5
+ *
6
+ * LIMITATION: there is NO async isolation here. `with` only holds the context
7
+ * for the synchronous portion of `fn`; anything that runs after an `await` or a
8
+ * deferred callback ( unless wrapped with {@link LogContextImpl.bind} ) will not
9
+ * see it. This mirrors the Node API surface so callers write the same code, but
10
+ * on the browser ambient context is best-effort and synchronous only.
11
+ */
12
+ declare class LogContextImpl {
13
+ private current;
14
+ /**
15
+ * The current ambient store.
16
+ */
17
+ active(): Record<string, unknown>;
18
+ /**
19
+ * Synchronously set the context to `{ ...current, ...vars }` for the duration
20
+ * of `fn`, restoring the previous value afterwards. No async isolation.
21
+ */
22
+ with<T>(vars: Record<string, unknown>, fn: () => T): T;
23
+ /**
24
+ * Mutate the current store in place ( late-bound values ).
25
+ */
26
+ set(key: string, value: unknown): void;
27
+ /**
28
+ * Capture the current store and restore it around each invocation of the
29
+ * returned function.
30
+ */
31
+ bind<A extends unknown[], R>(fn: (...a: A) => R): (...a: A) => R;
32
+ }
33
+ /**
34
+ * Shared ambient log context ( browser, synchronous fallback ).
35
+ */
36
+ export declare const LogContext: LogContextImpl;
37
+ /**
38
+ * Projects only primitive scalar values ( string / number / boolean / bigint )
39
+ * from an ambient-context object, dropping objects, arrays, Dates, functions,
40
+ * null and undefined. Ambient context is meant for correlation ids ( requestId,
41
+ * traceId, ... ) that belong on every log line; structured payloads should be
42
+ * passed explicitly per call ( log.info({ obj }, ... ) ), not via ambient context.
43
+ */
44
+ export declare function scalarContext(ctx: Record<string, unknown>): Record<string, unknown>;
45
+ export {};
46
+ //# sourceMappingURL=context.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.browser.d.ts","sourceRoot":"","sources":["../../src/context.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,OAAO,CAA+B;IAE9C;;OAEG;IACI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIxC;;;OAGG;IACI,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAU7D;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAI7C;;;OAGG;IACI,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;CAYxE;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,gBAAuB,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASnF"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogContext = void 0;
4
+ exports.scalarContext = scalarContext;
5
+ /**
6
+ * Browser fallback for {@link LogContext}. The browser has no
7
+ * `node:async_hooks` / AsyncLocalStorage, so this keeps a single module-level
8
+ * `current` object and swaps it synchronously around `with`.
9
+ *
10
+ * LIMITATION: there is NO async isolation here. `with` only holds the context
11
+ * for the synchronous portion of `fn`; anything that runs after an `await` or a
12
+ * deferred callback ( unless wrapped with {@link LogContextImpl.bind} ) will not
13
+ * see it. This mirrors the Node API surface so callers write the same code, but
14
+ * on the browser ambient context is best-effort and synchronous only.
15
+ */
16
+ class LogContextImpl {
17
+ constructor() {
18
+ this.current = {};
19
+ }
20
+ /**
21
+ * The current ambient store.
22
+ */
23
+ active() {
24
+ return this.current;
25
+ }
26
+ /**
27
+ * Synchronously set the context to `{ ...current, ...vars }` for the duration
28
+ * of `fn`, restoring the previous value afterwards. No async isolation.
29
+ */
30
+ with(vars, fn) {
31
+ const previous = this.current;
32
+ this.current = { ...previous, ...vars };
33
+ try {
34
+ return fn();
35
+ }
36
+ finally {
37
+ this.current = previous;
38
+ }
39
+ }
40
+ /**
41
+ * Mutate the current store in place ( late-bound values ).
42
+ */
43
+ set(key, value) {
44
+ this.current[key] = value;
45
+ }
46
+ /**
47
+ * Capture the current store and restore it around each invocation of the
48
+ * returned function.
49
+ */
50
+ bind(fn) {
51
+ const captured = this.current;
52
+ return (...args) => {
53
+ const previous = this.current;
54
+ this.current = captured;
55
+ try {
56
+ return fn(...args);
57
+ }
58
+ finally {
59
+ this.current = previous;
60
+ }
61
+ };
62
+ }
63
+ }
64
+ /**
65
+ * Shared ambient log context ( browser, synchronous fallback ).
66
+ */
67
+ exports.LogContext = new LogContextImpl();
68
+ /**
69
+ * Projects only primitive scalar values ( string / number / boolean / bigint )
70
+ * from an ambient-context object, dropping objects, arrays, Dates, functions,
71
+ * null and undefined. Ambient context is meant for correlation ids ( requestId,
72
+ * traceId, ... ) that belong on every log line; structured payloads should be
73
+ * passed explicitly per call ( log.info({ obj }, ... ) ), not via ambient context.
74
+ */
75
+ function scalarContext(ctx) {
76
+ const out = {};
77
+ for (const [k, v] of Object.entries(ctx)) {
78
+ const t = typeof v;
79
+ if (t === "string" || t === "number" || t === "boolean" || t === "bigint") {
80
+ out[k] = v;
81
+ }
82
+ }
83
+ return out;
84
+ }
85
+ //# sourceMappingURL=context.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.browser.js","sourceRoot":"","sources":["../../src/context.browser.ts"],"names":[],"mappings":";;;AAwEA,sCASC;AAjFD;;;;;;;;;;GAUG;AACH,MAAM,cAAc;IAApB;QACU,YAAO,GAA4B,EAAE,CAAC;IA8ChD,CAAC;IA5CC;;OAEG;IACI,MAAM;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,IAAI,CAAI,IAA6B,EAAE,EAAW;QACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC;QACxC,IAAI,CAAC;YACH,OAAO,EAAE,EAAE,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;QAC1B,CAAC;IACH,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,GAAW,EAAE,KAAc;QACpC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,IAAI,CAAyB,EAAkB;QACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;QAC9B,OAAO,CAAC,GAAG,IAAO,EAAK,EAAE;YACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;YAC9B,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;YACxB,IAAI,CAAC;gBACH,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACrB,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;YAC1B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACU,QAAA,UAAU,GAAG,IAAI,cAAc,EAAE,CAAC;AAE/C;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,GAA4B;IACxD,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1E,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Ambient log context backed by `node:async_hooks` AsyncLocalStorage.
3
+ *
4
+ * It deliberately resolves the SAME DI-singleton AsyncLocalStorage instance the
5
+ * @spinajs/http module runs per action ( `als.run(req.storage, ...)` ). Because
6
+ * that instance is a shared DI singleton, any log emitted anywhere inside a
7
+ * request automatically inherits the request store ( requestId, realIp, ... )
8
+ * with zero threading — the log package wires `setLogContextProvider(() =>
9
+ * LogContext.active())` so `createLogMessageObject` merges it at lowest
10
+ * precedence.
11
+ *
12
+ * The store type is a plain `Record<string, unknown>` — a superset of http's
13
+ * `IActionLocalStoregeContext` — so log stays independent of http.
14
+ */
15
+ declare class LogContextImpl {
16
+ /**
17
+ * Resolve the shared AsyncLocalStorage from DI. Resolved as a bare concrete
18
+ * class it is a shared singleton, so this is the very instance http drives per
19
+ * action. We deliberately do NOT cache the reference: DI returns the same
20
+ * singleton on every call ( cheap lookup ), and NOT caching keeps LogContext
21
+ * consistent with the current DI instance even if the container is reset /
22
+ * re-registered ( a stale cached reference would silently diverge — e.g. after
23
+ * a `DI.clearCache()` the store written via a freshly-resolved instance would
24
+ * be invisible here ).
25
+ */
26
+ private storage;
27
+ /**
28
+ * The current ambient store, or an empty object when outside any context.
29
+ */
30
+ active(): Record<string, unknown>;
31
+ /**
32
+ * Run `fn` with `vars` merged ( copy-on-write ) onto the current store, so
33
+ * nesting accumulates and http's already-set fields ( eg. requestId ) survive.
34
+ */
35
+ with<T>(vars: Record<string, unknown>, fn: () => T): T;
36
+ /**
37
+ * Mutate the current store in place ( late-bound values ). No-op when called
38
+ * outside any active context.
39
+ */
40
+ set(key: string, value: unknown): void;
41
+ /**
42
+ * Capture the current store and re-attach it whenever the returned function is
43
+ * invoked. Use to carry context across detached callbacks / EventEmitter
44
+ * handlers that would otherwise lose it.
45
+ */
46
+ bind<A extends unknown[], R>(fn: (...a: A) => R): (...a: A) => R;
47
+ }
48
+ /**
49
+ * Shared ambient log context. See {@link LogContextImpl}.
50
+ */
51
+ export declare const LogContext: LogContextImpl;
52
+ /**
53
+ * Projects only primitive scalar values ( string / number / boolean / bigint )
54
+ * from an ambient-context object, dropping objects, arrays, Dates, functions,
55
+ * null and undefined. Ambient context is meant for correlation ids ( requestId,
56
+ * traceId, ... ) that belong on every log line; structured payloads should be
57
+ * passed explicitly per call ( log.info({ obj }, ... ) ), not via ambient context.
58
+ */
59
+ export declare function scalarContext(ctx: Record<string, unknown>): Record<string, unknown>;
60
+ export {};
61
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,cAAM,cAAc;IAClB;;;;;;;;;OASG;IACH,OAAO,CAAC,OAAO;IAIf;;OAEG;IACI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIxC;;;OAGG;IACI,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAI7D;;;OAGG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAO7C;;;;OAIG;IACI,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;CAOxE;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,gBAAuB,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASnF"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogContext = void 0;
4
+ exports.scalarContext = scalarContext;
5
+ const node_async_hooks_1 = require("node:async_hooks");
6
+ const di_1 = require("@spinajs/di");
7
+ /**
8
+ * Ambient log context backed by `node:async_hooks` AsyncLocalStorage.
9
+ *
10
+ * It deliberately resolves the SAME DI-singleton AsyncLocalStorage instance the
11
+ * @spinajs/http module runs per action ( `als.run(req.storage, ...)` ). Because
12
+ * that instance is a shared DI singleton, any log emitted anywhere inside a
13
+ * request automatically inherits the request store ( requestId, realIp, ... )
14
+ * with zero threading — the log package wires `setLogContextProvider(() =>
15
+ * LogContext.active())` so `createLogMessageObject` merges it at lowest
16
+ * precedence.
17
+ *
18
+ * The store type is a plain `Record<string, unknown>` — a superset of http's
19
+ * `IActionLocalStoregeContext` — so log stays independent of http.
20
+ */
21
+ class LogContextImpl {
22
+ /**
23
+ * Resolve the shared AsyncLocalStorage from DI. Resolved as a bare concrete
24
+ * class it is a shared singleton, so this is the very instance http drives per
25
+ * action. We deliberately do NOT cache the reference: DI returns the same
26
+ * singleton on every call ( cheap lookup ), and NOT caching keeps LogContext
27
+ * consistent with the current DI instance even if the container is reset /
28
+ * re-registered ( a stale cached reference would silently diverge — e.g. after
29
+ * a `DI.clearCache()` the store written via a freshly-resolved instance would
30
+ * be invisible here ).
31
+ */
32
+ storage() {
33
+ return di_1.DI.resolve(node_async_hooks_1.AsyncLocalStorage);
34
+ }
35
+ /**
36
+ * The current ambient store, or an empty object when outside any context.
37
+ */
38
+ active() {
39
+ return this.storage().getStore() ?? {};
40
+ }
41
+ /**
42
+ * Run `fn` with `vars` merged ( copy-on-write ) onto the current store, so
43
+ * nesting accumulates and http's already-set fields ( eg. requestId ) survive.
44
+ */
45
+ with(vars, fn) {
46
+ return this.storage().run({ ...this.active(), ...vars }, fn);
47
+ }
48
+ /**
49
+ * Mutate the current store in place ( late-bound values ). No-op when called
50
+ * outside any active context.
51
+ */
52
+ set(key, value) {
53
+ const store = this.storage().getStore();
54
+ if (store) {
55
+ store[key] = value;
56
+ }
57
+ }
58
+ /**
59
+ * Capture the current store and re-attach it whenever the returned function is
60
+ * invoked. Use to carry context across detached callbacks / EventEmitter
61
+ * handlers that would otherwise lose it.
62
+ */
63
+ bind(fn) {
64
+ const store = this.storage().getStore();
65
+ if (!store) {
66
+ return fn;
67
+ }
68
+ return (...args) => this.storage().run(store, () => fn(...args));
69
+ }
70
+ }
71
+ /**
72
+ * Shared ambient log context. See {@link LogContextImpl}.
73
+ */
74
+ exports.LogContext = new LogContextImpl();
75
+ /**
76
+ * Projects only primitive scalar values ( string / number / boolean / bigint )
77
+ * from an ambient-context object, dropping objects, arrays, Dates, functions,
78
+ * null and undefined. Ambient context is meant for correlation ids ( requestId,
79
+ * traceId, ... ) that belong on every log line; structured payloads should be
80
+ * passed explicitly per call ( log.info({ obj }, ... ) ), not via ambient context.
81
+ */
82
+ function scalarContext(ctx) {
83
+ const out = {};
84
+ for (const [k, v] of Object.entries(ctx)) {
85
+ const t = typeof v;
86
+ if (t === "string" || t === "number" || t === "boolean" || t === "bigint") {
87
+ out[k] = v;
88
+ }
89
+ }
90
+ return out;
91
+ }
92
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";;;AAoFA,sCASC;AA7FD,uDAAqD;AACrD,oCAAiC;AAEjC;;;;;;;;;;;;;GAaG;AACH,MAAM,cAAc;IAClB;;;;;;;;;OASG;IACK,OAAO;QACb,OAAO,OAAE,CAAC,OAAO,CAAC,oCAAiB,CAA+C,CAAC;IACrF,CAAC;IAED;;OAEG;IACI,MAAM;QACX,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzC,CAAC;IAED;;;OAGG;IACI,IAAI,CAAI,IAA6B,EAAE,EAAW;QACvD,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED;;;OAGG;IACI,GAAG,CAAC,GAAW,EAAE,KAAc;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;QACxC,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACrB,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAyB,EAAkB;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,CAAC,GAAG,IAAO,EAAK,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACzE,CAAC;CACF;AAED;;GAEG;AACU,QAAA,UAAU,GAAG,IAAI,cAAc,EAAE,CAAC;AAE/C;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,GAA4B;IACxD,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1E,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { ILogEntry, ILogFilterOptions, LogFilter, LogLevel, StrToLogLevel } from "@spinajs/log-common";
2
+ type LevelName = keyof typeof StrToLogLevel;
3
+ /**
4
+ * Options for {@link LevelFilter}.
5
+ */
6
+ export interface ILevelFilterOptions extends ILogFilterOptions {
7
+ /** Lowest level to keep ( inclusive ). Entries below are dropped. */
8
+ min?: LevelName;
9
+ /** Highest level to keep ( inclusive ). Entries above are dropped. */
10
+ max?: LevelName;
11
+ }
12
+ /**
13
+ * Level-window filter. Keeps an entry only when its numeric {@link LogLevel} is
14
+ * within `[min, max]` ( both inclusive, both optional ), otherwise drops it.
15
+ * Useful for routing eg. only warn..error to a given target via a filter.
16
+ */
17
+ export declare class LevelFilter extends LogFilter {
18
+ protected min: LogLevel;
19
+ protected max: LogLevel;
20
+ constructor(options?: ILevelFilterOptions);
21
+ apply(entry: ILogEntry): ILogEntry | null;
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=LevelFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LevelFilter.d.ts","sourceRoot":"","sources":["../../../src/filters/LevelFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGvG,KAAK,SAAS,GAAG,MAAM,OAAO,aAAa,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,qEAAqE;IACrE,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,sEAAsE;IACtE,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB;AAED;;;;GAIG;AACH,qBAEa,WAAY,SAAQ,SAAS;IACxC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;IACxB,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;gBAEZ,OAAO,CAAC,EAAE,mBAAmB;IAMlC,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI;CAMjD"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LevelFilter = void 0;
13
+ const log_common_1 = require("@spinajs/log-common");
14
+ const di_1 = require("@spinajs/di");
15
+ /**
16
+ * Level-window filter. Keeps an entry only when its numeric {@link LogLevel} is
17
+ * within `[min, max]` ( both inclusive, both optional ), otherwise drops it.
18
+ * Useful for routing eg. only warn..error to a given target via a filter.
19
+ */
20
+ let LevelFilter = class LevelFilter extends log_common_1.LogFilter {
21
+ constructor(options) {
22
+ super(options);
23
+ this.min = options?.min !== undefined ? log_common_1.StrToLogLevel[options.min] : log_common_1.LogLevel.Trace;
24
+ this.max = options?.max !== undefined ? log_common_1.StrToLogLevel[options.max] : log_common_1.LogLevel.Security;
25
+ }
26
+ apply(entry) {
27
+ if (entry.Level < this.min || entry.Level > this.max) {
28
+ return null;
29
+ }
30
+ return entry;
31
+ }
32
+ };
33
+ exports.LevelFilter = LevelFilter;
34
+ exports.LevelFilter = LevelFilter = __decorate([
35
+ (0, di_1.Injectable)("LevelFilter"),
36
+ (0, di_1.NewInstance)(),
37
+ __metadata("design:paramtypes", [Object])
38
+ ], LevelFilter);
39
+ //# sourceMappingURL=LevelFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LevelFilter.js","sourceRoot":"","sources":["../../../src/filters/LevelFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAuG;AACvG,oCAAsD;AActD;;;;GAIG;AAGI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,sBAAS;IAIxC,YAAY,OAA6B;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,0BAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,qBAAQ,CAAC,KAAK,CAAC;QACpF,IAAI,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,0BAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,qBAAQ,CAAC,QAAQ,CAAC;IACzF,CAAC;IAEM,KAAK,CAAC,KAAgB;QAC3B,IAAI,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAhBY,kCAAW;sBAAX,WAAW;IAFvB,IAAA,eAAU,EAAC,aAAa,CAAC;IACzB,IAAA,gBAAW,GAAE;;GACD,WAAW,CAgBvB"}
@@ -0,0 +1,30 @@
1
+ import { ILogEntry, ILogFilterOptions, LogFilter } from "@spinajs/log-common";
2
+ /**
3
+ * Options for {@link MatchFilter}.
4
+ */
5
+ export interface IMatchFilterOptions extends ILogFilterOptions {
6
+ /** Regex source tested against the chosen field. Required. */
7
+ pattern: string;
8
+ /** Variable field to test. Default "message". */
9
+ field?: string;
10
+ /** "keep" ( default ) keeps on match, drops otherwise; "drop" drops on match. */
11
+ mode?: "keep" | "drop";
12
+ /** RegExp flags ( eg. "i" ). */
13
+ flags?: string;
14
+ }
15
+ /**
16
+ * Regex keep/drop filter. Builds a RegExp from `pattern`/`flags` and tests it
17
+ * against `String(entry.Variables[field])` ( field defaults to "message" ).
18
+ * In "keep" mode the entry is kept only on a match; in "drop" mode it is
19
+ * dropped on a match. An invalid pattern degrades to a no-op ( pass-through )
20
+ * and warns ONCE so a bad config never silently swallows or drops everything.
21
+ */
22
+ export declare class MatchFilter extends LogFilter {
23
+ protected regex: RegExp | null;
24
+ protected field: string;
25
+ protected mode: "keep" | "drop";
26
+ protected warned: boolean;
27
+ constructor(options?: IMatchFilterOptions);
28
+ apply(entry: ILogEntry): ILogEntry | null;
29
+ }
30
+ //# sourceMappingURL=MatchFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MatchFilter.d.ts","sourceRoot":"","sources":["../../../src/filters/MatchFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG9E;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,qBAEa,WAAY,SAAQ,SAAS;IACxC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IACtC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,SAAS,CAAC,MAAM,UAAS;gBAEb,OAAO,CAAC,EAAE,mBAAmB;IAqBlC,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI;CAejD"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MatchFilter = void 0;
13
+ const log_common_1 = require("@spinajs/log-common");
14
+ const di_1 = require("@spinajs/di");
15
+ /**
16
+ * Regex keep/drop filter. Builds a RegExp from `pattern`/`flags` and tests it
17
+ * against `String(entry.Variables[field])` ( field defaults to "message" ).
18
+ * In "keep" mode the entry is kept only on a match; in "drop" mode it is
19
+ * dropped on a match. An invalid pattern degrades to a no-op ( pass-through )
20
+ * and warns ONCE so a bad config never silently swallows or drops everything.
21
+ */
22
+ let MatchFilter = class MatchFilter extends log_common_1.LogFilter {
23
+ constructor(options) {
24
+ super(options);
25
+ this.regex = null;
26
+ this.warned = false;
27
+ this.field = options?.field ?? "message";
28
+ this.mode = options?.mode ?? "keep";
29
+ try {
30
+ if (options?.pattern === undefined) {
31
+ throw new Error("MatchFilter requires a `pattern` option");
32
+ }
33
+ // eslint-disable-next-line security/detect-non-literal-regexp
34
+ this.regex = new RegExp(options.pattern, options.flags);
35
+ }
36
+ catch (err) {
37
+ this.regex = null;
38
+ // no-op on bad config; warn once to the raw console ( never re-enter the
39
+ // logger pipeline ) so a broken filter is visible but harmless.
40
+ // eslint-disable-next-line no-console
41
+ console.warn(`MatchFilter: invalid pattern "${options?.pattern}" - filter disabled ( no-op ). ${err.message}`);
42
+ this.warned = true;
43
+ }
44
+ }
45
+ apply(entry) {
46
+ // invalid / missing pattern => no-op pass-through
47
+ if (!this.regex) {
48
+ return entry;
49
+ }
50
+ const value = String(entry.Variables[this.field]);
51
+ const matched = this.regex.test(value);
52
+ if (this.mode === "drop") {
53
+ return matched ? null : entry;
54
+ }
55
+ // keep mode
56
+ return matched ? entry : null;
57
+ }
58
+ };
59
+ exports.MatchFilter = MatchFilter;
60
+ exports.MatchFilter = MatchFilter = __decorate([
61
+ (0, di_1.Injectable)("MatchFilter"),
62
+ (0, di_1.NewInstance)(),
63
+ __metadata("design:paramtypes", [Object])
64
+ ], MatchFilter);
65
+ //# sourceMappingURL=MatchFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MatchFilter.js","sourceRoot":"","sources":["../../../src/filters/MatchFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA8E;AAC9E,oCAAsD;AAgBtD;;;;;;GAMG;AAGI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,sBAAS;IAMxC,YAAY,OAA6B;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QANP,UAAK,GAAkB,IAAI,CAAC;QAG5B,WAAM,GAAG,KAAK,CAAC;QAIvB,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,SAAS,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,MAAM,CAAC;QAEpC,IAAI,CAAC;YACH,IAAI,OAAO,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;gBACnC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;YAC7D,CAAC;YACD,8DAA8D;YAC9D,IAAI,CAAC,KAAK,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC1D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,yEAAyE;YACzE,gEAAgE;YAChE,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,iCAAiC,OAAO,EAAE,OAAO,kCAAmC,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1H,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,KAAgB;QAC3B,kDAAkD;QAClD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEvC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACzB,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QAChC,CAAC;QACD,YAAY;QACZ,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAChC,CAAC;CACF,CAAA;AA1CY,kCAAW;sBAAX,WAAW;IAFvB,IAAA,eAAU,EAAC,aAAa,CAAC;IACzB,IAAA,gBAAW,GAAE;;GACD,WAAW,CA0CvB"}
@@ -0,0 +1,37 @@
1
+ import { ILogEntry, ILogFilterOptions, LogFilter } from "@spinajs/log-common";
2
+ /**
3
+ * Options for {@link RateLimitFilter}.
4
+ */
5
+ export interface IRateLimitFilterOptions extends ILogFilterOptions {
6
+ /** Max entries kept per window. Required. */
7
+ limit: number;
8
+ /** Fixed window length in SECONDS. Required. */
9
+ intervalSeconds: number;
10
+ /** Variable field used to bucket the limit ( eg. per-logger ). Global if unset. */
11
+ key?: string;
12
+ }
13
+ interface IWindowRecord {
14
+ count: number;
15
+ windowStart: number;
16
+ }
17
+ /**
18
+ * Fixed-window rate limiter. Keeps at most `limit` entries per `intervalSeconds`
19
+ * window, bucketed by `entry.Variables[key]` when `key` is given ( else a single
20
+ * global bucket ). Overflow entries within a window are DROPPED; the counter
21
+ * resets when the window elapses. The bucket map is self-pruning ( stale windows
22
+ * dropped on access ) so memory stays bounded. Clock is injectable for tests.
23
+ */
24
+ export declare class RateLimitFilter extends LogFilter {
25
+ protected now: () => number;
26
+ protected limit: number;
27
+ protected intervalMs: number;
28
+ protected keyField?: string;
29
+ protected windows: Map<string, IWindowRecord>;
30
+ constructor(options?: IRateLimitFilterOptions, now?: () => number);
31
+ protected keyOf(entry: ILogEntry): string;
32
+ apply(entry: ILogEntry): ILogEntry | null;
33
+ /** Drops windows whose interval has fully elapsed so the map stays bounded. */
34
+ protected prune(now: number): void;
35
+ }
36
+ export {};
37
+ //# sourceMappingURL=RateLimitFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RateLimitFilter.d.ts","sourceRoot":"","sources":["../../../src/filters/RateLimitFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG9E;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,eAAe,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAID;;;;;;GAMG;AACH,qBAEa,eAAgB,SAAQ,SAAS;IAMG,SAAS,CAAC,GAAG,EAAE,MAAM,MAAM;IAL1E,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAa;gBAE9C,OAAO,CAAC,EAAE,uBAAuB,EAAY,GAAG,GAAE,MAAM,MAAyB;IAO7F,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAOlC,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI;IAqBhD,+EAA+E;IAC/E,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAOnC"}