standard-log 8.0.1 → 9.1.0

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 (624) hide show
  1. package/README.md +57 -133
  2. package/{esm/console/createConsoleLogReporter.d.ts → cjs/console.d.ts} +5 -5
  3. package/cjs/console.d.ts.map +1 -0
  4. package/cjs/console.js +74 -0
  5. package/cjs/console.js.map +1 -0
  6. package/cjs/console.spec.d.ts +2 -0
  7. package/cjs/console.spec.d.ts.map +1 -0
  8. package/cjs/{console/createConsoleLogReporter.spec.js → console.spec.js} +50 -68
  9. package/cjs/console.spec.js.map +1 -0
  10. package/cjs/errors.d.ts +0 -10
  11. package/cjs/errors.d.ts.map +1 -1
  12. package/cjs/errors.js +1 -43
  13. package/cjs/errors.js.map +1 -1
  14. package/cjs/formatter.d.ts +6 -0
  15. package/cjs/formatter.d.ts.map +1 -0
  16. package/cjs/formatter.js +46 -0
  17. package/cjs/formatter.js.map +1 -0
  18. package/cjs/formatter.spec.d.ts +2 -0
  19. package/cjs/formatter.spec.d.ts.map +1 -0
  20. package/cjs/formatter.spec.js +32 -0
  21. package/cjs/formatter.spec.js.map +1 -0
  22. package/cjs/global.d.ts +13 -0
  23. package/cjs/global.d.ts.map +1 -0
  24. package/cjs/global.js +33 -0
  25. package/cjs/global.js.map +1 -0
  26. package/cjs/global.spec.d.ts +2 -0
  27. package/cjs/global.spec.d.ts.map +1 -0
  28. package/cjs/global.spec.js +32 -0
  29. package/cjs/global.spec.js.map +1 -0
  30. package/cjs/index.d.ts +6 -14
  31. package/cjs/index.d.ts.map +1 -1
  32. package/cjs/index.js +11 -14
  33. package/cjs/index.js.map +1 -1
  34. package/cjs/logLevels.d.ts +60 -0
  35. package/cjs/logLevels.d.ts.map +1 -0
  36. package/cjs/logLevels.js +87 -0
  37. package/cjs/logLevels.js.map +1 -0
  38. package/cjs/logStore.d.ts +20 -0
  39. package/cjs/logStore.d.ts.map +1 -0
  40. package/cjs/logStore.js +44 -0
  41. package/cjs/logStore.js.map +1 -0
  42. package/cjs/logStore.spec.d.ts +2 -0
  43. package/cjs/logStore.spec.d.ts.map +1 -0
  44. package/cjs/logStore.spec.js +93 -0
  45. package/cjs/logStore.spec.js.map +1 -0
  46. package/cjs/logger.d.ts +5 -0
  47. package/cjs/logger.d.ts.map +1 -0
  48. package/cjs/logger.js +99 -0
  49. package/cjs/logger.js.map +1 -0
  50. package/{esm/memory/MemoryLogReporter.d.ts → cjs/memory.d.ts} +2 -2
  51. package/cjs/memory.d.ts.map +1 -0
  52. package/cjs/memory.js +39 -0
  53. package/cjs/memory.js.map +1 -0
  54. package/cjs/memory.spec.d.ts +2 -0
  55. package/cjs/memory.spec.d.ts.map +1 -0
  56. package/cjs/memory.spec.js +115 -0
  57. package/cjs/memory.spec.js.map +1 -0
  58. package/cjs/package.json +1 -3
  59. package/cjs/platform.browser.d.ts +6 -0
  60. package/cjs/platform.browser.d.ts.map +1 -0
  61. package/cjs/platform.browser.js +7 -0
  62. package/cjs/platform.browser.js.map +1 -0
  63. package/cjs/platform.d.ts +6 -0
  64. package/cjs/platform.d.ts.map +1 -0
  65. package/cjs/platform.js +9 -0
  66. package/cjs/platform.js.map +1 -0
  67. package/cjs/standardLog.d.ts +28 -0
  68. package/cjs/standardLog.d.ts.map +1 -0
  69. package/cjs/standardLog.js +65 -0
  70. package/cjs/standardLog.js.map +1 -0
  71. package/cjs/standardLog.spec.d.ts +2 -0
  72. package/cjs/standardLog.spec.d.ts.map +1 -0
  73. package/cjs/standardLog.spec.js +548 -0
  74. package/cjs/standardLog.spec.js.map +1 -0
  75. package/cjs/testUtil.d.ts +7 -5
  76. package/cjs/testUtil.d.ts.map +1 -1
  77. package/cjs/testUtil.js +11 -14
  78. package/cjs/testUtil.js.map +1 -1
  79. package/cjs/types.d.ts +33 -24
  80. package/cjs/types.d.ts.map +1 -1
  81. package/cjs/types.js.map +1 -1
  82. package/dist/standard-log.es5.js +355 -1071
  83. package/dist/standard-log.es5.js.gz +0 -0
  84. package/dist/standard-log.es5.js.map +1 -1
  85. package/dist/standard-log.es5.js.map.gz +0 -0
  86. package/dist/standard-log.esm.js +353 -1135
  87. package/dist/standard-log.esm.js.gz +0 -0
  88. package/dist/standard-log.esm.js.map +1 -1
  89. package/dist/standard-log.esm.js.map.gz +0 -0
  90. package/{cjs/console/createConsoleLogReporter.d.ts → esm/console.d.ts} +5 -5
  91. package/esm/console.d.ts.map +1 -0
  92. package/esm/console.js +62 -0
  93. package/esm/console.js.map +1 -0
  94. package/esm/console.spec.d.ts +2 -0
  95. package/esm/console.spec.d.ts.map +1 -0
  96. package/esm/{console/createConsoleLogReporter.spec.js → console.spec.js} +50 -65
  97. package/esm/console.spec.js.map +1 -0
  98. package/esm/errors.d.ts +0 -10
  99. package/esm/errors.d.ts.map +1 -1
  100. package/esm/errors.js +0 -34
  101. package/esm/errors.js.map +1 -1
  102. package/esm/formatter.d.ts +6 -0
  103. package/esm/formatter.d.ts.map +1 -0
  104. package/esm/{formatter/createTimestampFormatter.js → formatter.js} +10 -2
  105. package/esm/formatter.js.map +1 -0
  106. package/esm/formatter.spec.d.ts +2 -0
  107. package/esm/formatter.spec.d.ts.map +1 -0
  108. package/esm/formatter.spec.js +30 -0
  109. package/esm/formatter.spec.js.map +1 -0
  110. package/esm/global.d.ts +13 -0
  111. package/esm/global.d.ts.map +1 -0
  112. package/esm/global.js +28 -0
  113. package/esm/global.js.map +1 -0
  114. package/esm/global.spec.d.ts +2 -0
  115. package/esm/global.spec.d.ts.map +1 -0
  116. package/esm/global.spec.js +30 -0
  117. package/esm/global.spec.js.map +1 -0
  118. package/esm/index.d.ts +6 -14
  119. package/esm/index.d.ts.map +1 -1
  120. package/esm/index.js +6 -14
  121. package/esm/index.js.map +1 -1
  122. package/esm/logLevels.d.ts +60 -0
  123. package/esm/logLevels.d.ts.map +1 -0
  124. package/esm/{logLevel.js → logLevels.js} +29 -3
  125. package/esm/logLevels.js.map +1 -0
  126. package/esm/logStore.d.ts +20 -0
  127. package/esm/logStore.d.ts.map +1 -0
  128. package/esm/logStore.js +37 -0
  129. package/esm/logStore.js.map +1 -0
  130. package/esm/logStore.spec.d.ts +2 -0
  131. package/esm/logStore.spec.d.ts.map +1 -0
  132. package/esm/logStore.spec.js +93 -0
  133. package/esm/logStore.spec.js.map +1 -0
  134. package/esm/logger.d.ts +5 -0
  135. package/esm/logger.d.ts.map +1 -0
  136. package/esm/logger.js +75 -0
  137. package/esm/logger.js.map +1 -0
  138. package/{cjs/memory/MemoryLogReporter.d.ts → esm/memory.d.ts} +2 -2
  139. package/esm/memory.d.ts.map +1 -0
  140. package/esm/memory.js +34 -0
  141. package/esm/memory.js.map +1 -0
  142. package/esm/memory.spec.d.ts +2 -0
  143. package/esm/memory.spec.d.ts.map +1 -0
  144. package/esm/memory.spec.js +110 -0
  145. package/esm/memory.spec.js.map +1 -0
  146. package/esm/platform.browser.d.ts +6 -0
  147. package/esm/platform.browser.d.ts.map +1 -0
  148. package/esm/platform.browser.js +3 -0
  149. package/esm/platform.browser.js.map +1 -0
  150. package/esm/platform.d.ts +6 -0
  151. package/esm/platform.d.ts.map +1 -0
  152. package/esm/platform.js +5 -0
  153. package/esm/platform.js.map +1 -0
  154. package/esm/standardLog.d.ts +28 -0
  155. package/esm/standardLog.d.ts.map +1 -0
  156. package/esm/standardLog.js +41 -0
  157. package/esm/standardLog.js.map +1 -0
  158. package/esm/standardLog.spec.d.ts +2 -0
  159. package/esm/standardLog.spec.d.ts.map +1 -0
  160. package/esm/standardLog.spec.js +446 -0
  161. package/esm/standardLog.spec.js.map +1 -0
  162. package/esm/testUtil.d.ts +7 -5
  163. package/esm/testUtil.d.ts.map +1 -1
  164. package/esm/testUtil.js +8 -12
  165. package/esm/testUtil.js.map +1 -1
  166. package/esm/types.d.ts +33 -24
  167. package/esm/types.d.ts.map +1 -1
  168. package/esm/types.js.map +1 -1
  169. package/package.json +10 -19
  170. package/ts/console.ts +70 -0
  171. package/ts/errors.ts +0 -12
  172. package/ts/{formatter/createTimestampFormatter.ts → formatter.ts} +12 -1
  173. package/ts/global.ts +34 -0
  174. package/ts/index.ts +9 -14
  175. package/ts/{logLevel.ts → logLevels.ts} +20 -3
  176. package/ts/logStore.ts +52 -0
  177. package/ts/logger.ts +85 -0
  178. package/ts/memory.ts +47 -0
  179. package/ts/platform.browser.ts +5 -0
  180. package/ts/platform.ts +8 -0
  181. package/ts/standardLog.ts +65 -0
  182. package/ts/types.ts +39 -30
  183. package/cjs/LogEntry.d.ts +0 -7
  184. package/cjs/LogEntry.d.ts.map +0 -1
  185. package/cjs/LogEntry.js +0 -3
  186. package/cjs/LogEntry.js.map +0 -1
  187. package/cjs/captureLogs.d.ts +0 -4
  188. package/cjs/captureLogs.d.ts.map +0 -1
  189. package/cjs/captureLogs.js +0 -33
  190. package/cjs/captureLogs.js.map +0 -1
  191. package/cjs/captureLogs.spec.d.ts +0 -2
  192. package/cjs/captureLogs.spec.d.ts.map +0 -1
  193. package/cjs/captureLogs.spec.js +0 -117
  194. package/cjs/captureLogs.spec.js.map +0 -1
  195. package/cjs/config.d.ts +0 -12
  196. package/cjs/config.d.ts.map +0 -1
  197. package/cjs/config.js +0 -59
  198. package/cjs/config.js.map +0 -1
  199. package/cjs/config.spec.d.ts +0 -2
  200. package/cjs/config.spec.d.ts.map +0 -1
  201. package/cjs/config.spec.js +0 -72
  202. package/cjs/config.spec.js.map +0 -1
  203. package/cjs/configForTest.d.ts +0 -5
  204. package/cjs/configForTest.d.ts.map +0 -1
  205. package/cjs/configForTest.js +0 -18
  206. package/cjs/configForTest.js.map +0 -1
  207. package/cjs/configForTest.spec.d.ts +0 -2
  208. package/cjs/configForTest.spec.d.ts.map +0 -1
  209. package/cjs/configForTest.spec.js +0 -17
  210. package/cjs/configForTest.spec.js.map +0 -1
  211. package/cjs/console/createConsoleLogReporter.d.ts.map +0 -1
  212. package/cjs/console/createConsoleLogReporter.js +0 -42
  213. package/cjs/console/createConsoleLogReporter.js.map +0 -1
  214. package/cjs/console/createConsoleLogReporter.spec.d.ts +0 -2
  215. package/cjs/console/createConsoleLogReporter.spec.d.ts.map +0 -1
  216. package/cjs/console/createConsoleLogReporter.spec.js.map +0 -1
  217. package/cjs/console/index.d.ts +0 -4
  218. package/cjs/console/index.d.ts.map +0 -1
  219. package/cjs/console/index.js +0 -20
  220. package/cjs/console/index.js.map +0 -1
  221. package/cjs/console/isConsoleDebugAvailable.d.ts +0 -2
  222. package/cjs/console/isConsoleDebugAvailable.d.ts.map +0 -1
  223. package/cjs/console/isConsoleDebugAvailable.js +0 -20
  224. package/cjs/console/isConsoleDebugAvailable.js.map +0 -1
  225. package/cjs/console/polyfilledConsole.d.ts +0 -7
  226. package/cjs/console/polyfilledConsole.d.ts.map +0 -1
  227. package/cjs/console/polyfilledConsole.js +0 -41
  228. package/cjs/console/polyfilledConsole.js.map +0 -1
  229. package/cjs/console/semverGt.d.ts +0 -2
  230. package/cjs/console/semverGt.d.ts.map +0 -1
  231. package/cjs/console/semverGt.js +0 -13
  232. package/cjs/console/semverGt.js.map +0 -1
  233. package/cjs/console/semverGt.spec.d.ts +0 -2
  234. package/cjs/console/semverGt.spec.d.ts.map +0 -1
  235. package/cjs/console/semverGt.spec.js +0 -22
  236. package/cjs/console/semverGt.spec.js.map +0 -1
  237. package/cjs/console/toConsoleMethod.d.ts +0 -2
  238. package/cjs/console/toConsoleMethod.d.ts.map +0 -1
  239. package/cjs/console/toConsoleMethod.js +0 -22
  240. package/cjs/console/toConsoleMethod.js.map +0 -1
  241. package/cjs/console/types.d.ts +0 -3
  242. package/cjs/console/types.d.ts.map +0 -1
  243. package/cjs/console/types.js +0 -3
  244. package/cjs/console/types.js.map +0 -1
  245. package/cjs/customLogLevel.d.ts +0 -11
  246. package/cjs/customLogLevel.d.ts.map +0 -1
  247. package/cjs/customLogLevel.js +0 -38
  248. package/cjs/customLogLevel.js.map +0 -1
  249. package/cjs/customLogLevel.spec.d.ts +0 -2
  250. package/cjs/customLogLevel.spec.d.ts.map +0 -1
  251. package/cjs/customLogLevel.spec.js +0 -37
  252. package/cjs/customLogLevel.spec.js.map +0 -1
  253. package/cjs/formatter/createTimestampFormatter.d.ts +0 -3
  254. package/cjs/formatter/createTimestampFormatter.d.ts.map +0 -1
  255. package/cjs/formatter/createTimestampFormatter.js +0 -26
  256. package/cjs/formatter/createTimestampFormatter.js.map +0 -1
  257. package/cjs/formatter/createTimestampFormatter.spec.d.ts +0 -2
  258. package/cjs/formatter/createTimestampFormatter.spec.d.ts.map +0 -1
  259. package/cjs/formatter/createTimestampFormatter.spec.js +0 -23
  260. package/cjs/formatter/createTimestampFormatter.spec.js.map +0 -1
  261. package/cjs/formatter/formatLogLevel.d.ts +0 -2
  262. package/cjs/formatter/formatLogLevel.d.ts.map +0 -1
  263. package/cjs/formatter/formatLogLevel.js +0 -10
  264. package/cjs/formatter/formatLogLevel.js.map +0 -1
  265. package/cjs/formatter/index.d.ts +0 -4
  266. package/cjs/formatter/index.d.ts.map +0 -1
  267. package/cjs/formatter/index.js +0 -20
  268. package/cjs/formatter/index.js.map +0 -1
  269. package/cjs/formatter/plainLogFormatter.d.ts +0 -3
  270. package/cjs/formatter/plainLogFormatter.d.ts.map +0 -1
  271. package/cjs/formatter/plainLogFormatter.js +0 -19
  272. package/cjs/formatter/plainLogFormatter.js.map +0 -1
  273. package/cjs/formatter/plainLogFormatter.spec.d.ts +0 -2
  274. package/cjs/formatter/plainLogFormatter.spec.d.ts.map +0 -1
  275. package/cjs/formatter/plainLogFormatter.spec.js +0 -9
  276. package/cjs/formatter/plainLogFormatter.spec.js.map +0 -1
  277. package/cjs/getDefaultReporter.browser.d.ts +0 -2
  278. package/cjs/getDefaultReporter.browser.d.ts.map +0 -1
  279. package/cjs/getDefaultReporter.browser.js +0 -15
  280. package/cjs/getDefaultReporter.browser.js.map +0 -1
  281. package/cjs/getDefaultReporter.d.ts +0 -2
  282. package/cjs/getDefaultReporter.d.ts.map +0 -1
  283. package/cjs/getDefaultReporter.js +0 -19
  284. package/cjs/getDefaultReporter.js.map +0 -1
  285. package/cjs/getLogModeFromEnvironment.browser.d.ts +0 -3
  286. package/cjs/getLogModeFromEnvironment.browser.d.ts.map +0 -1
  287. package/cjs/getLogModeFromEnvironment.browser.js +0 -9
  288. package/cjs/getLogModeFromEnvironment.browser.js.map +0 -1
  289. package/cjs/getLogModeFromEnvironment.d.ts +0 -3
  290. package/cjs/getLogModeFromEnvironment.d.ts.map +0 -1
  291. package/cjs/getLogModeFromEnvironment.js +0 -17
  292. package/cjs/getLogModeFromEnvironment.js.map +0 -1
  293. package/cjs/getLogModeFromEnvironment.spec.d.ts +0 -2
  294. package/cjs/getLogModeFromEnvironment.spec.d.ts.map +0 -1
  295. package/cjs/getLogModeFromEnvironment.spec.js +0 -25
  296. package/cjs/getLogModeFromEnvironment.spec.js.map +0 -1
  297. package/cjs/getLogger.d.ts +0 -9
  298. package/cjs/getLogger.d.ts.map +0 -1
  299. package/cjs/getLogger.js +0 -103
  300. package/cjs/getLogger.js.map +0 -1
  301. package/cjs/getLogger.spec.d.ts +0 -2
  302. package/cjs/getLogger.spec.d.ts.map +0 -1
  303. package/cjs/getLogger.spec.js +0 -485
  304. package/cjs/getLogger.spec.js.map +0 -1
  305. package/cjs/getLoggers.d.ts +0 -7
  306. package/cjs/getLoggers.d.ts.map +0 -1
  307. package/cjs/getLoggers.js +0 -15
  308. package/cjs/getLoggers.js.map +0 -1
  309. package/cjs/logLevel.d.ts +0 -106
  310. package/cjs/logLevel.d.ts.map +0 -1
  311. package/cjs/logLevel.js +0 -59
  312. package/cjs/logLevel.js.map +0 -1
  313. package/cjs/logLevel.spec.d.ts +0 -2
  314. package/cjs/logLevel.spec.d.ts.map +0 -1
  315. package/cjs/logLevel.spec.js +0 -195
  316. package/cjs/logLevel.spec.js.map +0 -1
  317. package/cjs/logLevelFn.d.ts +0 -20
  318. package/cjs/logLevelFn.d.ts.map +0 -1
  319. package/cjs/logLevelFn.js +0 -76
  320. package/cjs/logLevelFn.js.map +0 -1
  321. package/cjs/logReporter.d.ts +0 -7
  322. package/cjs/logReporter.d.ts.map +0 -1
  323. package/cjs/logReporter.js +0 -29
  324. package/cjs/logReporter.js.map +0 -1
  325. package/cjs/logReporter.spec.d.ts +0 -2
  326. package/cjs/logReporter.spec.d.ts.map +0 -1
  327. package/cjs/logReporter.spec.js +0 -98
  328. package/cjs/logReporter.spec.js.map +0 -1
  329. package/cjs/logReporterInternal.d.ts +0 -3
  330. package/cjs/logReporterInternal.d.ts.map +0 -1
  331. package/cjs/logReporterInternal.js +0 -23
  332. package/cjs/logReporterInternal.js.map +0 -1
  333. package/cjs/memory/MemoryLogReporter.d.ts.map +0 -1
  334. package/cjs/memory/MemoryLogReporter.js +0 -56
  335. package/cjs/memory/MemoryLogReporter.js.map +0 -1
  336. package/cjs/memory/MemoryLogReporter.spec.d.ts +0 -2
  337. package/cjs/memory/MemoryLogReporter.spec.d.ts.map +0 -1
  338. package/cjs/memory/MemoryLogReporter.spec.js +0 -124
  339. package/cjs/memory/MemoryLogReporter.spec.js.map +0 -1
  340. package/cjs/memory/index.d.ts +0 -3
  341. package/cjs/memory/index.d.ts.map +0 -1
  342. package/cjs/memory/index.js +0 -19
  343. package/cjs/memory/index.js.map +0 -1
  344. package/cjs/memory/logEntriesToString.d.ts +0 -3
  345. package/cjs/memory/logEntriesToString.d.ts.map +0 -1
  346. package/cjs/memory/logEntriesToString.js +0 -10
  347. package/cjs/memory/logEntriesToString.js.map +0 -1
  348. package/cjs/memory/logEntriesToString.spec.d.ts +0 -2
  349. package/cjs/memory/logEntriesToString.spec.d.ts.map +0 -1
  350. package/cjs/memory/logEntriesToString.spec.js +0 -36
  351. package/cjs/memory/logEntriesToString.spec.js.map +0 -1
  352. package/cjs/memory/toInspectStringForObject.d.ts +0 -3
  353. package/cjs/memory/toInspectStringForObject.d.ts.map +0 -1
  354. package/cjs/memory/toInspectStringForObject.js +0 -17
  355. package/cjs/memory/toInspectStringForObject.js.map +0 -1
  356. package/cjs/shouldLog.d.ts +0 -8
  357. package/cjs/shouldLog.d.ts.map +0 -1
  358. package/cjs/shouldLog.js +0 -14
  359. package/cjs/shouldLog.js.map +0 -1
  360. package/cjs/store.d.ts +0 -3
  361. package/cjs/store.d.ts.map +0 -1
  362. package/cjs/store.js +0 -27
  363. package/cjs/store.js.map +0 -1
  364. package/cjs/suppressLogs.d.ts +0 -6
  365. package/cjs/suppressLogs.d.ts.map +0 -1
  366. package/cjs/suppressLogs.js +0 -17
  367. package/cjs/suppressLogs.js.map +0 -1
  368. package/cjs/suppressLogs.spec.d.ts +0 -2
  369. package/cjs/suppressLogs.spec.d.ts.map +0 -1
  370. package/cjs/suppressLogs.spec.js +0 -31
  371. package/cjs/suppressLogs.spec.js.map +0 -1
  372. package/cjs/typesInternal.d.ts +0 -20
  373. package/cjs/typesInternal.d.ts.map +0 -1
  374. package/cjs/typesInternal.js +0 -3
  375. package/cjs/typesInternal.js.map +0 -1
  376. package/cjs/utils.d.ts +0 -6
  377. package/cjs/utils.d.ts.map +0 -1
  378. package/cjs/utils.js +0 -15
  379. package/cjs/utils.js.map +0 -1
  380. package/cjs/writeToReporters.d.ts +0 -6
  381. package/cjs/writeToReporters.d.ts.map +0 -1
  382. package/cjs/writeToReporters.js +0 -22
  383. package/cjs/writeToReporters.js.map +0 -1
  384. package/cjs/writeToReporters.spec.d.ts +0 -2
  385. package/cjs/writeToReporters.spec.d.ts.map +0 -1
  386. package/cjs/writeToReporters.spec.js +0 -59
  387. package/cjs/writeToReporters.spec.js.map +0 -1
  388. package/esm/LogEntry.d.ts +0 -7
  389. package/esm/LogEntry.d.ts.map +0 -1
  390. package/esm/LogEntry.js +0 -2
  391. package/esm/LogEntry.js.map +0 -1
  392. package/esm/captureLogs.d.ts +0 -4
  393. package/esm/captureLogs.d.ts.map +0 -1
  394. package/esm/captureLogs.js +0 -29
  395. package/esm/captureLogs.js.map +0 -1
  396. package/esm/captureLogs.spec.d.ts +0 -2
  397. package/esm/captureLogs.spec.d.ts.map +0 -1
  398. package/esm/captureLogs.spec.js +0 -45
  399. package/esm/captureLogs.spec.js.map +0 -1
  400. package/esm/config.d.ts +0 -12
  401. package/esm/config.d.ts.map +0 -1
  402. package/esm/config.js +0 -44
  403. package/esm/config.js.map +0 -1
  404. package/esm/config.spec.d.ts +0 -2
  405. package/esm/config.spec.d.ts.map +0 -1
  406. package/esm/config.spec.js +0 -67
  407. package/esm/config.spec.js.map +0 -1
  408. package/esm/configForTest.d.ts +0 -5
  409. package/esm/configForTest.d.ts.map +0 -1
  410. package/esm/configForTest.js +0 -14
  411. package/esm/configForTest.js.map +0 -1
  412. package/esm/configForTest.spec.d.ts +0 -2
  413. package/esm/configForTest.spec.d.ts.map +0 -1
  414. package/esm/configForTest.spec.js +0 -15
  415. package/esm/configForTest.spec.js.map +0 -1
  416. package/esm/console/createConsoleLogReporter.d.ts.map +0 -1
  417. package/esm/console/createConsoleLogReporter.js +0 -37
  418. package/esm/console/createConsoleLogReporter.js.map +0 -1
  419. package/esm/console/createConsoleLogReporter.spec.d.ts +0 -2
  420. package/esm/console/createConsoleLogReporter.spec.d.ts.map +0 -1
  421. package/esm/console/createConsoleLogReporter.spec.js.map +0 -1
  422. package/esm/console/index.d.ts +0 -4
  423. package/esm/console/index.d.ts.map +0 -1
  424. package/esm/console/index.js +0 -4
  425. package/esm/console/index.js.map +0 -1
  426. package/esm/console/isConsoleDebugAvailable.d.ts +0 -2
  427. package/esm/console/isConsoleDebugAvailable.d.ts.map +0 -1
  428. package/esm/console/isConsoleDebugAvailable.js +0 -13
  429. package/esm/console/isConsoleDebugAvailable.js.map +0 -1
  430. package/esm/console/polyfilledConsole.d.ts +0 -7
  431. package/esm/console/polyfilledConsole.d.ts.map +0 -1
  432. package/esm/console/polyfilledConsole.js +0 -32
  433. package/esm/console/polyfilledConsole.js.map +0 -1
  434. package/esm/console/semverGt.d.ts +0 -2
  435. package/esm/console/semverGt.d.ts.map +0 -1
  436. package/esm/console/semverGt.js +0 -9
  437. package/esm/console/semverGt.js.map +0 -1
  438. package/esm/console/semverGt.spec.d.ts +0 -2
  439. package/esm/console/semverGt.spec.d.ts.map +0 -1
  440. package/esm/console/semverGt.spec.js +0 -20
  441. package/esm/console/semverGt.spec.js.map +0 -1
  442. package/esm/console/toConsoleMethod.d.ts +0 -2
  443. package/esm/console/toConsoleMethod.d.ts.map +0 -1
  444. package/esm/console/toConsoleMethod.js +0 -18
  445. package/esm/console/toConsoleMethod.js.map +0 -1
  446. package/esm/console/types.d.ts +0 -3
  447. package/esm/console/types.d.ts.map +0 -1
  448. package/esm/console/types.js +0 -2
  449. package/esm/console/types.js.map +0 -1
  450. package/esm/customLogLevel.d.ts +0 -11
  451. package/esm/customLogLevel.d.ts.map +0 -1
  452. package/esm/customLogLevel.js +0 -30
  453. package/esm/customLogLevel.js.map +0 -1
  454. package/esm/customLogLevel.spec.d.ts +0 -2
  455. package/esm/customLogLevel.spec.d.ts.map +0 -1
  456. package/esm/customLogLevel.spec.js +0 -32
  457. package/esm/customLogLevel.spec.js.map +0 -1
  458. package/esm/formatter/createTimestampFormatter.d.ts +0 -3
  459. package/esm/formatter/createTimestampFormatter.d.ts.map +0 -1
  460. package/esm/formatter/createTimestampFormatter.js.map +0 -1
  461. package/esm/formatter/createTimestampFormatter.spec.d.ts +0 -2
  462. package/esm/formatter/createTimestampFormatter.spec.d.ts.map +0 -1
  463. package/esm/formatter/createTimestampFormatter.spec.js +0 -21
  464. package/esm/formatter/createTimestampFormatter.spec.js.map +0 -1
  465. package/esm/formatter/formatLogLevel.d.ts +0 -2
  466. package/esm/formatter/formatLogLevel.d.ts.map +0 -1
  467. package/esm/formatter/formatLogLevel.js +0 -6
  468. package/esm/formatter/formatLogLevel.js.map +0 -1
  469. package/esm/formatter/index.d.ts +0 -4
  470. package/esm/formatter/index.d.ts.map +0 -1
  471. package/esm/formatter/index.js +0 -4
  472. package/esm/formatter/index.js.map +0 -1
  473. package/esm/formatter/plainLogFormatter.d.ts +0 -3
  474. package/esm/formatter/plainLogFormatter.d.ts.map +0 -1
  475. package/esm/formatter/plainLogFormatter.js +0 -5
  476. package/esm/formatter/plainLogFormatter.js.map +0 -1
  477. package/esm/formatter/plainLogFormatter.spec.d.ts +0 -2
  478. package/esm/formatter/plainLogFormatter.spec.d.ts.map +0 -1
  479. package/esm/formatter/plainLogFormatter.spec.js +0 -7
  480. package/esm/formatter/plainLogFormatter.spec.js.map +0 -1
  481. package/esm/getDefaultReporter.browser.d.ts +0 -2
  482. package/esm/getDefaultReporter.browser.d.ts.map +0 -1
  483. package/esm/getDefaultReporter.browser.js +0 -11
  484. package/esm/getDefaultReporter.browser.js.map +0 -1
  485. package/esm/getDefaultReporter.d.ts +0 -2
  486. package/esm/getDefaultReporter.d.ts.map +0 -1
  487. package/esm/getDefaultReporter.js +0 -15
  488. package/esm/getDefaultReporter.js.map +0 -1
  489. package/esm/getLogModeFromEnvironment.browser.d.ts +0 -3
  490. package/esm/getLogModeFromEnvironment.browser.d.ts.map +0 -1
  491. package/esm/getLogModeFromEnvironment.browser.js +0 -5
  492. package/esm/getLogModeFromEnvironment.browser.js.map +0 -1
  493. package/esm/getLogModeFromEnvironment.d.ts +0 -3
  494. package/esm/getLogModeFromEnvironment.d.ts.map +0 -1
  495. package/esm/getLogModeFromEnvironment.js +0 -13
  496. package/esm/getLogModeFromEnvironment.js.map +0 -1
  497. package/esm/getLogModeFromEnvironment.spec.d.ts +0 -2
  498. package/esm/getLogModeFromEnvironment.spec.d.ts.map +0 -1
  499. package/esm/getLogModeFromEnvironment.spec.js +0 -20
  500. package/esm/getLogModeFromEnvironment.spec.js.map +0 -1
  501. package/esm/getLogger.d.ts +0 -9
  502. package/esm/getLogger.d.ts.map +0 -1
  503. package/esm/getLogger.js +0 -78
  504. package/esm/getLogger.js.map +0 -1
  505. package/esm/getLogger.spec.d.ts +0 -2
  506. package/esm/getLogger.spec.d.ts.map +0 -1
  507. package/esm/getLogger.spec.js +0 -385
  508. package/esm/getLogger.spec.js.map +0 -1
  509. package/esm/getLoggers.d.ts +0 -7
  510. package/esm/getLoggers.d.ts.map +0 -1
  511. package/esm/getLoggers.js +0 -11
  512. package/esm/getLoggers.js.map +0 -1
  513. package/esm/logLevel.d.ts +0 -106
  514. package/esm/logLevel.d.ts.map +0 -1
  515. package/esm/logLevel.js.map +0 -1
  516. package/esm/logLevel.spec.d.ts +0 -2
  517. package/esm/logLevel.spec.d.ts.map +0 -1
  518. package/esm/logLevel.spec.js +0 -148
  519. package/esm/logLevel.spec.js.map +0 -1
  520. package/esm/logLevelFn.d.ts +0 -20
  521. package/esm/logLevelFn.d.ts.map +0 -1
  522. package/esm/logLevelFn.js +0 -67
  523. package/esm/logLevelFn.js.map +0 -1
  524. package/esm/logReporter.d.ts +0 -7
  525. package/esm/logReporter.d.ts.map +0 -1
  526. package/esm/logReporter.js +0 -21
  527. package/esm/logReporter.js.map +0 -1
  528. package/esm/logReporter.spec.d.ts +0 -2
  529. package/esm/logReporter.spec.d.ts.map +0 -1
  530. package/esm/logReporter.spec.js +0 -93
  531. package/esm/logReporter.spec.js.map +0 -1
  532. package/esm/logReporterInternal.d.ts +0 -3
  533. package/esm/logReporterInternal.d.ts.map +0 -1
  534. package/esm/logReporterInternal.js +0 -19
  535. package/esm/logReporterInternal.js.map +0 -1
  536. package/esm/memory/MemoryLogReporter.d.ts.map +0 -1
  537. package/esm/memory/MemoryLogReporter.js +0 -51
  538. package/esm/memory/MemoryLogReporter.js.map +0 -1
  539. package/esm/memory/MemoryLogReporter.spec.d.ts +0 -2
  540. package/esm/memory/MemoryLogReporter.spec.d.ts.map +0 -1
  541. package/esm/memory/MemoryLogReporter.spec.js +0 -111
  542. package/esm/memory/MemoryLogReporter.spec.js.map +0 -1
  543. package/esm/memory/index.d.ts +0 -3
  544. package/esm/memory/index.d.ts.map +0 -1
  545. package/esm/memory/index.js +0 -3
  546. package/esm/memory/index.js.map +0 -1
  547. package/esm/memory/logEntriesToString.d.ts +0 -3
  548. package/esm/memory/logEntriesToString.d.ts.map +0 -1
  549. package/esm/memory/logEntriesToString.js +0 -6
  550. package/esm/memory/logEntriesToString.js.map +0 -1
  551. package/esm/memory/logEntriesToString.spec.d.ts +0 -2
  552. package/esm/memory/logEntriesToString.spec.d.ts.map +0 -1
  553. package/esm/memory/logEntriesToString.spec.js +0 -42
  554. package/esm/memory/logEntriesToString.spec.js.map +0 -1
  555. package/esm/memory/toInspectStringForObject.d.ts +0 -3
  556. package/esm/memory/toInspectStringForObject.d.ts.map +0 -1
  557. package/esm/memory/toInspectStringForObject.js +0 -11
  558. package/esm/memory/toInspectStringForObject.js.map +0 -1
  559. package/esm/shouldLog.d.ts +0 -8
  560. package/esm/shouldLog.d.ts.map +0 -1
  561. package/esm/shouldLog.js +0 -10
  562. package/esm/shouldLog.js.map +0 -1
  563. package/esm/store.d.ts +0 -3
  564. package/esm/store.d.ts.map +0 -1
  565. package/esm/store.js +0 -24
  566. package/esm/store.js.map +0 -1
  567. package/esm/suppressLogs.d.ts +0 -6
  568. package/esm/suppressLogs.d.ts.map +0 -1
  569. package/esm/suppressLogs.js +0 -9
  570. package/esm/suppressLogs.js.map +0 -1
  571. package/esm/suppressLogs.spec.d.ts +0 -2
  572. package/esm/suppressLogs.spec.d.ts.map +0 -1
  573. package/esm/suppressLogs.spec.js +0 -29
  574. package/esm/suppressLogs.spec.js.map +0 -1
  575. package/esm/typesInternal.d.ts +0 -20
  576. package/esm/typesInternal.d.ts.map +0 -1
  577. package/esm/typesInternal.js +0 -2
  578. package/esm/typesInternal.js.map +0 -1
  579. package/esm/utils.d.ts +0 -6
  580. package/esm/utils.d.ts.map +0 -1
  581. package/esm/utils.js +0 -11
  582. package/esm/utils.js.map +0 -1
  583. package/esm/writeToReporters.d.ts +0 -6
  584. package/esm/writeToReporters.d.ts.map +0 -1
  585. package/esm/writeToReporters.js +0 -18
  586. package/esm/writeToReporters.js.map +0 -1
  587. package/esm/writeToReporters.spec.d.ts +0 -2
  588. package/esm/writeToReporters.spec.d.ts.map +0 -1
  589. package/esm/writeToReporters.spec.js +0 -9
  590. package/esm/writeToReporters.spec.js.map +0 -1
  591. package/ts/LogEntry.ts +0 -7
  592. package/ts/captureLogs.ts +0 -35
  593. package/ts/config.ts +0 -57
  594. package/ts/configForTest.ts +0 -16
  595. package/ts/console/createConsoleLogReporter.ts +0 -48
  596. package/ts/console/index.ts +0 -3
  597. package/ts/console/isConsoleDebugAvailable.ts +0 -11
  598. package/ts/console/polyfilledConsole.ts +0 -34
  599. package/ts/console/semverGt.ts +0 -9
  600. package/ts/console/toConsoleMethod.ts +0 -18
  601. package/ts/console/types.ts +0 -3
  602. package/ts/customLogLevel.ts +0 -35
  603. package/ts/formatter/formatLogLevel.ts +0 -6
  604. package/ts/formatter/index.ts +0 -3
  605. package/ts/formatter/plainLogFormatter.ts +0 -6
  606. package/ts/getDefaultReporter.browser.ts +0 -13
  607. package/ts/getDefaultReporter.ts +0 -15
  608. package/ts/getLogModeFromEnvironment.browser.ts +0 -6
  609. package/ts/getLogModeFromEnvironment.ts +0 -16
  610. package/ts/getLogger.ts +0 -92
  611. package/ts/getLoggers.ts +0 -12
  612. package/ts/logLevelFn.ts +0 -72
  613. package/ts/logReporter.ts +0 -26
  614. package/ts/logReporterInternal.ts +0 -18
  615. package/ts/memory/MemoryLogReporter.ts +0 -72
  616. package/ts/memory/index.ts +0 -2
  617. package/ts/memory/logEntriesToString.ts +0 -7
  618. package/ts/memory/toInspectStringForObject.ts +0 -13
  619. package/ts/shouldLog.ts +0 -11
  620. package/ts/store.ts +0 -25
  621. package/ts/suppressLogs.ts +0 -14
  622. package/ts/typesInternal.ts +0 -21
  623. package/ts/utils.ts +0 -11
  624. package/ts/writeToReporters.ts +0 -20
