@spinajs/log 2.0.481 → 2.0.484

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 +55 -0
  90. package/lib/cjs/perf/LogMetricSink.d.ts.map +1 -0
  91. package/lib/cjs/perf/LogMetricSink.js +154 -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 +55 -0
  240. package/lib/mjs/perf/LogMetricSink.d.ts.map +1 -0
  241. package/lib/mjs/perf/LogMetricSink.js +151 -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 +26 -15
@@ -0,0 +1,151 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Singleton, Injectable } from "@spinajs/di";
11
+ import { Config } from "@spinajs/configuration";
12
+ import { Logger, Log, PerfSink } from "@spinajs/log-common";
13
+ /**
14
+ * Default {@link PerfSink}: renders perf measurements as structured log entries
15
+ * through the normal targets/filters/rules pipeline, on a dedicated `perf`
16
+ * logger. Spans over their per-name threshold log at `warn`; under-threshold
17
+ * spans log at `trace` ( kept for on-demand visibility, cheaply gated out when
18
+ * trace routing is off ). Rollups log one `info` line.
19
+ */
20
+ let LogMetricSink = class LogMetricSink extends PerfSink {
21
+ logsUnderThreshold(name) {
22
+ const setting = this.LogUnderThreshold ?? false;
23
+ return Array.isArray(setting) ? setting.includes(name) : setting === true;
24
+ }
25
+ thresholdFor(name) {
26
+ const t = this.Thresholds ?? {};
27
+ return t[name] ?? t.default ?? 0;
28
+ }
29
+ /**
30
+ * Renders the statement into the message. The `sql` field is already attached to
31
+ * the entry, but most console layouts print only `${message}`, so
32
+ * "Slow orm.query: 251.1ms" on its own gives no way to tell WHICH query it was.
33
+ *
34
+ * Bindings are deliberately left out of the message - they routinely hold
35
+ * passwords, tokens and personal data. They stay in the structured fields, where a
36
+ * target can opt into them.
37
+ */
38
+ sqlSuffix(fields) {
39
+ const sql = fields.sql;
40
+ if (typeof sql !== "string" || sql.trim().length === 0) {
41
+ return "";
42
+ }
43
+ const flattened = sql.replace(/\s+/g, " ").trim();
44
+ const max = this.SqlMaxLength ?? 2000;
45
+ const clipped = flattened.length > max ? `${flattened.slice(0, max)}...` : flattened;
46
+ return ` - ${clipped}`;
47
+ }
48
+ collect(metric) {
49
+ if (!this.Enabled)
50
+ return;
51
+ if (metric.kind === "span") {
52
+ const dur = metric.durationMs ?? 0;
53
+ // `metric.fields` already carries `error` for a failed span ( set by the
54
+ // facade ), so the log's error serializer runs when this object is logged.
55
+ const fields = { durationMs: dur, ...(metric.labels ?? {}), ...(metric.fields ?? {}) };
56
+ if (metric.error !== undefined) {
57
+ this.emitAt("error", `${metric.name} failed after ${dur.toFixed(1)}ms${this.sqlSuffix(fields)}`, fields);
58
+ return;
59
+ }
60
+ const threshold = this.thresholdFor(metric.name);
61
+ const slow = threshold > 0 && dur >= threshold;
62
+ if (!slow && !this.logsUnderThreshold(metric.name)) {
63
+ return;
64
+ }
65
+ const level = slow ? this.OverLevel : this.UnderLevel;
66
+ this.emitAt(level, `${slow ? "Slow " : ""}${metric.name}: ${dur.toFixed(1)}ms${this.sqlSuffix(fields)}`, fields);
67
+ return;
68
+ }
69
+ if (this.LogCounters && (metric.kind === "counter" || metric.kind === "value")) {
70
+ this.emitAt("trace", `${metric.name}=${metric.value}`, { ...(metric.labels ?? {}) });
71
+ }
72
+ }
73
+ onScopeEnd(rollup) {
74
+ if (!this.Enabled)
75
+ return;
76
+ const parts = Object.entries(rollup.byName)
77
+ .map(([n, e]) => `${n} x${e.count} ${e.totalMs.toFixed(0)}ms`)
78
+ .join(", ");
79
+ const tag = rollup.requestId ? ` [${rollup.requestId}]` : "";
80
+ this.emitAt("info", `perf rollup${tag}: ${parts || "no measurements"}`, {
81
+ requestId: rollup.requestId,
82
+ totalMs: rollup.totalMs,
83
+ byName: rollup.byName,
84
+ ...(rollup.labels ?? {}),
85
+ });
86
+ }
87
+ /**
88
+ * Emit through the log's MERGING-OBJECT form ( fields object FIRST, then the
89
+ * message string ) so the structured variables ( durationMs, labels, sql,
90
+ * error ) are attached to the entry. The `@spinajs/log` API treats a trailing
91
+ * object as a printf argument, so passing fields last would silently drop
92
+ * them. See the `warn(fields, message?)` overload on the `Log` base class.
93
+ */
94
+ emitAt(level, message, fields) {
95
+ switch (level) {
96
+ case "error":
97
+ this.Log.error(fields, message);
98
+ break;
99
+ case "warn":
100
+ this.Log.warn(fields, message);
101
+ break;
102
+ case "info":
103
+ this.Log.info(fields, message);
104
+ break;
105
+ case "debug":
106
+ this.Log.debug(fields, message);
107
+ break;
108
+ default:
109
+ this.Log.trace(fields, message);
110
+ break;
111
+ }
112
+ }
113
+ };
114
+ __decorate([
115
+ Logger("perf"),
116
+ __metadata("design:type", Log)
117
+ ], LogMetricSink.prototype, "Log", void 0);
118
+ __decorate([
119
+ Config("logger.perf.enabled", { defaultValue: true }),
120
+ __metadata("design:type", Boolean)
121
+ ], LogMetricSink.prototype, "Enabled", void 0);
122
+ __decorate([
123
+ Config("logger.perf.thresholds", { defaultValue: { "orm.query": 200, "http.request": 1000, default: 0 } }),
124
+ __metadata("design:type", Object)
125
+ ], LogMetricSink.prototype, "Thresholds", void 0);
126
+ __decorate([
127
+ Config("logger.perf.overThresholdLevel", { defaultValue: "warn" }),
128
+ __metadata("design:type", String)
129
+ ], LogMetricSink.prototype, "OverLevel", void 0);
130
+ __decorate([
131
+ Config("logger.perf.underThresholdLevel", { defaultValue: "trace" }),
132
+ __metadata("design:type", String)
133
+ ], LogMetricSink.prototype, "UnderLevel", void 0);
134
+ __decorate([
135
+ Config("logger.perf.logCounters", { defaultValue: false }),
136
+ __metadata("design:type", Boolean)
137
+ ], LogMetricSink.prototype, "LogCounters", void 0);
138
+ __decorate([
139
+ Config("logger.perf.sqlMaxLength", { defaultValue: 2000 }),
140
+ __metadata("design:type", Number)
141
+ ], LogMetricSink.prototype, "SqlMaxLength", void 0);
142
+ __decorate([
143
+ Config("logger.perf.logUnderThreshold", { defaultValue: false }),
144
+ __metadata("design:type", Object)
145
+ ], LogMetricSink.prototype, "LogUnderThreshold", void 0);
146
+ LogMetricSink = __decorate([
147
+ Singleton(),
148
+ Injectable(PerfSink)
149
+ ], LogMetricSink);
150
+ export { LogMetricSink };
151
+ //# sourceMappingURL=LogMetricSink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogMetricSink.js","sourceRoot":"","sources":["../../../src/perf/LogMetricSink.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAA4B,MAAM,qBAAqB,CAAC;AAEtF;;;;;;GAMG;AAGI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,QAAQ;IAuCjC,kBAAkB,CAAC,IAAY;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,IAAI,KAAK,CAAC;QAChD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC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AAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAChC,MAAM;YACR;gBACE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAChC,MAAM;QACV,CAAC;IACH,CAAC;CACF,CAAA;AA7IW;IADT,MAAM,CAAC,MAAM,CAAC;8BACC,GAAG;0CAAC;AAGV;IADT,MAAM,CAAC,qBAAqB,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;;8CAC1B;AAGlB;IADT,MAAM,CAAC,wBAAwB,EAAE,EAAE,YAAY,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;;iDAC7D;AAGpC;IADT,MAAM,CAAC,gCAAgC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;;gDACC;AAG1D;IADT,MAAM,CAAC,iCAAiC,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;;iDACA;AAG3D;IADT,MAAM,CAAC,yBAAyB,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;;kDAC3B;AAGtB;IADT,MAAM,CAAC,0BAA0B,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;;mDAC3B;AAiBtB;IADT,MAAM,CAAC,+BAA+B,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;;wDAChB;AArCtC,aAAa;IAFzB,SAAS,EAAE;IACX,UAAU,CAAC,QAAQ,CAAC;GACR,aAAa,CA+IzB"}
@@ -0,0 +1,9 @@
1
+ import { IMeasureOpts } from "@spinajs/log-common";
2
+ /**
3
+ * Method decorator that times the wrapped method via {@link Perf.measure}. Name
4
+ * defaults to `${ClassName}.${method}`. Works for sync and async methods ( the
5
+ * facade awaits a returned thenable ). Uses the same legacy-decorator signature
6
+ * as the rest of the framework ( `experimentalDecorators` ).
7
+ */
8
+ export declare function Measure(name?: string, opts?: IMeasureOpts): (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
9
+ //# sourceMappingURL=measure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../../src/perf/measure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,IACvC,QAAQ,MAAM,EAAE,aAAa,MAAM,GAAG,MAAM,EAAE,YAAY,kBAAkB,KAAG,kBAAkB,CAQnH"}
@@ -0,0 +1,18 @@
1
+ import { Perf } from "@spinajs/log-common";
2
+ /**
3
+ * Method decorator that times the wrapped method via {@link Perf.measure}. Name
4
+ * defaults to `${ClassName}.${method}`. Works for sync and async methods ( the
5
+ * facade awaits a returned thenable ). Uses the same legacy-decorator signature
6
+ * as the rest of the framework ( `experimentalDecorators` ).
7
+ */
8
+ export function Measure(name, opts) {
9
+ return function (target, propertyKey, descriptor) {
10
+ const original = descriptor.value;
11
+ const metricName = name ?? `${target.constructor.name}.${String(propertyKey)}`;
12
+ descriptor.value = function (...args) {
13
+ return Perf.measure(metricName, () => original.apply(this, args), opts);
14
+ };
15
+ return descriptor;
16
+ };
17
+ }
18
+ //# sourceMappingURL=measure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measure.js","sourceRoot":"","sources":["../../../src/perf/measure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,qBAAqB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,IAAa,EAAE,IAAmB;IACxD,OAAO,UAAU,MAAc,EAAE,WAA4B,EAAE,UAA8B;QAC3F,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAwC,CAAC;QACrE,MAAM,UAAU,GAAG,IAAI,IAAI,GAAI,MAA4C,CAAC,WAAW,CAAC,IAAI,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QACtH,UAAU,CAAC,KAAK,GAAG,UAAyB,GAAG,IAAe;YAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;QAC1E,CAAC,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Install the per-request perf-scope backend for the node runtime. Reads the
3
+ * `perf` accumulator off the ambient async store ( which IS `req.storage` when
4
+ * http runs an action, so the scope created by the http PerfRollup middleware
5
+ * and mutated during the action is one and the same object ). Called from
6
+ * {@link LogBotstrapper.bootstrap}.
7
+ */
8
+ export declare function wirePerfScope(): void;
9
+ //# sourceMappingURL=perf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perf.d.ts","sourceRoot":"","sources":["../../src/perf.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAIpC"}
@@ -0,0 +1,15 @@
1
+ import { setPerfScopeBackend } from "@spinajs/log-common";
2
+ import { LogContext } from "./context.js";
3
+ /**
4
+ * Install the per-request perf-scope backend for the node runtime. Reads the
5
+ * `perf` accumulator off the ambient async store ( which IS `req.storage` when
6
+ * http runs an action, so the scope created by the http PerfRollup middleware
7
+ * and mutated during the action is one and the same object ). Called from
8
+ * {@link LogBotstrapper.bootstrap}.
9
+ */
10
+ export function wirePerfScope() {
11
+ setPerfScopeBackend({
12
+ get: () => LogContext.active().perf ?? null,
13
+ });
14
+ }
15
+ //# sourceMappingURL=perf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perf.js","sourceRoot":"","sources":["../../src/perf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAc,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IAC3B,mBAAmB,CAAC;QAClB,GAAG,EAAE,GAAG,EAAE,CAAE,UAAU,CAAC,MAAM,EAAE,CAAC,IAA+B,IAAI,IAAI;KACxE,CAAC,CAAC;AACL,CAAC"}
@@ -24,29 +24,153 @@ declare const CONFIGURATION_SCHEMA: {
24
24
  enabled: {
25
25
  type: string;
26
26
  };
27
- path: {
28
- type: string;
29
- };
30
- archivePath: {
31
- type: string;
32
- };
33
- maxSize: {
34
- type: string;
35
- minimum: number;
36
- };
37
- compress: {
38
- type: string;
39
- };
40
- rotate: {
27
+ filters: {
28
+ description: string;
41
29
  type: string;
30
+ items: {
31
+ type: string;
32
+ properties: {
33
+ type: {
34
+ description: string;
35
+ type: string;
36
+ };
37
+ };
38
+ required: string[];
39
+ };
42
40
  };
43
- maxArchiveFiles: {
41
+ options: {
44
42
  type: string;
45
- minimum: number;
43
+ properties: {
44
+ path: {
45
+ description: string;
46
+ type: string;
47
+ };
48
+ archivePath: {
49
+ description: string;
50
+ type: string;
51
+ };
52
+ fs: {
53
+ description: string;
54
+ type: string;
55
+ };
56
+ archiveFs: {
57
+ description: string;
58
+ type: string;
59
+ };
60
+ archiveStrategy: {
61
+ description: string;
62
+ type: string;
63
+ };
64
+ retentionStrategies: {
65
+ description: string;
66
+ type: string;
67
+ items: {
68
+ type: string;
69
+ };
70
+ };
71
+ maxSize: {
72
+ description: string;
73
+ type: string;
74
+ minimum: number;
75
+ };
76
+ compress: {
77
+ description: string;
78
+ type: string;
79
+ };
80
+ rotate: {
81
+ description: string;
82
+ type: string;
83
+ };
84
+ maxBufferSize: {
85
+ description: string;
86
+ type: string;
87
+ minimum: number;
88
+ };
89
+ maxQueueSize: {
90
+ description: string;
91
+ type: string;
92
+ minimum: number;
93
+ };
94
+ maxArchiveFiles: {
95
+ description: string;
96
+ type: string;
97
+ minimum: number;
98
+ };
99
+ maxAge: {
100
+ description: string;
101
+ type: string;
102
+ minimum: number;
103
+ };
104
+ archiveInterval: {
105
+ description: string;
106
+ type: string;
107
+ minimum: number;
108
+ };
109
+ flushInterval: {
110
+ description: string;
111
+ type: string;
112
+ minimum: number;
113
+ };
114
+ };
115
+ required: string[];
46
116
  };
47
- bufferSize: {
117
+ };
118
+ required: string[];
119
+ };
120
+ };
121
+ file: {
122
+ description: string;
123
+ type: string;
124
+ };
125
+ perf: {
126
+ description: string;
127
+ type: string;
128
+ properties: {
129
+ enabled: {
130
+ type: string;
131
+ };
132
+ thresholds: {
133
+ description: string;
134
+ type: string;
135
+ };
136
+ overThresholdLevel: {
137
+ type: string;
138
+ enum: string[];
139
+ };
140
+ underThresholdLevel: {
141
+ type: string;
142
+ enum: string[];
143
+ };
144
+ logCounters: {
145
+ type: string;
146
+ };
147
+ };
148
+ };
149
+ whenRepeated: {
150
+ description: string;
151
+ type: string;
152
+ properties: {
153
+ timeout: {
154
+ description: string;
155
+ type: string;
156
+ minimum: number;
157
+ };
158
+ maxKeys: {
159
+ description: string;
160
+ type: string;
161
+ minimum: number;
162
+ };
163
+ };
164
+ };
165
+ filters: {
166
+ description: string;
167
+ type: string;
168
+ items: {
169
+ type: string;
170
+ properties: {
171
+ type: {
172
+ description: string;
48
173
  type: string;
49
- minimum: number;
50
174
  };
51
175
  };
52
176
  required: string[];
@@ -67,6 +191,11 @@ declare const CONFIGURATION_SCHEMA: {
67
191
  type: string;
68
192
  enum: string[];
69
193
  };
194
+ maxLevel: {
195
+ description: string;
196
+ type: string;
197
+ enum: string[];
198
+ };
70
199
  target: {
71
200
  oneOf: ({
72
201
  type: string;
@@ -78,6 +207,10 @@ declare const CONFIGURATION_SCHEMA: {
78
207
  };
79
208
  })[];
80
209
  };
210
+ final: {
211
+ description: string;
212
+ type: string;
213
+ };
81
214
  };
82
215
  required: string[];
83
216
  };
@@ -1 +1 @@
1
- {"version":3,"file":"log.configuration.d.ts","sourceRoot":"","sources":["../../../src/schemas/log.configuration.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiGzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"log.configuration.d.ts","sourceRoot":"","sources":["../../../src/schemas/log.configuration.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0PzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -24,32 +24,147 @@ const CONFIGURATION_SCHEMA = {
24
24
  enabled: {
25
25
  type: "boolean",
26
26
  },
27
- path: {
28
- type: "string",
29
- },
30
- archivePath: {
31
- type: "string",
32
- },
33
- maxSize: {
34
- type: "integer",
35
- minimum: 10000,
27
+ filters: {
28
+ description: "Per-target filter pipeline, applied only when writing to THIS target ( after the logger-level filters ). Each item is { type, ...opts } where `type` is the DI name of a LogFilter. Any returning null drops the entry for this target only.",
29
+ type: "array",
30
+ items: {
31
+ type: "object",
32
+ properties: {
33
+ type: {
34
+ description: "DI string name of the registered LogFilter.",
35
+ type: "string",
36
+ },
37
+ },
38
+ required: ["type"],
39
+ },
36
40
  },
37
- compress: {
38
- type: "boolean",
41
+ // FileTarget options ( nested under `options` )
42
+ options: {
43
+ type: "object",
44
+ properties: {
45
+ path: {
46
+ description: "Active log path, relative to the `fs` provider base path. Variables allowed.",
47
+ type: "string",
48
+ },
49
+ archivePath: {
50
+ description: "Archive directory, relative to the `archiveFs` provider base path. Variables allowed.",
51
+ type: "string",
52
+ },
53
+ fs: {
54
+ description: "Registered @spinajs/fs provider for the active log. Defaults to 'fs-log-default'.",
55
+ type: "string",
56
+ },
57
+ archiveFs: {
58
+ description: "Registered @spinajs/fs provider archives are moved to. Defaults to `fs`.",
59
+ type: "string",
60
+ },
61
+ archiveStrategy: {
62
+ description: "LogArchiveStrategy class name deciding WHEN to rotate. Default 'SizeLogArchiveStrategy'.",
63
+ type: "string",
64
+ },
65
+ retentionStrategies: {
66
+ description: "LogRetentionStrategy class names applied in order after rotation. Default ['CountLogRetentionStrategy'].",
67
+ type: "array",
68
+ items: {
69
+ type: "string",
70
+ },
71
+ },
72
+ maxSize: {
73
+ description: "Max active log size in bytes before rotation.",
74
+ type: "integer",
75
+ minimum: 1,
76
+ },
77
+ compress: {
78
+ description: "Zip the archived file when moved to the archive.",
79
+ type: "boolean",
80
+ },
81
+ rotate: {
82
+ description: "Cron expression for CronLogArchiveStrategy ( 6-field with seconds ).",
83
+ type: "string",
84
+ },
85
+ maxBufferSize: {
86
+ description: "Max buffered messages before a flush.",
87
+ type: "integer",
88
+ minimum: 1,
89
+ },
90
+ maxQueueSize: {
91
+ description: "Hard cap on buffered messages; oldest are dropped past this so a down sink cannot OOM.",
92
+ type: "integer",
93
+ minimum: 1,
94
+ },
95
+ maxArchiveFiles: {
96
+ description: "How many archives to keep ( CountLogRetentionStrategy ). Oldest are deleted.",
97
+ type: "integer",
98
+ minimum: 1,
99
+ },
100
+ maxAge: {
101
+ description: "Max archive age in seconds ( AgeLogRetentionStrategy ).",
102
+ type: "integer",
103
+ minimum: 1,
104
+ },
105
+ archiveInterval: {
106
+ description: "Interval in seconds SizeLogArchiveStrategy checks the active log size.",
107
+ type: "integer",
108
+ minimum: 1,
109
+ },
110
+ flushInterval: {
111
+ description: "Periodic flush tick in milliseconds for a partially filled buffer.",
112
+ type: "integer",
113
+ minimum: 1,
114
+ },
115
+ },
116
+ required: ["path"],
39
117
  },
40
- rotate: {
118
+ },
119
+ required: ["name", "type"],
120
+ },
121
+ },
122
+ file: {
123
+ description: "Default FileTarget options ( buffer / rotation / retention tunables ) merged UNDER every file target's own `options`. Shipped by @spinajs/log ( see logger.file defaults ) and overridable by user config.",
124
+ type: "object",
125
+ },
126
+ perf: {
127
+ description: "Performance-instrumentation ( Perf facade ) options for the default LogMetricSink.",
128
+ type: "object",
129
+ properties: {
130
+ enabled: { type: "boolean" },
131
+ thresholds: {
132
+ description: "Per-metric-name slow threshold in ms. A name not present falls back to `default`; 0 means never slow.",
133
+ type: "object",
134
+ },
135
+ overThresholdLevel: { type: "string", enum: ["trace", "debug", "info", "warn", "error"] },
136
+ underThresholdLevel: { type: "string", enum: ["trace", "debug", "info", "warn", "error"] },
137
+ logCounters: { type: "boolean" },
138
+ },
139
+ },
140
+ whenRepeated: {
141
+ description: "Opt-in dedup filter. Collapses identical repeated log entries within a timeout window into one, emitting a (xN) count when logging resumes. Off when absent; global for now.",
142
+ type: "object",
143
+ properties: {
144
+ timeout: {
145
+ description: "Suppression window in SECONDS. Identical entries within this window are collapsed. Default 10.",
146
+ type: "integer",
147
+ minimum: 1,
148
+ },
149
+ maxKeys: {
150
+ description: "Hard cap on tracked keys; the map self-prunes ( expired first, then oldest ) so memory stays bounded. Default 1024.",
151
+ type: "integer",
152
+ minimum: 1,
153
+ },
154
+ },
155
+ },
156
+ filters: {
157
+ description: "Composable per-logger filter pipeline. Each item is { type, ...opts } where `type` is the DI name of a LogFilter ( eg. LevelFilter, MatchFilter, RateLimitFilter, WhenRepeatedFilter ). Filters run in order in write(); any returning null drops the entry.",
158
+ type: "array",
159
+ items: {
160
+ type: "object",
161
+ properties: {
162
+ type: {
163
+ description: "DI string name of the registered LogFilter.",
41
164
  type: "string",
42
165
  },
43
- maxArchiveFiles: {
44
- type: "integer",
45
- minimum: 1,
46
- },
47
- bufferSize: {
48
- type: "integer",
49
- minimum: 1000,
50
- },
51
166
  },
52
- required: ["name", "type"],
167
+ required: ["type"],
53
168
  },
54
169
  },
55
170
  rules: {
@@ -76,6 +191,20 @@ const CONFIGURATION_SCHEMA = {
76
191
  "success",
77
192
  ],
78
193
  },
194
+ maxLevel: {
195
+ description: "Optional INCLUSIVE upper bound of the level window this rule routes. With `level` as the lower bound, only entries in [level, maxLevel] are routed. Defaults to the highest level ( security ).",
196
+ type: "string",
197
+ enum: [
198
+ "trace",
199
+ "debug",
200
+ "warn",
201
+ "info",
202
+ "error",
203
+ "fatal",
204
+ "security",
205
+ "success",
206
+ ],
207
+ },
79
208
  target: {
80
209
  oneOf: [
81
210
  {
@@ -89,6 +218,10 @@ const CONFIGURATION_SCHEMA = {
89
218
  },
90
219
  ],
91
220
  },
221
+ final: {
222
+ description: "Stop evaluating further rules for a logger once this matching rule is applied ( NLog-style ). Earlier matched rules and this one still apply.",
223
+ type: "boolean",
224
+ },
92
225
  },
93
226
  required: ["name", "level", "target"],
94
227
  },
@@ -1 +1 @@
1
- {"version":3,"file":"log.configuration.js","sourceRoot":"","sources":["../../../src/schemas/log.configuration.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAG;IAC3B,GAAG,EAAE,uCAAuC;IAC5C,oBAAoB,EAAE,QAAQ;IAC9B,WAAW,EAAE,wCAAwC;IACrD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,OAAO,EAAE;YACP,WAAW,EACT,wEAAwE;YAC1E,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,CAAC;YACX,WAAW,EAAE,IAAI;YACjB,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;qBACf;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;qBACf;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;qBACf;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,SAAS;qBAChB;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;qBACf;oBACD,WAAW,EAAE;wBACX,IAAI,EAAE,QAAQ;qBACf;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,KAAK;qBACf;oBACD,QAAQ,EAAE;wBACR,IAAI,EAAE,SAAS;qBAChB;oBACD,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;qBACf;oBACD,eAAe,EAAE;wBACf,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,CAAC;qBACX;oBACD,UAAU,EAAE;wBACV,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,IAAI;qBACd;iBACF;gBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;aAC3B;SACF;QACD,KAAK,EAAE;YACL,WAAW,EAAE,2CAA2C;YACxD,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,CAAC;YACX,WAAW,EAAE,IAAI;YACjB,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;qBACf;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE;4BACJ,OAAO;4BACP,OAAO;4BACP,MAAM;4BACN,MAAM;4BACN,OAAO;4BACP,OAAO;4BACP,UAAU;4BACV,SAAS;yBACV;qBACF;oBACD,MAAM,EAAE;wBACN,KAAK,EAAE;4BACL;gCACE,IAAI,EAAE,QAAQ;6BACf;4BACD;gCACE,IAAI,EAAE,OAAO;gCACb,KAAK,EAAE;oCACL,IAAI,EAAE,QAAQ;iCACf;6BACF;yBACF;qBACF;iBACF;gBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC;aACtC;SACF;KACF;CACF,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"log.configuration.js","sourceRoot":"","sources":["../../../src/schemas/log.configuration.ts"],"names":[],"mappings":"AAAA,MAAM,oBA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