@@ -50,7 +50,33 @@ export const logLevels = {
50
50
  all: Infinity
51
51
  };
52
52
  /**
53
- * @deprecated logLevel is renamed to logLevels
53
+ * Convert default log level value to log level name.
54
54
  */
55
- export const logLevel = logLevels;
56
- //# sourceMappingURL=logLevel.js.map
55
+ export function toLogLevelName(level) {
56
+ if (level <= 100)
57
+ return 'emergency';
58
+ if (level <= 200)
59
+ return 'alert';
60
+ if (level <= 300)
61
+ return 'critical';
62
+ if (level <= 400)
63
+ return 'error';
64
+ if (level <= 500)
65
+ return 'warn';
66
+ if (level <= 600)
67
+ return 'notice';
68
+ if (level <= 700)
69
+ return 'info';
70
+ if (level <= 800)
71
+ return 'debug';
72
+ if (level <= 900)
73
+ return 'trace';
74
+ return 'planck';
75
+ }
76
+ /**
77
+ * Convert default log level name to log level value.
78
+ */
79
+ export function toLogLevel(name) {
80
+ return logLevels[name.toLocaleLowerCase()];
81
+ }
82
+ //# sourceMappingURL=logLevels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logLevels.js","sourceRoot":"","sources":["../ts/logLevels.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,CAAC;IACP;;OAEG;IACH,SAAS,EAAE,GAAG;IACd;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;OAEG;IACH,QAAQ,EAAE,GAAG;IACb;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;OAEG;IACH,IAAI,EAAE,GAAG;IACT;;OAEG;IACH,MAAM,EAAE,GAAG;IACX;;OAEG;IACH,IAAI,EAAE,GAAG;IACT;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;;OAGG;IACH,MAAM,EAAE,QAAQ;IAChB;;OAEG;IACH,GAAG,EAAE,QAAQ;CACd,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,WAAW,CAAA;IACpC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,UAAU,CAAA;IACnC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,QAAQ,CAAA;IACjC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAQ,SAAiB,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;AACrD,CAAC","sourcesContent":["export const logLevels = {\n /**\n * none: 0\n */\n none: 0,\n /**\n * emergency: 100\n */\n emergency: 100,\n /**\n * alert: 200\n */\n alert: 200,\n /**\n * critical: 300\n */\n critical: 300,\n /**\n * error: 400\n */\n error: 400,\n /**\n * warn: 500\n */\n warn: 500,\n /**\n * notice: 600\n */\n notice: 600,\n /**\n * info: 700\n */\n info: 700,\n /**\n * debug: 800\n */\n debug: 800,\n /**\n * trace: 900\n */\n trace: 900,\n /**\n * planck: Infinity\n * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.\n */\n planck: Infinity,\n /**\n * all: Infinity\n */\n all: Infinity\n}\n\n/**\n * Convert default log level value to log level name.\n */\nexport function toLogLevelName(level: number) {\n if (level <= 100) return 'emergency'\n if (level <= 200) return 'alert'\n if (level <= 300) return 'critical'\n if (level <= 400) return 'error'\n if (level <= 500) return 'warn'\n if (level <= 600) return 'notice'\n if (level <= 700) return 'info'\n if (level <= 800) return 'debug'\n if (level <= 900) return 'trace'\n return 'planck'\n}\n\n/**\n * Convert default log level name to log level value.\n */\nexport function toLogLevel(name: string) {\n return (logLevels as any)[name.toLocaleLowerCase()]\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import type { Logger, LogLevel, LogReporter, StandardLogOptions } from './types.js';
2
+ export declare function createLogStore(options: Required<StandardLogOptions>): LogStore;
3
+ export interface LogStore {
4
+ loggers: Record<string, Logger>;
5
+ reporters: LogReporter[];
6
+ logLevel: LogLevel;
7
+ logLevelStore: ReturnType<typeof logLevelStore>;
8
+ }
9
+ export interface LogLevelStoreOptions {
10
+ customLevels?: Record<string, number>;
11
+ }
12
+ export declare function logLevelStore(options: LogLevelStoreOptions): {
13
+ getName(level: number): string;
14
+ getLevel(name: string): number;
15
+ getAllLevels(): {
16
+ name: string;
17
+ level: number;
18
+ }[];
19
+ };
20
+ //# sourceMappingURL=logStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../ts/logStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEnF,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAO9E;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;CAChD;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACtC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB;mBAWxC,MAAM;mBAGN,MAAM;;;;;EAWxB"}
@@ -0,0 +1,37 @@
1
+ import { mapKey, reduceByKey, reduceKey } from 'type-plus';
2
+ import { createConsoleLogReporter } from './console.js';
3
+ import { logLevels, toLogLevel, toLogLevelName } from './logLevels.js';
4
+ export function createLogStore(options) {
5
+ return {
6
+ loggers: {},
7
+ reporters: options.reporters || [createConsoleLogReporter()],
8
+ logLevel: options.logLevel,
9
+ logLevelStore: logLevelStore(options)
10
+ };
11
+ }
12
+ export function logLevelStore(options) {
13
+ const customLevels = options.customLevels || {};
14
+ const store = {
15
+ customLevels,
16
+ customLevelsReverse: reduceByKey(customLevels, (p, k) => {
17
+ p[customLevels[k]] = k;
18
+ return p;
19
+ }, {})
20
+ };
21
+ return {
22
+ getName(level) {
23
+ return store.customLevelsReverse[level] ?? toLogLevelName(level);
24
+ },
25
+ getLevel(name) {
26
+ return store.customLevels[name] ?? toLogLevel(name);
27
+ },
28
+ getAllLevels() {
29
+ return reduceKey(logLevels, (result, name) => {
30
+ if (name !== 'none' && name !== 'all')
31
+ result.push({ name, level: logLevels[name] });
32
+ return result;
33
+ }, mapKey(store.customLevels, name => ({ name, level: store.customLevels[name] })));
34
+ }
35
+ };
36
+ }
37
+ //# sourceMappingURL=logStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logStore.js","sourceRoot":"","sources":["../ts/logStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGtE,MAAM,UAAU,cAAc,CAAC,OAAqC;IAClE,OAAO;QACL,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC5D,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC;KACtC,CAAA;AACH,CAAC;AAaD,MAAM,UAAU,aAAa,CAAC,OAA6B;IACzD,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAA;IAE/C,MAAM,KAAK,GAAG;QACZ,YAAY;QACZ,mBAAmB,EAAE,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACtD,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;YACtB,OAAO,CAAC,CAAA;QACV,CAAC,EAAE,EAA4B,CAAC;KACjC,CAAA;IACD,OAAO;QACL,OAAO,CAAC,KAAa;YACnB,OAAO,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,CAAA;QAClE,CAAC;QACD,QAAQ,CAAC,IAAY;YACnB,OAAO,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;QACrD,CAAC;QACD,YAAY;YACV,OAAO,SAAS,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;gBAC3C,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK;oBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAEpF,OAAO,MAAM,CAAA;YACf,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACrF,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["\nimport { mapKey, reduceByKey, reduceKey } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { logLevels, toLogLevel, toLogLevelName } from './logLevels.js'\nimport type { Logger, LogLevel, LogReporter, StandardLogOptions } from './types.js'\n\nexport function createLogStore(options: Required<StandardLogOptions>): LogStore {\n return {\n loggers: {},\n reporters: options.reporters || [createConsoleLogReporter()],\n logLevel: options.logLevel,\n logLevelStore: logLevelStore(options)\n }\n}\n\nexport interface LogStore {\n loggers: Record<string, Logger>,\n reporters: LogReporter[],\n logLevel: LogLevel,\n logLevelStore: ReturnType<typeof logLevelStore>\n}\n\nexport interface LogLevelStoreOptions {\n customLevels?: Record<string, number>\n}\n\nexport function logLevelStore(options: LogLevelStoreOptions) {\n const customLevels = options.customLevels || {}\n\n const store = {\n customLevels,\n customLevelsReverse: reduceByKey(customLevels, (p, k) => {\n p[customLevels[k]] = k\n return p\n }, {} as Record<number, string>)\n }\n return {\n getName(level: number) {\n return store.customLevelsReverse[level] ?? toLogLevelName(level)\n },\n getLevel(name: string) {\n return store.customLevels[name] ?? toLogLevel(name)\n },\n getAllLevels() {\n return reduceKey(logLevels, (result, name) => {\n if (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })\n\n return result\n }, mapKey(store.customLevels, name => ({ name, level: store.customLevels[name] })))\n }\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=logStore.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logStore.spec.d.ts","sourceRoot":"","sources":["../ts/logStore.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,93 @@
1
+ import { forEachKey } from 'type-plus';
2
+ import { logLevels } from './logLevels.js';
3
+ import { logLevelStore } from './logStore.js';
4
+ import { rangeEntries } from './testUtil.js';
5
+ describe('getName()', () => {
6
+ it.each([
7
+ ...rangeEntries(99, 100, 'emergency'),
8
+ ...rangeEntries(199, 200, 'alert'),
9
+ ...rangeEntries(299, 300, 'critical'),
10
+ ...rangeEntries(399, 400, 'error'),
11
+ ...rangeEntries(499, 500, 'warn'),
12
+ ...rangeEntries(599, 600, 'notice'),
13
+ ...rangeEntries(699, 700, 'info'),
14
+ ...rangeEntries(799, 800, 'debug'),
15
+ ...rangeEntries(899, 900, 'trace'),
16
+ ...rangeEntries(9999999, 10000000, 'planck')
17
+ ])('convert %i to %s', (level, logLevel) => {
18
+ const store = logLevelStore({ customLevels: {} });
19
+ expect(store.getName(level)).toBe(logLevel);
20
+ });
21
+ it('gets custom log level name', () => {
22
+ const store = logLevelStore({ customLevels: { 'cust-name': 144 } });
23
+ expect(store.getName(144)).toBe('cust-name');
24
+ });
25
+ });
26
+ describe('getLevel()', () => {
27
+ it('get default log levels', () => {
28
+ const store = logLevelStore({ customLevels: {} });
29
+ const names = [
30
+ 'emergency',
31
+ 'alert',
32
+ 'critical',
33
+ 'error',
34
+ 'warn',
35
+ 'notice',
36
+ 'info',
37
+ 'debug',
38
+ 'trace',
39
+ 'planck'
40
+ ];
41
+ expect(names.map(n => store.getLevel(n))).toEqual([
42
+ 100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity
43
+ ]);
44
+ });
45
+ it('is case insensitive for default levels', () => {
46
+ const store = logLevelStore({ customLevels: {} });
47
+ const names = [
48
+ 'emerGency',
49
+ 'aleRt',
50
+ 'critIcal',
51
+ 'errOr',
52
+ 'warN',
53
+ 'nOtice',
54
+ 'iNfo',
55
+ 'deBug',
56
+ 'traCe',
57
+ 'planCk',
58
+ ];
59
+ expect(names.map(n => store.getLevel(n))).toEqual([
60
+ 100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity
61
+ ]);
62
+ });
63
+ it('gets custom log level', () => {
64
+ const store = logLevelStore({ customLevels: { 'cust-get': 123 } });
65
+ expect(store.getLevel('cust-get')).toBe(123);
66
+ });
67
+ });
68
+ describe('getAllLevels()', () => {
69
+ it('gets all default log levels except none and all', () => {
70
+ const store = logLevelStore({ customLevels: {} });
71
+ const actual = store.getAllLevels();
72
+ forEachKey(logLevels, name => {
73
+ if (name === 'none' || name === 'all') {
74
+ expect(actual.find(x => x.name === name)).toBeUndefined();
75
+ }
76
+ else {
77
+ expect(actual.find(x => x.name === name)).toEqual({ name, level: logLevels[name] });
78
+ }
79
+ });
80
+ });
81
+ it('include custom level (even if they have the same level value as one of the default level)', () => {
82
+ const store = logLevelStore({
83
+ customLevels: {
84
+ 'info_a': 301,
85
+ 'info_b': logLevels.info
86
+ }
87
+ });
88
+ const actual = store.getAllLevels();
89
+ expect(actual.find(x => x.name === 'info_a')).toEqual({ name: 'info_a', level: 301 });
90
+ expect(actual.find(x => x.name === 'info_b')).toEqual({ name: 'info_b', level: logLevels.info });
91
+ });
92
+ });
93
+ //# sourceMappingURL=logStore.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logStore.spec.js","sourceRoot":"","sources":["../ts/logStore.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,IAAI,CAAC;QACN,GAAG,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,WAAW,CAAC;QACrC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC;QAClC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC;QACrC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC;QAClC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC;QACjC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC;QACnC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC;QACjC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC;QAClC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC;QAClC,GAAG,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC;KAC7C,CAAC,CAAC,kBAAkB,EAAE,CAAC,KAAa,EAAE,QAAgB,EAAE,EAAE;QACzD,MAAM,KAAK,GAAG,aAA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C,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;aACpF;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,EAAE,CAAC,2FAA2F,EAAE,GAAG,EAAE;QACnG,MAAM,KAAK,GAAG,aAAa,CAAC;YAC1B,YAAY,EAAE;gBACZ,QAAQ,EAAE,GAAG;gBACb,QAAQ,EAAE,SAAS,CAAC,IAAI;aACzB;SACF,CAAC,CAAA;QACF,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,EAAE,CAAA;QACnC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QACrF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC,CAAA;IAClG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { forEachKey } from 'type-plus'\nimport { logLevels } from './logLevels.js'\nimport { logLevelStore } from './logStore.js'\nimport { rangeEntries } from './testUtil.js'\n\ndescribe('getName()', () => {\n it.each([\n ...rangeEntries(99, 100, 'emergency'),\n ...rangeEntries(199, 200, 'alert'),\n ...rangeEntries(299, 300, 'critical'),\n ...rangeEntries(399, 400, 'error'),\n ...rangeEntries(499, 500, 'warn'),\n ...rangeEntries(599, 600, 'notice'),\n ...rangeEntries(699, 700, 'info'),\n ...rangeEntries(799, 800, 'debug'),\n ...rangeEntries(899, 900, 'trace'),\n ...rangeEntries(9999999, 10000000, 'planck')\n ])('convert %i to %s', (level: number, logLevel: string) => {\n const store = logLevelStore({ customLevels: {} })\n expect(store.getName(level)).toBe(logLevel)\n })\n it('gets custom log level name', () => {\n const store = logLevelStore({ customLevels: { 'cust-name': 144 } })\n expect(store.getName(144)).toBe('cust-name')\n })\n})\n\ndescribe('getLevel()', () => {\n it('get default log levels', () => {\n const store = logLevelStore({ customLevels: {} })\n const names = [\n 'emergency',\n 'alert',\n 'critical',\n 'error',\n 'warn',\n 'notice',\n 'info',\n 'debug',\n 'trace',\n 'planck'\n ]\n expect(names.map(n => store.getLevel(n))).toEqual([\n 100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity\n ])\n })\n it('is case insensitive for default levels', () => {\n const store = logLevelStore({ customLevels: {} })\n const names = [\n 'emerGency',\n 'aleRt',\n 'critIcal',\n 'errOr',\n 'warN',\n 'nOtice',\n 'iNfo',\n 'deBug',\n 'traCe',\n 'planCk',\n ]\n expect(names.map(n => store.getLevel(n))).toEqual([\n 100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity\n ])\n })\n it('gets custom log level', () => {\n const store = logLevelStore({ customLevels: { 'cust-get': 123 } })\n expect(store.getLevel('cust-get')).toBe(123)\n })\n})\n\ndescribe('getAllLevels()', () => {\n it('gets all default log levels except none and all', () => {\n const store = logLevelStore({ customLevels: {} })\n const actual = store.getAllLevels()\n forEachKey(logLevels, name => {\n if (name === 'none' || name === 'all') {\n expect(actual.find(x => x.name === name)).toBeUndefined()\n }\n else {\n expect(actual.find(x => x.name === name)).toEqual({ name, level: logLevels[name] })\n }\n })\n })\n it('include custom level (even if they have the same level value as one of the default level)', () => {\n const store = logLevelStore({\n customLevels: {\n 'info_a': 301,\n 'info_b': logLevels.info\n }\n })\n const actual = store.getAllLevels()\n expect(actual.find(x => x.name === 'info_a')).toEqual({ name: 'info_a', level: 301 })\n expect(actual.find(x => x.name === 'info_b')).toEqual({ name: 'info_b', level: logLevels.info })\n })\n})\n"]}
@@ -0,0 +1,5 @@
1
+ import type { StackTraceMeta } from '@just-func/types';
2
+ import { LogStore } from './logStore.js';
3
+ import type { Logger, LoggerOptions, LogMethodNames } from './types.js';
4
+ export declare function createLogger<T extends string = LogMethodNames>([store, id, options]: [LogStore, string, LoggerOptions | undefined], meta?: StackTraceMeta): Logger;
5
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../ts/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGtD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAyB,MAAM,EAAE,aAAa,EAAE,cAAc,EAAe,MAAM,YAAY,CAAA;AAG3G,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EAC5D,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC,EACnE,IAAI,CAAC,EAAE,cAAc,GACpB,MAAM,CAyDR"}
package/esm/logger.js ADDED
@@ -0,0 +1,75 @@
1
+ import { InvalidId } from './errors.js';
2
+ import { logLevels } from './logLevels.js';
3
+ export function createLogger([store, id, options], meta) {
4
+ validateId(id, meta);
5
+ const writeTo = options?.writeTo ?? (() => true);
6
+ const [filter, reporters] = typeof writeTo === 'string'
7
+ ? [id => id === writeTo, store.reporters]
8
+ : writeTo instanceof RegExp
9
+ ? [id => writeTo.test(id), store.reporters]
10
+ : typeof writeTo === 'function'
11
+ ? [writeTo, store.reporters]
12
+ : [() => true, [writeTo]];
13
+ function write(entry) {
14
+ writeToReporters(reporters, entry, filter);
15
+ }
16
+ const logger = {
17
+ level: options?.level,
18
+ write
19
+ };
20
+ Object.defineProperties(logger, {
21
+ id: { value: id, writable: false },
22
+ count: {
23
+ writable: false,
24
+ value: ((counter) => (...args) => {
25
+ const level = logLevels.debug;
26
+ if (shouldLog(store, level, logger.level))
27
+ write({
28
+ id,
29
+ level,
30
+ args: [++counter, ...args],
31
+ timestamp: new Date()
32
+ });
33
+ })(0)
34
+ },
35
+ on: {
36
+ writable: false,
37
+ value: (level, logFn) => {
38
+ const logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level) : level;
39
+ if (shouldLog(store, logLevel, logger.level)) {
40
+ const methodName = store.logLevelStore.getName(logLevel);
41
+ const bindedMethod = logger[methodName].bind(logger);
42
+ const result = logFn(bindedMethod);
43
+ if (result)
44
+ bindedMethod(result);
45
+ }
46
+ }
47
+ }
48
+ });
49
+ store.logLevelStore.getAllLevels().forEach(function addMethod({ name, level }) {
50
+ Object.defineProperty(logger, name, {
51
+ writable: false,
52
+ value: (...args) => {
53
+ if (shouldLog(store, level, logger.level))
54
+ write({ id, level, args, timestamp: new Date() });
55
+ }
56
+ });
57
+ });
58
+ return logger;
59
+ }
60
+ function validateId(id, meta) {
61
+ if (/[`~!#$%^&*()=+[\]{},|<>?]/.test(id))
62
+ throw new InvalidId(id, meta);
63
+ }
64
+ function writeToReporters(reporters, logEntry, filter) {
65
+ reporters.filter(r => filter(r.id)).forEach(r => r.write(logEntry));
66
+ }
67
+ /**
68
+ * Determines should you log.
69
+ * @param loggerLevel Log level of the logger.
70
+ * It can be undefined which the global log level will be used.
71
+ */
72
+ function shouldLog(store, targetLevel, loggerLevel) {
73
+ return targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.logLevel);
74
+ }
75
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../ts/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK1C,MAAM,UAAU,YAAY,CAC1B,CAAC,KAAK,EAAE,EAAE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,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAA;YAC9F,CAAC;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,UAAU,CAAC,EAAU,EAAE,IAAqB;IACnD,IAAI,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;AACzE,CAAC;AAED,SAAS,gBAAgB,CAAC,SAAwB,EAAE,QAAkB,EAAE,MAAuC;IAC7G,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAS,CAAC,CAAC,CAAA;AACtE,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAe,EAAE,WAAqB,EAAE,WAAiC;IAC1F,OAAO,WAAW,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;AAClF,CAAC","sourcesContent":["import type { StackTraceMeta } from '@just-func/types'\nimport { InvalidId } from './errors.js'\nimport { logLevels } from './logLevels.js'\nimport { LogStore } from './logStore.js'\nimport type { LogEntry, LogFunction, Logger, LoggerOptions, LogMethodNames, LogReporter } from './types.js'\nimport { LogLevel } from './types.js'\n\nexport function createLogger<T extends string = LogMethodNames>(\n [store, id, options]: [LogStore, string, LoggerOptions | undefined],\n meta?: StackTraceMeta\n): Logger {\n validateId(id, meta)\n const writeTo = options?.writeTo ?? (() => true)\n const [filter, reporters]: [(reporterId: string) => boolean, LogReporter[]] = typeof writeTo === 'string'\n ? [id => id === writeTo, store.reporters]\n : writeTo instanceof RegExp\n ? [id => writeTo.test(id), store.reporters]\n : typeof writeTo === 'function'\n ? [writeTo, store.reporters]\n : [() => true, [writeTo]]\n\n function write(entry: LogEntry) {\n writeToReporters(reporters, entry, filter)\n }\n\n const logger = {\n level: options?.level,\n write\n } as any\n\n Object.defineProperties(logger, {\n id: { value: id, writable: false },\n count: {\n writable: false,\n value: ((counter) => (...args: any[]) => {\n const level = logLevels.debug\n if (shouldLog(store, level, logger.level))\n write({\n id,\n level,\n args: [++counter, ...args],\n timestamp: new Date()\n })\n })(0)\n },\n on: {\n writable: false,\n value: (level: number | T, logFn: LogFunction) => {\n const logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level)! : level\n if (shouldLog(store, logLevel, logger.level)) {\n const methodName = store.logLevelStore.getName(logLevel)\n const bindedMethod = logger[methodName].bind(logger)\n const result = logFn(bindedMethod)\n if (result) bindedMethod(result)\n }\n }\n }\n })\n store.logLevelStore.getAllLevels().forEach(function addMethod({ name, level }) {\n Object.defineProperty(logger, name, {\n writable: false,\n value: (...args: any[]) => {\n if (shouldLog(store, level, logger.level)) write({ id, level, args, timestamp: new Date() })\n }\n })\n })\n return logger\n}\n\nfunction validateId(id: string, meta?: StackTraceMeta) {\n if (/[`~!#$%^&*()=+[\\]{},|<>?]/.test(id)) throw new InvalidId(id, meta)\n}\n\nfunction writeToReporters(reporters: LogReporter[], logEntry: LogEntry, filter: (reporterId: string) => boolean) {\n reporters.filter(r => filter(r.id)).forEach(r => r.write(logEntry!))\n}\n\n/**\n * Determines should you log.\n * @param loggerLevel Log level of the logger.\n * It can be undefined which the global log level will be used.\n */\nfunction shouldLog(store: LogStore, targetLevel: LogLevel, loggerLevel: LogLevel | undefined) {\n return targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.logLevel)\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from '../types.js';
1
+ import type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js';
2
2
  export declare type MemoryLogReporter = LogReporter<LogEntry> & {
3
3
  logs: LogEntry[];
4
4
  /**
@@ -11,4 +11,4 @@ export declare type MemoryLogReporter = LogReporter<LogEntry> & {
11
11
  export declare type MemoryLogFormatter = LogFormatter<LogEntry>;
12
12
  export declare function toMessageWithLevel(logs: LogEntry[]): string;
13
13
  export declare function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
14
- //# sourceMappingURL=MemoryLogReporter.d.ts.map
14
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../ts/memory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEzF,oBAAY,iBAAiB,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG;IACtD,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB;;;OAGG;IACH,aAAa,IAAI,MAAM,CAAC;IACxB,sBAAsB,IAAI,MAAM,CAAA;CACjC,CAAA;AAED,oBAAY,kBAAkB,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;AAEvD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAQlD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAmBjG"}
package/esm/memory.js ADDED
@@ -0,0 +1,34 @@
1
+ import { required } from 'type-plus';
2
+ import { toInspectLogEntry } from './platform.js';
3
+ import { formatLogLevel } from './formatter.js';
4
+ export function toMessageWithLevel(logs) {
5
+ return logs.map(toInspectLogEntry)
6
+ .map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)
7
+ .join('\n')
8
+ // if it has more than this log,
9
+ // we assume it is running under tests,
10
+ // and remove this log to simplify testing.
11
+ .replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, '');
12
+ }
13
+ export function createMemoryLogReporter(options) {
14
+ const { id, formatter, filter } = required({ id: 'memory', formatter: (e) => e }, options);
15
+ const logs = [];
16
+ return Object.freeze({
17
+ id,
18
+ get formatter() { return formatter; },
19
+ get filter() { return filter; },
20
+ logs,
21
+ write(entry) {
22
+ if (filter && !filter(entry))
23
+ return;
24
+ logs.push(formatter(entry));
25
+ },
26
+ getLogMessage() {
27
+ return logs.map(toInspectLogEntry)
28
+ .map(log => log.args.join(' '))
29
+ .join('\n');
30
+ },
31
+ getLogMessageWithLevel() { return toMessageWithLevel(logs); }
32
+ });
33
+ }
34
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../ts/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAe/C,MAAM,UAAU,kBAAkB,CAAC,IAAgB;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC;SAC/B,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;SAChE,IAAI,CAAC,IAAI,CAAC;QACX,gCAAgC;QAChC,uCAAuC;QACvC,2CAA2C;SAC1C,OAAO,CAAC,mEAAmE,EAAE,EAAE,CAAC,CAAA;AACrF,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAsC;IAC5E,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IACpG,MAAM,IAAI,GAAe,EAAE,CAAA;IAC3B,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,EAAE;QACF,IAAI,SAAS,KAAK,OAAO,SAAS,CAAA,CAAC,CAAC;QACpC,IAAI,MAAM,KAAK,OAAO,MAAM,CAAA,CAAC,CAAC;QAC9B,IAAI;QACJ,KAAK,CAAC,KAAe;YACnB,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAE,OAAM;YACpC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;QAC7B,CAAC;QACD,aAAa;YACX,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC;iBAC/B,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBAC9B,IAAI,CAAC,IAAI,CAAC,CAAA;QACf,CAAC;QACD,sBAAsB,KAAK,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;KAC7D,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { required } from 'type-plus'\nimport { toInspectLogEntry } from './platform.js'\nimport { formatLogLevel } from './formatter.js'\nimport type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'\n\nexport type MemoryLogReporter = LogReporter<LogEntry> & {\n logs: LogEntry[],\n /**\n * Gets a simple log message for testing.\n * The message only contains arguments for each log entry.\n */\n getLogMessage(): string,\n getLogMessageWithLevel(): string\n}\n\nexport type MemoryLogFormatter = LogFormatter<LogEntry>\n\nexport function toMessageWithLevel(logs: LogEntry[]) {\n return logs.map(toInspectLogEntry)\n .map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n .join('\\n')\n // if it has more than this log,\n // we assume it is running under tests,\n // and remove this log to simplify testing.\n .replace(/^\\(WARN\\) already configured for test, ignoring config\\(\\) call\\n/, '')\n}\n\nexport function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter {\n const { id, formatter, filter } = required({ id: 'memory', formatter: (e: LogEntry) => e }, options)\n const logs: LogEntry[] = []\n return Object.freeze({\n id,\n get formatter() { return formatter },\n get filter() { return filter },\n logs,\n write(entry: LogEntry) {\n if (filter && !filter(entry)) return\n logs.push(formatter(entry))\n },\n getLogMessage() {\n return logs.map(toInspectLogEntry)\n .map(log => log.args.join(' '))\n .join('\\n')\n },\n getLogMessageWithLevel() { return toMessageWithLevel(logs) }\n })\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=memory.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.spec.d.ts","sourceRoot":"","sources":["../ts/memory.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,110 @@
1
+ import a from 'assertron';
2
+ import { createMemoryLogReporter, logLevels } from './index.js';
3
+ import { assertSSF, logEntriesToString } from './testUtil.js';
4
+ describe('MemoryLogReporter', () => {
5
+ it('filter is readonly', () => {
6
+ const reporter = createMemoryLogReporter();
7
+ const err = a.throws(() => { reporter.filter = () => true; }, err => /only a getter/.test(err));
8
+ assertSSF(err, __filename);
9
+ });
10
+ describe('unit tests', () => {
11
+ test('log entries are saved in the `logs` property', () => {
12
+ const reporter = createMemoryLogReporter();
13
+ const entry = { id: 'log', level: 1, args: ['some messages'], timestamp: new Date() };
14
+ reporter.write(entry);
15
+ expect(reporter.logs).toEqual([entry]);
16
+ });
17
+ test('can override id', () => {
18
+ const reporter = createMemoryLogReporter({ id: 'custom-id-mem' });
19
+ expect(reporter.id).toBe('custom-id-mem');
20
+ });
21
+ test('can filter', () => {
22
+ const filter = (entry) => entry.id !== 'secret';
23
+ const reporter = createMemoryLogReporter({ filter });
24
+ expect(reporter.filter).toBe(filter);
25
+ reporter.write({ id: 'ok', level: 1, args: ['some messages'], timestamp: new Date() });
26
+ reporter.write({ id: 'secret', level: 1, args: ['some messages'], timestamp: new Date() });
27
+ expect(reporter.logs.length).toBe(1);
28
+ });
29
+ test('formatter can be used to pre-process the log', () => {
30
+ const formatter = (entry) => ({
31
+ ...entry,
32
+ args: entry.args.map(arg => arg === 'secret' ? '<censored>' : arg)
33
+ });
34
+ const reporter = createMemoryLogReporter({ formatter });
35
+ expect(reporter.formatter).toBe(formatter);
36
+ const entry = { id: 'log', level: 1, args: ['a', 'secret', 'b'], timestamp: new Date() };
37
+ reporter.write(entry);
38
+ expect(reporter.logs[0].args[1]).toBe('<censored>');
39
+ });
40
+ describe('getLogMessages()', () => {
41
+ test('empty logs returns empty string', () => {
42
+ const reporter = createMemoryLogReporter();
43
+ expect(reporter.getLogMessage()).toEqual('');
44
+ });
45
+ test('print args', () => {
46
+ const reporter = createMemoryLogReporter();
47
+ const entry = { id: 'log', level: 1, args: ['miku', 'is', 'singing'], timestamp: new Date() };
48
+ reporter.write(entry);
49
+ expect(reporter.getLogMessage()).toEqual('miku is singing');
50
+ });
51
+ test('print object arg', () => {
52
+ const reporter = createMemoryLogReporter();
53
+ const entry = { id: 'log', level: 1, args: [{ 'miku': 'sing' }], timestamp: new Date() };
54
+ reporter.write(entry);
55
+ expect(reporter.getLogMessage()).toEqual("{ miku: 'sing' }");
56
+ });
57
+ });
58
+ describe('getLogMessageWithLevel', () => {
59
+ test('print with level', () => {
60
+ const reporter = createMemoryLogReporter();
61
+ reporter.write({ id: 'log', level: logLevels.info, args: ['msg 1'], timestamp: new Date() });
62
+ reporter.write({ id: 'log', level: logLevels.warn, args: ['msg 2'], timestamp: new Date() });
63
+ expect(reporter.getLogMessageWithLevel()).toEqual(`(INFO) msg 1\n(WARN) msg 2`);
64
+ });
65
+ });
66
+ });
67
+ });
68
+ describe('logEntriesToString()', () => {
69
+ test('convert log entries to string', () => {
70
+ const timestamp = new Date(2019, 6);
71
+ const actual = logEntriesToString([
72
+ { id: 'log', level: logLevels.emergency, args: ['emergency'], timestamp },
73
+ { id: 'log', level: logLevels.critical, args: ['critical'], timestamp },
74
+ { id: 'log', level: logLevels.alert, args: ['alert'], timestamp },
75
+ { id: 'log', level: logLevels.error, args: ['error'], timestamp },
76
+ { id: 'log', level: logLevels.warn, args: ['warn'], timestamp },
77
+ { id: 'log', level: logLevels.notice, args: ['notice'], timestamp },
78
+ { id: 'log', level: logLevels.info, args: ['info'], timestamp },
79
+ { id: 'log', level: logLevels.debug, args: ['debug'], timestamp },
80
+ { id: 'log', level: logLevels.trace, args: ['trace'], timestamp }
81
+ ]);
82
+ const iso = timestamp.toISOString();
83
+ expect(actual).toEqual(`${iso},log,(EMERGENCY),emergency
84
+ ${iso},log,(CRITICAL),critical
85
+ ${iso},log,(ALERT),alert
86
+ ${iso},log,(ERROR),error
87
+ ${iso},log,(WARN),warn
88
+ ${iso},log,(NOTICE),notice
89
+ ${iso},log,(INFO),info
90
+ ${iso},log,(DEBUG),debug
91
+ ${iso},log,(TRACE),trace`);
92
+ });
93
+ test('print out object', () => {
94
+ const timestamp = new Date(2021, 4);
95
+ const actual = logEntriesToString([
96
+ { id: 'log', level: logLevels.info, args: ['a', { a: 1 }], timestamp }
97
+ ]);
98
+ const iso = timestamp.toISOString();
99
+ expect(actual).toEqual(`${iso},log,(INFO),a,{ a: 1 }`);
100
+ });
101
+ test('print out array', () => {
102
+ const timestamp = new Date(2021, 4);
103
+ const actual = logEntriesToString([
104
+ { id: 'log', level: logLevels.info, args: ['a', [1, 2, 3]], timestamp }
105
+ ]);
106
+ const iso = timestamp.toISOString();
107
+ expect(actual).toEqual(`${iso},log,(INFO),a,[ 1, 2, 3 ]`);
108
+ });
109
+ });
110
+ //# sourceMappingURL=memory.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.spec.js","sourceRoot":"","sources":["../ts/memory.spec.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,WAAW,CAAA;AACzB,OAAO,EAAE,uBAAuB,EAAqC,SAAS,EAAE,MAAM,YAAY,CAAA;AAClG,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAE7D,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,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AM,MAAM,GAAG,kBAAkB,CAAC;YAChC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE;SACvE,CAAC,CAAA;QAEF,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,wBAAwB,CAAC,CAAA;IACxD,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC3B,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;QACnC,MAAM,MAAM,GAAG,kBAAkB,CAAC;YAChC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE;SACxE,CAAC,CAAA;QAEF,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,2BAA2B,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import a from 'assertron'\nimport { createMemoryLogReporter, LogEntry, LogFilter, LogFormatter, logLevels } from './index.js'\nimport { assertSSF, logEntriesToString } from './testUtil.js'\n\ndescribe('MemoryLogReporter', () => {\n it('filter is readonly', () => {\n const reporter = createMemoryLogReporter()\n const err = a.throws(() => { (reporter as any).filter = () => true }, err => /only a getter/.test(err))\n\n assertSSF(err, __filename)\n })\n\n describe('unit tests', () => {\n test('log entries are saved in the `logs` property', () => {\n const reporter = createMemoryLogReporter()\n const entry = { id: 'log', level: 1, args: ['some messages'], timestamp: new Date() }\n reporter.write(entry)\n expect(reporter.logs).toEqual([entry])\n })\n\n test('can override id', () => {\n const reporter = createMemoryLogReporter({ id: 'custom-id-mem' })\n expect(reporter.id).toBe('custom-id-mem')\n })\n\n test('can filter', () => {\n const filter: LogFilter = (entry) => entry.id !== 'secret'\n const reporter = createMemoryLogReporter({ filter })\n expect(reporter.filter).toBe(filter)\n reporter.write({ id: 'ok', level: 1, args: ['some messages'], timestamp: new Date() })\n reporter.write({ id: 'secret', level: 1, args: ['some messages'], timestamp: new Date() })\n expect(reporter.logs.length).toBe(1)\n })\n\n test('formatter can be used to pre-process the log', () => {\n const formatter: LogFormatter<LogEntry> = (entry) => ({\n ...entry,\n args: entry.args.map(arg => arg === 'secret' ? '<censored>' : arg)\n })\n const reporter = createMemoryLogReporter({ formatter })\n expect(reporter.formatter).toBe(formatter)\n\n const entry = { id: 'log', level: 1, args: ['a', 'secret', 'b'], timestamp: new Date() }\n reporter.write(entry)\n\n expect(reporter.logs[0].args[1]).toBe('<censored>')\n })\n\n describe('getLogMessages()', () => {\n test('empty logs returns empty string', () => {\n const reporter = createMemoryLogReporter()\n\n expect(reporter.getLogMessage()).toEqual('')\n })\n\n test('print args', () => {\n const reporter = createMemoryLogReporter()\n const entry = { id: 'log', level: 1, args: ['miku', 'is', 'singing'], timestamp: new Date() }\n reporter.write(entry)\n expect(reporter.getLogMessage()).toEqual('miku is singing')\n })\n\n test('print object arg', () => {\n const reporter = createMemoryLogReporter()\n const entry = { id: 'log', level: 1, args: [{ 'miku': 'sing' }], timestamp: new Date() }\n reporter.write(entry)\n expect(reporter.getLogMessage()).toEqual(\"{ miku: 'sing' }\")\n })\n })\n\n describe('getLogMessageWithLevel', () => {\n test('print with level', () => {\n const reporter = createMemoryLogReporter()\n reporter.write({ id: 'log', level: logLevels.info, args: ['msg 1'], timestamp: new Date() })\n reporter.write({ id: 'log', level: logLevels.warn, args: ['msg 2'], timestamp: new Date() })\n expect(reporter.getLogMessageWithLevel()).toEqual(`(INFO) msg 1\\n(WARN) msg 2`)\n })\n })\n })\n})\n\ndescribe('logEntriesToString()', () => {\n test('convert log entries to string', () => {\n const timestamp = new Date(2019, 6)\n const actual = logEntriesToString([\n { id: 'log', level: logLevels.emergency, args: ['emergency'], timestamp },\n { id: 'log', level: logLevels.critical, args: ['critical'], timestamp },\n { id: 'log', level: logLevels.alert, args: ['alert'], timestamp },\n { id: 'log', level: logLevels.error, args: ['error'], timestamp },\n { id: 'log', level: logLevels.warn, args: ['warn'], timestamp },\n { id: 'log', level: logLevels.notice, args: ['notice'], timestamp },\n { id: 'log', level: logLevels.info, args: ['info'], timestamp },\n { id: 'log', level: logLevels.debug, args: ['debug'], timestamp },\n { id: 'log', level: logLevels.trace, args: ['trace'], timestamp }\n ])\n\n const iso = timestamp.toISOString()\n expect(actual).toEqual(`${iso},log,(EMERGENCY),emergency\n${iso},log,(CRITICAL),critical\n${iso},log,(ALERT),alert\n${iso},log,(ERROR),error\n${iso},log,(WARN),warn\n${iso},log,(NOTICE),notice\n${iso},log,(INFO),info\n${iso},log,(DEBUG),debug\n${iso},log,(TRACE),trace`)\n })\n\n test('print out object', () => {\n const timestamp = new Date(2021, 4)\n const actual = logEntriesToString([\n { id: 'log', level: logLevels.info, args: ['a', { a: 1 }], timestamp }\n ])\n\n const iso = timestamp.toISOString()\n expect(actual).toEqual(`${iso},log,(INFO),a,{ a: 1 }`)\n })\n\n test('print out array', () => {\n const timestamp = new Date(2021, 4)\n const actual = logEntriesToString([\n { id: 'log', level: logLevels.info, args: ['a', [1, 2, 3]], timestamp }\n ])\n\n const iso = timestamp.toISOString()\n expect(actual).toEqual(`${iso},log,(INFO),a,[ 1, 2, 3 ]`)\n })\n})\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ConsoleLike, LogEntry } from './types.js';
2
+ export declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
3
+ export declare const polyfill: {
4
+ console?: ConsoleLike;
5
+ };
6
+ //# sourceMappingURL=platform.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.browser.d.ts","sourceRoot":"","sources":["../ts/platform.browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,iBAAiB,MAAO,QAAQ,aAAM,CAAA;AAEnD,eAAO,MAAM,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAO,CAAA"}
@@ -0,0 +1,3 @@
1
+ export const toInspectLogEntry = (e) => e;
2
+ export const polyfill = {};
3
+ //# sourceMappingURL=platform.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.browser.js","sourceRoot":"","sources":["../ts/platform.browser.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC,CAAA;AAEnD,MAAM,CAAC,MAAM,QAAQ,GAA8B,EAAE,CAAA","sourcesContent":["import type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => e\n\nexport const polyfill: { console?: ConsoleLike } = {}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ConsoleLike, LogEntry } from './types.js';
2
+ export declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
3
+ export declare const polyfill: {
4
+ console?: ConsoleLike;
5
+ };
6
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,iBAAiB,MAAO,QAAQ,aAEzC,CAAA;AAEJ,eAAO,MAAM,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAO,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { inspect } from 'util';
2
+ export const toInspectLogEntry = (e) => (e.args = e.args.map(value => typeof value === 'object' && value !== null ? inspect(value) : value),
3
+ e);
4
+ export const polyfill = {};
5
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAG9B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAW,EAAE,EAAE,CAAC,CAChD,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAClG,CAAC,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,QAAQ,GAA8B,EAAE,CAAA","sourcesContent":["import { inspect } from 'util'\nimport type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => (\n e.args = e.args.map(value => typeof value === 'object' && value !== null ? inspect(value) : value),\n e)\n\nexport const polyfill: { console?: ConsoleLike } = {}\n"]}
@@ -0,0 +1,28 @@
1
+ import { StackTraceMeta } from '@just-func/types';
2
+ import { LogStore } from './logStore.js';
3
+ import type { Logger, LoggerOptions, LogLevel, LogMethodNames, StandardLogOptions } from './types.js';
4
+ export interface StandardLogInstance<N extends string = LogMethodNames> {
5
+ logLevel: number;
6
+ toLogLevelName(level: number): string;
7
+ toLogLevel(name: N): number;
8
+ getLogger(params: [id: string, options?: LoggerOptions], meta?: StackTraceMeta): Logger<N | LogMethodNames>;
9
+ }
10
+ export interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {
11
+ }
12
+ export declare function createStandardLog<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLog<N>;
13
+ export declare function createStandardLogClosure<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): {
14
+ store: LogStore;
15
+ standardLog: StandardLog<N>;
16
+ };
17
+ export declare function createStandardLogForTest(logLevel?: LogLevel): {
18
+ reporter: import("./memory.js").MemoryLogReporter;
19
+ logLevel: number;
20
+ toLogLevelName: (level: number) => string;
21
+ toLogLevel: (name: LogMethodNames) => number;
22
+ getLogger: (params: [id: string, options?: LoggerOptions | undefined], meta?: StackTraceMeta | undefined) => Logger<LogMethodNames>;
23
+ };
24
+ /**
25
+ * Suppress logging within the code block.
26
+ */
27
+ export declare function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R;
28
+ //# sourceMappingURL=standardLog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standardLog.d.ts","sourceRoot":"","sources":["../ts/standardLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAIjD,OAAO,EAAkB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAErG,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACtC,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC,CAAC,GAAG,cAAc,CAAC,CAAA;CAC5G;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,CAAE,SAAQ,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;CACvG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