standard-log 8.0.1 → 9.0.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 (613) 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 +76 -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/index.d.ts +5 -14
  23. package/cjs/index.d.ts.map +1 -1
  24. package/cjs/index.js +5 -14
  25. package/cjs/index.js.map +1 -1
  26. package/cjs/logLevels.d.ts +60 -0
  27. package/cjs/logLevels.d.ts.map +1 -0
  28. package/cjs/logLevels.js +87 -0
  29. package/cjs/logLevels.js.map +1 -0
  30. package/cjs/logStore.d.ts +20 -0
  31. package/cjs/logStore.d.ts.map +1 -0
  32. package/cjs/logStore.js +44 -0
  33. package/cjs/logStore.js.map +1 -0
  34. package/cjs/logStore.spec.d.ts +2 -0
  35. package/cjs/logStore.spec.d.ts.map +1 -0
  36. package/cjs/logStore.spec.js +93 -0
  37. package/cjs/logStore.spec.js.map +1 -0
  38. package/cjs/logger.d.ts +6 -0
  39. package/cjs/logger.d.ts.map +1 -0
  40. package/cjs/logger.js +97 -0
  41. package/cjs/logger.js.map +1 -0
  42. package/{esm/memory/MemoryLogReporter.d.ts → cjs/memory.d.ts} +2 -2
  43. package/cjs/memory.d.ts.map +1 -0
  44. package/cjs/memory.js +39 -0
  45. package/cjs/memory.js.map +1 -0
  46. package/cjs/memory.spec.d.ts +2 -0
  47. package/cjs/memory.spec.d.ts.map +1 -0
  48. package/cjs/memory.spec.js +115 -0
  49. package/cjs/memory.spec.js.map +1 -0
  50. package/cjs/package.json +1 -3
  51. package/cjs/platform.browser.d.ts +7 -0
  52. package/cjs/platform.browser.d.ts.map +1 -0
  53. package/cjs/platform.browser.js +11 -0
  54. package/cjs/platform.browser.js.map +1 -0
  55. package/cjs/platform.d.ts +8 -0
  56. package/cjs/platform.d.ts.map +1 -0
  57. package/cjs/platform.js +26 -0
  58. package/cjs/platform.js.map +1 -0
  59. package/cjs/platform.spec.d.ts +2 -0
  60. package/cjs/platform.spec.d.ts.map +1 -0
  61. package/cjs/platform.spec.js +22 -0
  62. package/cjs/platform.spec.js.map +1 -0
  63. package/cjs/standardLog.d.ts +21 -0
  64. package/cjs/standardLog.d.ts.map +1 -0
  65. package/cjs/standardLog.js +59 -0
  66. package/cjs/standardLog.js.map +1 -0
  67. package/cjs/standardLog.spec.d.ts +2 -0
  68. package/cjs/standardLog.spec.d.ts.map +1 -0
  69. package/cjs/standardLog.spec.js +536 -0
  70. package/cjs/standardLog.spec.js.map +1 -0
  71. package/cjs/testUtil.d.ts +7 -5
  72. package/cjs/testUtil.d.ts.map +1 -1
  73. package/cjs/testUtil.js +11 -14
  74. package/cjs/testUtil.js.map +1 -1
  75. package/cjs/types.d.ts +33 -24
  76. package/cjs/types.d.ts.map +1 -1
  77. package/cjs/types.js.map +1 -1
  78. package/dist/standard-log.es5.js +324 -1078
  79. package/dist/standard-log.es5.js.gz +0 -0
  80. package/dist/standard-log.es5.js.map +1 -1
  81. package/dist/standard-log.es5.js.map.gz +0 -0
  82. package/dist/standard-log.esm.js +307 -1145
  83. package/dist/standard-log.esm.js.gz +0 -0
  84. package/dist/standard-log.esm.js.map +1 -1
  85. package/dist/standard-log.esm.js.map.gz +0 -0
  86. package/{cjs/console/createConsoleLogReporter.d.ts → esm/console.d.ts} +5 -5
  87. package/esm/console.d.ts.map +1 -0
  88. package/esm/{console/polyfilledConsole.js → console.js} +36 -4
  89. package/esm/console.js.map +1 -0
  90. package/esm/console.spec.d.ts +2 -0
  91. package/esm/console.spec.d.ts.map +1 -0
  92. package/esm/{console/createConsoleLogReporter.spec.js → console.spec.js} +50 -65
  93. package/esm/console.spec.js.map +1 -0
  94. package/esm/errors.d.ts +0 -10
  95. package/esm/errors.d.ts.map +1 -1
  96. package/esm/errors.js +0 -34
  97. package/esm/errors.js.map +1 -1
  98. package/esm/formatter.d.ts +6 -0
  99. package/esm/formatter.d.ts.map +1 -0
  100. package/esm/{formatter/createTimestampFormatter.js → formatter.js} +10 -2
  101. package/esm/formatter.js.map +1 -0
  102. package/esm/formatter.spec.d.ts +2 -0
  103. package/esm/formatter.spec.d.ts.map +1 -0
  104. package/esm/formatter.spec.js +30 -0
  105. package/esm/formatter.spec.js.map +1 -0
  106. package/esm/index.d.ts +5 -14
  107. package/esm/index.d.ts.map +1 -1
  108. package/esm/index.js +5 -14
  109. package/esm/index.js.map +1 -1
  110. package/esm/logLevels.d.ts +60 -0
  111. package/esm/logLevels.d.ts.map +1 -0
  112. package/esm/{logLevel.js → logLevels.js} +29 -3
  113. package/esm/logLevels.js.map +1 -0
  114. package/esm/logStore.d.ts +20 -0
  115. package/esm/logStore.d.ts.map +1 -0
  116. package/esm/logStore.js +37 -0
  117. package/esm/logStore.js.map +1 -0
  118. package/esm/logStore.spec.d.ts +2 -0
  119. package/esm/logStore.spec.d.ts.map +1 -0
  120. package/esm/logStore.spec.js +93 -0
  121. package/esm/logStore.spec.js.map +1 -0
  122. package/esm/logger.d.ts +6 -0
  123. package/esm/logger.d.ts.map +1 -0
  124. package/esm/logger.js +74 -0
  125. package/esm/logger.js.map +1 -0
  126. package/{cjs/memory/MemoryLogReporter.d.ts → esm/memory.d.ts} +2 -2
  127. package/esm/memory.d.ts.map +1 -0
  128. package/esm/memory.js +34 -0
  129. package/esm/memory.js.map +1 -0
  130. package/esm/memory.spec.d.ts +2 -0
  131. package/esm/memory.spec.d.ts.map +1 -0
  132. package/esm/memory.spec.js +110 -0
  133. package/esm/memory.spec.js.map +1 -0
  134. package/esm/platform.browser.d.ts +7 -0
  135. package/esm/platform.browser.d.ts.map +1 -0
  136. package/esm/platform.browser.js +6 -0
  137. package/esm/platform.browser.js.map +1 -0
  138. package/esm/platform.d.ts +8 -0
  139. package/esm/platform.d.ts.map +1 -0
  140. package/esm/platform.js +20 -0
  141. package/esm/platform.js.map +1 -0
  142. package/esm/platform.spec.d.ts +2 -0
  143. package/esm/platform.spec.d.ts.map +1 -0
  144. package/esm/{console/semverGt.spec.js → platform.spec.js} +2 -2
  145. package/esm/platform.spec.js.map +1 -0
  146. package/esm/standardLog.d.ts +21 -0
  147. package/esm/standardLog.d.ts.map +1 -0
  148. package/esm/standardLog.js +36 -0
  149. package/esm/standardLog.js.map +1 -0
  150. package/esm/standardLog.spec.d.ts +2 -0
  151. package/esm/standardLog.spec.d.ts.map +1 -0
  152. package/esm/standardLog.spec.js +434 -0
  153. package/esm/standardLog.spec.js.map +1 -0
  154. package/esm/testUtil.d.ts +7 -5
  155. package/esm/testUtil.d.ts.map +1 -1
  156. package/esm/testUtil.js +8 -12
  157. package/esm/testUtil.js.map +1 -1
  158. package/esm/types.d.ts +33 -24
  159. package/esm/types.d.ts.map +1 -1
  160. package/esm/types.js.map +1 -1
  161. package/package.json +10 -19
  162. package/ts/console.ts +72 -0
  163. package/ts/errors.ts +0 -12
  164. package/ts/{formatter/createTimestampFormatter.ts → formatter.ts} +12 -1
  165. package/ts/index.ts +5 -14
  166. package/ts/{logLevel.ts → logLevels.ts} +20 -3
  167. package/ts/logStore.ts +52 -0
  168. package/ts/logger.ts +85 -0
  169. package/ts/memory.ts +47 -0
  170. package/ts/platform.browser.ts +8 -0
  171. package/ts/platform.ts +25 -0
  172. package/ts/standardLog.ts +54 -0
  173. package/ts/types.ts +39 -30
  174. package/cjs/LogEntry.d.ts +0 -7
  175. package/cjs/LogEntry.d.ts.map +0 -1
  176. package/cjs/LogEntry.js +0 -3
  177. package/cjs/LogEntry.js.map +0 -1
  178. package/cjs/captureLogs.d.ts +0 -4
  179. package/cjs/captureLogs.d.ts.map +0 -1
  180. package/cjs/captureLogs.js +0 -33
  181. package/cjs/captureLogs.js.map +0 -1
  182. package/cjs/captureLogs.spec.d.ts +0 -2
  183. package/cjs/captureLogs.spec.d.ts.map +0 -1
  184. package/cjs/captureLogs.spec.js +0 -117
  185. package/cjs/captureLogs.spec.js.map +0 -1
  186. package/cjs/config.d.ts +0 -12
  187. package/cjs/config.d.ts.map +0 -1
  188. package/cjs/config.js +0 -59
  189. package/cjs/config.js.map +0 -1
  190. package/cjs/config.spec.d.ts +0 -2
  191. package/cjs/config.spec.d.ts.map +0 -1
  192. package/cjs/config.spec.js +0 -72
  193. package/cjs/config.spec.js.map +0 -1
  194. package/cjs/configForTest.d.ts +0 -5
  195. package/cjs/configForTest.d.ts.map +0 -1
  196. package/cjs/configForTest.js +0 -18
  197. package/cjs/configForTest.js.map +0 -1
  198. package/cjs/configForTest.spec.d.ts +0 -2
  199. package/cjs/configForTest.spec.d.ts.map +0 -1
  200. package/cjs/configForTest.spec.js +0 -17
  201. package/cjs/configForTest.spec.js.map +0 -1
  202. package/cjs/console/createConsoleLogReporter.d.ts.map +0 -1
  203. package/cjs/console/createConsoleLogReporter.js +0 -42
  204. package/cjs/console/createConsoleLogReporter.js.map +0 -1
  205. package/cjs/console/createConsoleLogReporter.spec.d.ts +0 -2
  206. package/cjs/console/createConsoleLogReporter.spec.d.ts.map +0 -1
  207. package/cjs/console/createConsoleLogReporter.spec.js.map +0 -1
  208. package/cjs/console/index.d.ts +0 -4
  209. package/cjs/console/index.d.ts.map +0 -1
  210. package/cjs/console/index.js +0 -20
  211. package/cjs/console/index.js.map +0 -1
  212. package/cjs/console/isConsoleDebugAvailable.d.ts +0 -2
  213. package/cjs/console/isConsoleDebugAvailable.d.ts.map +0 -1
  214. package/cjs/console/isConsoleDebugAvailable.js +0 -20
  215. package/cjs/console/isConsoleDebugAvailable.js.map +0 -1
  216. package/cjs/console/polyfilledConsole.d.ts +0 -7
  217. package/cjs/console/polyfilledConsole.d.ts.map +0 -1
  218. package/cjs/console/polyfilledConsole.js +0 -41
  219. package/cjs/console/polyfilledConsole.js.map +0 -1
  220. package/cjs/console/semverGt.d.ts +0 -2
  221. package/cjs/console/semverGt.d.ts.map +0 -1
  222. package/cjs/console/semverGt.js +0 -13
  223. package/cjs/console/semverGt.js.map +0 -1
  224. package/cjs/console/semverGt.spec.d.ts +0 -2
  225. package/cjs/console/semverGt.spec.d.ts.map +0 -1
  226. package/cjs/console/semverGt.spec.js +0 -22
  227. package/cjs/console/semverGt.spec.js.map +0 -1
  228. package/cjs/console/toConsoleMethod.d.ts +0 -2
  229. package/cjs/console/toConsoleMethod.d.ts.map +0 -1
  230. package/cjs/console/toConsoleMethod.js +0 -22
  231. package/cjs/console/toConsoleMethod.js.map +0 -1
  232. package/cjs/console/types.d.ts +0 -3
  233. package/cjs/console/types.d.ts.map +0 -1
  234. package/cjs/console/types.js +0 -3
  235. package/cjs/console/types.js.map +0 -1
  236. package/cjs/customLogLevel.d.ts +0 -11
  237. package/cjs/customLogLevel.d.ts.map +0 -1
  238. package/cjs/customLogLevel.js +0 -38
  239. package/cjs/customLogLevel.js.map +0 -1
  240. package/cjs/customLogLevel.spec.d.ts +0 -2
  241. package/cjs/customLogLevel.spec.d.ts.map +0 -1
  242. package/cjs/customLogLevel.spec.js +0 -37
  243. package/cjs/customLogLevel.spec.js.map +0 -1
  244. package/cjs/formatter/createTimestampFormatter.d.ts +0 -3
  245. package/cjs/formatter/createTimestampFormatter.d.ts.map +0 -1
  246. package/cjs/formatter/createTimestampFormatter.js +0 -26
  247. package/cjs/formatter/createTimestampFormatter.js.map +0 -1
  248. package/cjs/formatter/createTimestampFormatter.spec.d.ts +0 -2
  249. package/cjs/formatter/createTimestampFormatter.spec.d.ts.map +0 -1
  250. package/cjs/formatter/createTimestampFormatter.spec.js +0 -23
  251. package/cjs/formatter/createTimestampFormatter.spec.js.map +0 -1
  252. package/cjs/formatter/formatLogLevel.d.ts +0 -2
  253. package/cjs/formatter/formatLogLevel.d.ts.map +0 -1
  254. package/cjs/formatter/formatLogLevel.js +0 -10
  255. package/cjs/formatter/formatLogLevel.js.map +0 -1
  256. package/cjs/formatter/index.d.ts +0 -4
  257. package/cjs/formatter/index.d.ts.map +0 -1
  258. package/cjs/formatter/index.js +0 -20
  259. package/cjs/formatter/index.js.map +0 -1
  260. package/cjs/formatter/plainLogFormatter.d.ts +0 -3
  261. package/cjs/formatter/plainLogFormatter.d.ts.map +0 -1
  262. package/cjs/formatter/plainLogFormatter.js +0 -19
  263. package/cjs/formatter/plainLogFormatter.js.map +0 -1
  264. package/cjs/formatter/plainLogFormatter.spec.d.ts +0 -2
  265. package/cjs/formatter/plainLogFormatter.spec.d.ts.map +0 -1
  266. package/cjs/formatter/plainLogFormatter.spec.js +0 -9
  267. package/cjs/formatter/plainLogFormatter.spec.js.map +0 -1
  268. package/cjs/getDefaultReporter.browser.d.ts +0 -2
  269. package/cjs/getDefaultReporter.browser.d.ts.map +0 -1
  270. package/cjs/getDefaultReporter.browser.js +0 -15
  271. package/cjs/getDefaultReporter.browser.js.map +0 -1
  272. package/cjs/getDefaultReporter.d.ts +0 -2
  273. package/cjs/getDefaultReporter.d.ts.map +0 -1
  274. package/cjs/getDefaultReporter.js +0 -19
  275. package/cjs/getDefaultReporter.js.map +0 -1
  276. package/cjs/getLogModeFromEnvironment.browser.d.ts +0 -3
  277. package/cjs/getLogModeFromEnvironment.browser.d.ts.map +0 -1
  278. package/cjs/getLogModeFromEnvironment.browser.js +0 -9
  279. package/cjs/getLogModeFromEnvironment.browser.js.map +0 -1
  280. package/cjs/getLogModeFromEnvironment.d.ts +0 -3
  281. package/cjs/getLogModeFromEnvironment.d.ts.map +0 -1
  282. package/cjs/getLogModeFromEnvironment.js +0 -17
  283. package/cjs/getLogModeFromEnvironment.js.map +0 -1
  284. package/cjs/getLogModeFromEnvironment.spec.d.ts +0 -2
  285. package/cjs/getLogModeFromEnvironment.spec.d.ts.map +0 -1
  286. package/cjs/getLogModeFromEnvironment.spec.js +0 -25
  287. package/cjs/getLogModeFromEnvironment.spec.js.map +0 -1
  288. package/cjs/getLogger.d.ts +0 -9
  289. package/cjs/getLogger.d.ts.map +0 -1
  290. package/cjs/getLogger.js +0 -103
  291. package/cjs/getLogger.js.map +0 -1
  292. package/cjs/getLogger.spec.d.ts +0 -2
  293. package/cjs/getLogger.spec.d.ts.map +0 -1
  294. package/cjs/getLogger.spec.js +0 -485
  295. package/cjs/getLogger.spec.js.map +0 -1
  296. package/cjs/getLoggers.d.ts +0 -7
  297. package/cjs/getLoggers.d.ts.map +0 -1
  298. package/cjs/getLoggers.js +0 -15
  299. package/cjs/getLoggers.js.map +0 -1
  300. package/cjs/logLevel.d.ts +0 -106
  301. package/cjs/logLevel.d.ts.map +0 -1
  302. package/cjs/logLevel.js +0 -59
  303. package/cjs/logLevel.js.map +0 -1
  304. package/cjs/logLevel.spec.d.ts +0 -2
  305. package/cjs/logLevel.spec.d.ts.map +0 -1
  306. package/cjs/logLevel.spec.js +0 -195
  307. package/cjs/logLevel.spec.js.map +0 -1
  308. package/cjs/logLevelFn.d.ts +0 -20
  309. package/cjs/logLevelFn.d.ts.map +0 -1
  310. package/cjs/logLevelFn.js +0 -76
  311. package/cjs/logLevelFn.js.map +0 -1
  312. package/cjs/logReporter.d.ts +0 -7
  313. package/cjs/logReporter.d.ts.map +0 -1
  314. package/cjs/logReporter.js +0 -29
  315. package/cjs/logReporter.js.map +0 -1
  316. package/cjs/logReporter.spec.d.ts +0 -2
  317. package/cjs/logReporter.spec.d.ts.map +0 -1
  318. package/cjs/logReporter.spec.js +0 -98
  319. package/cjs/logReporter.spec.js.map +0 -1
  320. package/cjs/logReporterInternal.d.ts +0 -3
  321. package/cjs/logReporterInternal.d.ts.map +0 -1
  322. package/cjs/logReporterInternal.js +0 -23
  323. package/cjs/logReporterInternal.js.map +0 -1
  324. package/cjs/memory/MemoryLogReporter.d.ts.map +0 -1
  325. package/cjs/memory/MemoryLogReporter.js +0 -56
  326. package/cjs/memory/MemoryLogReporter.js.map +0 -1
  327. package/cjs/memory/MemoryLogReporter.spec.d.ts +0 -2
  328. package/cjs/memory/MemoryLogReporter.spec.d.ts.map +0 -1
  329. package/cjs/memory/MemoryLogReporter.spec.js +0 -124
  330. package/cjs/memory/MemoryLogReporter.spec.js.map +0 -1
  331. package/cjs/memory/index.d.ts +0 -3
  332. package/cjs/memory/index.d.ts.map +0 -1
  333. package/cjs/memory/index.js +0 -19
  334. package/cjs/memory/index.js.map +0 -1
  335. package/cjs/memory/logEntriesToString.d.ts +0 -3
  336. package/cjs/memory/logEntriesToString.d.ts.map +0 -1
  337. package/cjs/memory/logEntriesToString.js +0 -10
  338. package/cjs/memory/logEntriesToString.js.map +0 -1
  339. package/cjs/memory/logEntriesToString.spec.d.ts +0 -2
  340. package/cjs/memory/logEntriesToString.spec.d.ts.map +0 -1
  341. package/cjs/memory/logEntriesToString.spec.js +0 -36
  342. package/cjs/memory/logEntriesToString.spec.js.map +0 -1
  343. package/cjs/memory/toInspectStringForObject.d.ts +0 -3
  344. package/cjs/memory/toInspectStringForObject.d.ts.map +0 -1
  345. package/cjs/memory/toInspectStringForObject.js +0 -17
  346. package/cjs/memory/toInspectStringForObject.js.map +0 -1
  347. package/cjs/shouldLog.d.ts +0 -8
  348. package/cjs/shouldLog.d.ts.map +0 -1
  349. package/cjs/shouldLog.js +0 -14
  350. package/cjs/shouldLog.js.map +0 -1
  351. package/cjs/store.d.ts +0 -3
  352. package/cjs/store.d.ts.map +0 -1
  353. package/cjs/store.js +0 -27
  354. package/cjs/store.js.map +0 -1
  355. package/cjs/suppressLogs.d.ts +0 -6
  356. package/cjs/suppressLogs.d.ts.map +0 -1
  357. package/cjs/suppressLogs.js +0 -17
  358. package/cjs/suppressLogs.js.map +0 -1
  359. package/cjs/suppressLogs.spec.d.ts +0 -2
  360. package/cjs/suppressLogs.spec.d.ts.map +0 -1
  361. package/cjs/suppressLogs.spec.js +0 -31
  362. package/cjs/suppressLogs.spec.js.map +0 -1
  363. package/cjs/typesInternal.d.ts +0 -20
  364. package/cjs/typesInternal.d.ts.map +0 -1
  365. package/cjs/typesInternal.js +0 -3
  366. package/cjs/typesInternal.js.map +0 -1
  367. package/cjs/utils.d.ts +0 -6
  368. package/cjs/utils.d.ts.map +0 -1
  369. package/cjs/utils.js +0 -15
  370. package/cjs/utils.js.map +0 -1
  371. package/cjs/writeToReporters.d.ts +0 -6
  372. package/cjs/writeToReporters.d.ts.map +0 -1
  373. package/cjs/writeToReporters.js +0 -22
  374. package/cjs/writeToReporters.js.map +0 -1
  375. package/cjs/writeToReporters.spec.d.ts +0 -2
  376. package/cjs/writeToReporters.spec.d.ts.map +0 -1
  377. package/cjs/writeToReporters.spec.js +0 -59
  378. package/cjs/writeToReporters.spec.js.map +0 -1
  379. package/esm/LogEntry.d.ts +0 -7
  380. package/esm/LogEntry.d.ts.map +0 -1
  381. package/esm/LogEntry.js +0 -2
  382. package/esm/LogEntry.js.map +0 -1
  383. package/esm/captureLogs.d.ts +0 -4
  384. package/esm/captureLogs.d.ts.map +0 -1
  385. package/esm/captureLogs.js +0 -29
  386. package/esm/captureLogs.js.map +0 -1
  387. package/esm/captureLogs.spec.d.ts +0 -2
  388. package/esm/captureLogs.spec.d.ts.map +0 -1
  389. package/esm/captureLogs.spec.js +0 -45
  390. package/esm/captureLogs.spec.js.map +0 -1
  391. package/esm/config.d.ts +0 -12
  392. package/esm/config.d.ts.map +0 -1
  393. package/esm/config.js +0 -44
  394. package/esm/config.js.map +0 -1
  395. package/esm/config.spec.d.ts +0 -2
  396. package/esm/config.spec.d.ts.map +0 -1
  397. package/esm/config.spec.js +0 -67
  398. package/esm/config.spec.js.map +0 -1
  399. package/esm/configForTest.d.ts +0 -5
  400. package/esm/configForTest.d.ts.map +0 -1
  401. package/esm/configForTest.js +0 -14
  402. package/esm/configForTest.js.map +0 -1
  403. package/esm/configForTest.spec.d.ts +0 -2
  404. package/esm/configForTest.spec.d.ts.map +0 -1
  405. package/esm/configForTest.spec.js +0 -15
  406. package/esm/configForTest.spec.js.map +0 -1
  407. package/esm/console/createConsoleLogReporter.d.ts.map +0 -1
  408. package/esm/console/createConsoleLogReporter.js +0 -37
  409. package/esm/console/createConsoleLogReporter.js.map +0 -1
  410. package/esm/console/createConsoleLogReporter.spec.d.ts +0 -2
  411. package/esm/console/createConsoleLogReporter.spec.d.ts.map +0 -1
  412. package/esm/console/createConsoleLogReporter.spec.js.map +0 -1
  413. package/esm/console/index.d.ts +0 -4
  414. package/esm/console/index.d.ts.map +0 -1
  415. package/esm/console/index.js +0 -4
  416. package/esm/console/index.js.map +0 -1
  417. package/esm/console/isConsoleDebugAvailable.d.ts +0 -2
  418. package/esm/console/isConsoleDebugAvailable.d.ts.map +0 -1
  419. package/esm/console/isConsoleDebugAvailable.js +0 -13
  420. package/esm/console/isConsoleDebugAvailable.js.map +0 -1
  421. package/esm/console/polyfilledConsole.d.ts +0 -7
  422. package/esm/console/polyfilledConsole.d.ts.map +0 -1
  423. package/esm/console/polyfilledConsole.js.map +0 -1
  424. package/esm/console/semverGt.d.ts +0 -2
  425. package/esm/console/semverGt.d.ts.map +0 -1
  426. package/esm/console/semverGt.js +0 -9
  427. package/esm/console/semverGt.js.map +0 -1
  428. package/esm/console/semverGt.spec.d.ts +0 -2
  429. package/esm/console/semverGt.spec.d.ts.map +0 -1
  430. package/esm/console/semverGt.spec.js.map +0 -1
  431. package/esm/console/toConsoleMethod.d.ts +0 -2
  432. package/esm/console/toConsoleMethod.d.ts.map +0 -1
  433. package/esm/console/toConsoleMethod.js +0 -18
  434. package/esm/console/toConsoleMethod.js.map +0 -1
  435. package/esm/console/types.d.ts +0 -3
  436. package/esm/console/types.d.ts.map +0 -1
  437. package/esm/console/types.js +0 -2
  438. package/esm/console/types.js.map +0 -1
  439. package/esm/customLogLevel.d.ts +0 -11
  440. package/esm/customLogLevel.d.ts.map +0 -1
  441. package/esm/customLogLevel.js +0 -30
  442. package/esm/customLogLevel.js.map +0 -1
  443. package/esm/customLogLevel.spec.d.ts +0 -2
  444. package/esm/customLogLevel.spec.d.ts.map +0 -1
  445. package/esm/customLogLevel.spec.js +0 -32
  446. package/esm/customLogLevel.spec.js.map +0 -1
  447. package/esm/formatter/createTimestampFormatter.d.ts +0 -3
  448. package/esm/formatter/createTimestampFormatter.d.ts.map +0 -1
  449. package/esm/formatter/createTimestampFormatter.js.map +0 -1
  450. package/esm/formatter/createTimestampFormatter.spec.d.ts +0 -2
  451. package/esm/formatter/createTimestampFormatter.spec.d.ts.map +0 -1
  452. package/esm/formatter/createTimestampFormatter.spec.js +0 -21
  453. package/esm/formatter/createTimestampFormatter.spec.js.map +0 -1
  454. package/esm/formatter/formatLogLevel.d.ts +0 -2
  455. package/esm/formatter/formatLogLevel.d.ts.map +0 -1
  456. package/esm/formatter/formatLogLevel.js +0 -6
  457. package/esm/formatter/formatLogLevel.js.map +0 -1
  458. package/esm/formatter/index.d.ts +0 -4
  459. package/esm/formatter/index.d.ts.map +0 -1
  460. package/esm/formatter/index.js +0 -4
  461. package/esm/formatter/index.js.map +0 -1
  462. package/esm/formatter/plainLogFormatter.d.ts +0 -3
  463. package/esm/formatter/plainLogFormatter.d.ts.map +0 -1
  464. package/esm/formatter/plainLogFormatter.js +0 -5
  465. package/esm/formatter/plainLogFormatter.js.map +0 -1
  466. package/esm/formatter/plainLogFormatter.spec.d.ts +0 -2
  467. package/esm/formatter/plainLogFormatter.spec.d.ts.map +0 -1
  468. package/esm/formatter/plainLogFormatter.spec.js +0 -7
  469. package/esm/formatter/plainLogFormatter.spec.js.map +0 -1
  470. package/esm/getDefaultReporter.browser.d.ts +0 -2
  471. package/esm/getDefaultReporter.browser.d.ts.map +0 -1
  472. package/esm/getDefaultReporter.browser.js +0 -11
  473. package/esm/getDefaultReporter.browser.js.map +0 -1
  474. package/esm/getDefaultReporter.d.ts +0 -2
  475. package/esm/getDefaultReporter.d.ts.map +0 -1
  476. package/esm/getDefaultReporter.js +0 -15
  477. package/esm/getDefaultReporter.js.map +0 -1
  478. package/esm/getLogModeFromEnvironment.browser.d.ts +0 -3
  479. package/esm/getLogModeFromEnvironment.browser.d.ts.map +0 -1
  480. package/esm/getLogModeFromEnvironment.browser.js +0 -5
  481. package/esm/getLogModeFromEnvironment.browser.js.map +0 -1
  482. package/esm/getLogModeFromEnvironment.d.ts +0 -3
  483. package/esm/getLogModeFromEnvironment.d.ts.map +0 -1
  484. package/esm/getLogModeFromEnvironment.js +0 -13
  485. package/esm/getLogModeFromEnvironment.js.map +0 -1
  486. package/esm/getLogModeFromEnvironment.spec.d.ts +0 -2
  487. package/esm/getLogModeFromEnvironment.spec.d.ts.map +0 -1
  488. package/esm/getLogModeFromEnvironment.spec.js +0 -20
  489. package/esm/getLogModeFromEnvironment.spec.js.map +0 -1
  490. package/esm/getLogger.d.ts +0 -9
  491. package/esm/getLogger.d.ts.map +0 -1
  492. package/esm/getLogger.js +0 -78
  493. package/esm/getLogger.js.map +0 -1
  494. package/esm/getLogger.spec.d.ts +0 -2
  495. package/esm/getLogger.spec.d.ts.map +0 -1
  496. package/esm/getLogger.spec.js +0 -385
  497. package/esm/getLogger.spec.js.map +0 -1
  498. package/esm/getLoggers.d.ts +0 -7
  499. package/esm/getLoggers.d.ts.map +0 -1
  500. package/esm/getLoggers.js +0 -11
  501. package/esm/getLoggers.js.map +0 -1
  502. package/esm/logLevel.d.ts +0 -106
  503. package/esm/logLevel.d.ts.map +0 -1
  504. package/esm/logLevel.js.map +0 -1
  505. package/esm/logLevel.spec.d.ts +0 -2
  506. package/esm/logLevel.spec.d.ts.map +0 -1
  507. package/esm/logLevel.spec.js +0 -148
  508. package/esm/logLevel.spec.js.map +0 -1
  509. package/esm/logLevelFn.d.ts +0 -20
  510. package/esm/logLevelFn.d.ts.map +0 -1
  511. package/esm/logLevelFn.js +0 -67
  512. package/esm/logLevelFn.js.map +0 -1
  513. package/esm/logReporter.d.ts +0 -7
  514. package/esm/logReporter.d.ts.map +0 -1
  515. package/esm/logReporter.js +0 -21
  516. package/esm/logReporter.js.map +0 -1
  517. package/esm/logReporter.spec.d.ts +0 -2
  518. package/esm/logReporter.spec.d.ts.map +0 -1
  519. package/esm/logReporter.spec.js +0 -93
  520. package/esm/logReporter.spec.js.map +0 -1
  521. package/esm/logReporterInternal.d.ts +0 -3
  522. package/esm/logReporterInternal.d.ts.map +0 -1
  523. package/esm/logReporterInternal.js +0 -19
  524. package/esm/logReporterInternal.js.map +0 -1
  525. package/esm/memory/MemoryLogReporter.d.ts.map +0 -1
  526. package/esm/memory/MemoryLogReporter.js +0 -51
  527. package/esm/memory/MemoryLogReporter.js.map +0 -1
  528. package/esm/memory/MemoryLogReporter.spec.d.ts +0 -2
  529. package/esm/memory/MemoryLogReporter.spec.d.ts.map +0 -1
  530. package/esm/memory/MemoryLogReporter.spec.js +0 -111
  531. package/esm/memory/MemoryLogReporter.spec.js.map +0 -1
  532. package/esm/memory/index.d.ts +0 -3
  533. package/esm/memory/index.d.ts.map +0 -1
  534. package/esm/memory/index.js +0 -3
  535. package/esm/memory/index.js.map +0 -1
  536. package/esm/memory/logEntriesToString.d.ts +0 -3
  537. package/esm/memory/logEntriesToString.d.ts.map +0 -1
  538. package/esm/memory/logEntriesToString.js +0 -6
  539. package/esm/memory/logEntriesToString.js.map +0 -1
  540. package/esm/memory/logEntriesToString.spec.d.ts +0 -2
  541. package/esm/memory/logEntriesToString.spec.d.ts.map +0 -1
  542. package/esm/memory/logEntriesToString.spec.js +0 -42
  543. package/esm/memory/logEntriesToString.spec.js.map +0 -1
  544. package/esm/memory/toInspectStringForObject.d.ts +0 -3
  545. package/esm/memory/toInspectStringForObject.d.ts.map +0 -1
  546. package/esm/memory/toInspectStringForObject.js +0 -11
  547. package/esm/memory/toInspectStringForObject.js.map +0 -1
  548. package/esm/shouldLog.d.ts +0 -8
  549. package/esm/shouldLog.d.ts.map +0 -1
  550. package/esm/shouldLog.js +0 -10
  551. package/esm/shouldLog.js.map +0 -1
  552. package/esm/store.d.ts +0 -3
  553. package/esm/store.d.ts.map +0 -1
  554. package/esm/store.js +0 -24
  555. package/esm/store.js.map +0 -1
  556. package/esm/suppressLogs.d.ts +0 -6
  557. package/esm/suppressLogs.d.ts.map +0 -1
  558. package/esm/suppressLogs.js +0 -9
  559. package/esm/suppressLogs.js.map +0 -1
  560. package/esm/suppressLogs.spec.d.ts +0 -2
  561. package/esm/suppressLogs.spec.d.ts.map +0 -1
  562. package/esm/suppressLogs.spec.js +0 -29
  563. package/esm/suppressLogs.spec.js.map +0 -1
  564. package/esm/typesInternal.d.ts +0 -20
  565. package/esm/typesInternal.d.ts.map +0 -1
  566. package/esm/typesInternal.js +0 -2
  567. package/esm/typesInternal.js.map +0 -1
  568. package/esm/utils.d.ts +0 -6
  569. package/esm/utils.d.ts.map +0 -1
  570. package/esm/utils.js +0 -11
  571. package/esm/utils.js.map +0 -1
  572. package/esm/writeToReporters.d.ts +0 -6
  573. package/esm/writeToReporters.d.ts.map +0 -1
  574. package/esm/writeToReporters.js +0 -18
  575. package/esm/writeToReporters.js.map +0 -1
  576. package/esm/writeToReporters.spec.d.ts +0 -2
  577. package/esm/writeToReporters.spec.d.ts.map +0 -1
  578. package/esm/writeToReporters.spec.js +0 -9
  579. package/esm/writeToReporters.spec.js.map +0 -1
  580. package/ts/LogEntry.ts +0 -7
  581. package/ts/captureLogs.ts +0 -35
  582. package/ts/config.ts +0 -57
  583. package/ts/configForTest.ts +0 -16
  584. package/ts/console/createConsoleLogReporter.ts +0 -48
  585. package/ts/console/index.ts +0 -3
  586. package/ts/console/isConsoleDebugAvailable.ts +0 -11
  587. package/ts/console/polyfilledConsole.ts +0 -34
  588. package/ts/console/semverGt.ts +0 -9
  589. package/ts/console/toConsoleMethod.ts +0 -18
  590. package/ts/console/types.ts +0 -3
  591. package/ts/customLogLevel.ts +0 -35
  592. package/ts/formatter/formatLogLevel.ts +0 -6
  593. package/ts/formatter/index.ts +0 -3
  594. package/ts/formatter/plainLogFormatter.ts +0 -6
  595. package/ts/getDefaultReporter.browser.ts +0 -13
  596. package/ts/getDefaultReporter.ts +0 -15
  597. package/ts/getLogModeFromEnvironment.browser.ts +0 -6
  598. package/ts/getLogModeFromEnvironment.ts +0 -16
  599. package/ts/getLogger.ts +0 -92
  600. package/ts/getLoggers.ts +0 -12
  601. package/ts/logLevelFn.ts +0 -72
  602. package/ts/logReporter.ts +0 -26
  603. package/ts/logReporterInternal.ts +0 -18
  604. package/ts/memory/MemoryLogReporter.ts +0 -72
  605. package/ts/memory/index.ts +0 -2
  606. package/ts/memory/logEntriesToString.ts +0 -7
  607. package/ts/memory/toInspectStringForObject.ts +0 -13
  608. package/ts/shouldLog.ts +0 -11
  609. package/ts/store.ts +0 -25
  610. package/ts/suppressLogs.ts +0 -14
  611. package/ts/typesInternal.ts +0 -21
  612. package/ts/utils.ts +0 -11
  613. package/ts/writeToReporters.ts +0 -20
@@ -1,93 +0,0 @@
1
- import a from 'assertron';
2
- import { addLogReporter, clearLogReporters, config, createConsoleLogReporter, createMemoryLogReporter, getConsoleReporter, getLogReporter, hasConsoleReporter, logLevels, ProhibitedDuringProduction } from './index.js';
3
- import { store } from './store.js';
4
- import { assertSSF } from './testUtil.js';
5
- describe('production checks', () => {
6
- beforeEach(() => store.reset());
7
- describe('addLogReporter()', () => {
8
- test('throws in production mode', () => {
9
- config({ mode: 'production' });
10
- const reporter = createMemoryLogReporter();
11
- a.throws(() => addLogReporter(reporter), ProhibitedDuringProduction);
12
- });
13
- it('throw with ssf at call site', () => {
14
- config({ mode: 'production' });
15
- const reporter = createMemoryLogReporter();
16
- const err = a.throws(() => addLogReporter(reporter), ProhibitedDuringProduction);
17
- assertSSF(err, __filename);
18
- });
19
- });
20
- describe('clearLogReporters()', () => {
21
- test('throws in production mode', () => {
22
- config({ mode: 'production' });
23
- a.throws(() => clearLogReporters(), ProhibitedDuringProduction);
24
- });
25
- it('throw with ssf at call site', () => {
26
- config({ mode: 'production' });
27
- const err = a.throws(() => clearLogReporters(), ProhibitedDuringProduction);
28
- assertSSF(err, __filename);
29
- });
30
- });
31
- });
32
- describe('unit tests', () => {
33
- beforeEach(() => {
34
- store.reset();
35
- config({ mode: 'test' });
36
- });
37
- describe('addLogReporter()', () => {
38
- test('adds log reporter', () => {
39
- const count = store.value.reporters.length;
40
- const reporter = createMemoryLogReporter();
41
- addLogReporter(reporter);
42
- expect(store.value.reporters.length).toBe(count + 1);
43
- });
44
- describe('add another console reporter', () => {
45
- test('will not replace existing one', () => {
46
- expect(getLogReporter('console')).toBeDefined();
47
- addLogReporter(createConsoleLogReporter({ id: 'c2' }));
48
- expect(getLogReporter('c2')).toBeUndefined();
49
- expect(getLogReporter('console')).toBeDefined();
50
- });
51
- test('will carry over existing filter', () => {
52
- const filter = entry => entry.level < logLevels.alert;
53
- addLogReporter(createConsoleLogReporter({ id: 'c2', filter }));
54
- addLogReporter(createConsoleLogReporter({ id: 'c3' }));
55
- const c3 = getConsoleReporter();
56
- expect(c3.filter).toBe(filter);
57
- });
58
- test('will combine existing filter and new filter', () => {
59
- addLogReporter(createConsoleLogReporter({ id: 'c2', filter: entry => entry.level > logLevels.critical }));
60
- addLogReporter(createConsoleLogReporter({ id: 'c3', filter: entry => entry.level < logLevels.error }));
61
- const c2 = getConsoleReporter();
62
- expect(c2.filter({ level: logLevels.info })).toBe(false);
63
- expect(c2.filter({ level: logLevels.alert })).toBe(false);
64
- });
65
- });
66
- });
67
- describe('getLogReporter()', () => {
68
- test('get log reporter by id', () => {
69
- expect(getLogReporter('console')).toBeDefined();
70
- });
71
- test('get log reporter with unknown id gets undefined', () => {
72
- expect(getLogReporter('blah')).toBeUndefined();
73
- });
74
- });
75
- describe('clearLogReporters()', () => {
76
- test('removes all reporters', () => {
77
- clearLogReporters();
78
- expect(store.value.reporters.length).toBe(0);
79
- });
80
- });
81
- describe('hasConsoleReporter()', () => {
82
- test('returns true if there is a console reporter', () => {
83
- expect(hasConsoleReporter()).toBeTruthy();
84
- });
85
- test('returns false if there is no console reporter', () => {
86
- clearLogReporters();
87
- expect(hasConsoleReporter()).toBeFalsy();
88
- addLogReporter(createMemoryLogReporter());
89
- expect(hasConsoleReporter()).toBeFalsy();
90
- });
91
- });
92
- });
93
- //# sourceMappingURL=logReporter.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logReporter.spec.js","sourceRoot":"","sources":["../ts/logReporter.spec.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,WAAW,CAAA;AACzB,OAAO,EACL,cAAc,EAAE,iBAAiB,EAAE,MAAM,EACzC,wBAAwB,EAAE,uBAAuB,EACjD,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAC3C,SAAS,EAAE,0BAA0B,EACjD,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;IAE/B,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,IAAI,CAAC,2BAA2B,EAAE,GAAG,EAAE;YACrC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAA;YAC9B,MAAM,QAAQ,GAAG,uBAAuB,EAAE,CAAA;YAC1C,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,0BAA0B,CAAC,CAAA;QACtE,CAAC,CAAC,CAAA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,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC9C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,IAAI,CAAC,6CAA6C,EAAE,GAAG,EAAE;YACvD,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC,UAAU,EAAE,CAAA;QAC3C,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACzD,iBAAiB,EAAE,CAAA;YACnB,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC,SAAS,EAAE,CAAA;YACxC,cAAc,CAAC,uBAAuB,EAAE,CAAC,CAAA;YACzC,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC,SAAS,EAAE,CAAA;QAC1C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import a from 'assertron'\nimport {\n addLogReporter, clearLogReporters, config,\n createConsoleLogReporter, createMemoryLogReporter,\n getConsoleReporter, getLogReporter, hasConsoleReporter,\n LogFilter, logLevels, ProhibitedDuringProduction\n} from './index.js'\nimport { store } from './store.js'\nimport { assertSSF } from './testUtil.js'\n\ndescribe('production checks', () => {\n beforeEach(() => store.reset())\n\n describe('addLogReporter()', () => {\n test('throws in production mode', () => {\n config({ mode: 'production' })\n const reporter = createMemoryLogReporter()\n a.throws(() => addLogReporter(reporter), ProhibitedDuringProduction)\n })\n\n it('throw with ssf at call site', () => {\n config({ mode: 'production' })\n const reporter = createMemoryLogReporter()\n const err = a.throws(() => addLogReporter(reporter), ProhibitedDuringProduction)\n\n assertSSF(err, __filename)\n })\n })\n\n describe('clearLogReporters()', () => {\n test('throws in production mode', () => {\n config({ mode: 'production' })\n a.throws(() => clearLogReporters(), ProhibitedDuringProduction)\n })\n it('throw with ssf at call site', () => {\n config({ mode: 'production' })\n const err = a.throws(() => clearLogReporters(), ProhibitedDuringProduction)\n\n assertSSF(err, __filename)\n })\n })\n})\n\ndescribe('unit tests', () => {\n beforeEach(() => {\n store.reset()\n config({ mode: 'test' })\n })\n\n describe('addLogReporter()', () => {\n test('adds log reporter', () => {\n const count = store.value.reporters.length\n const reporter = createMemoryLogReporter()\n addLogReporter(reporter)\n\n expect(store.value.reporters.length).toBe(count + 1)\n })\n\n describe('add another console reporter', () => {\n test('will not replace existing one', () => {\n expect(getLogReporter('console')).toBeDefined()\n addLogReporter(createConsoleLogReporter({ id: 'c2' }))\n expect(getLogReporter('c2')).toBeUndefined()\n expect(getLogReporter('console')).toBeDefined()\n })\n\n test('will carry over existing filter', () => {\n const filter: LogFilter = entry => entry.level < logLevels.alert\n addLogReporter(createConsoleLogReporter({ id: 'c2', filter }))\n addLogReporter(createConsoleLogReporter({ id: 'c3' }))\n const c3 = getConsoleReporter()!\n expect(c3.filter).toBe(filter)\n })\n\n test('will combine existing filter and new filter', () => {\n addLogReporter(createConsoleLogReporter({ id: 'c2', filter: entry => entry.level > logLevels.critical }))\n addLogReporter(createConsoleLogReporter({ id: 'c3', filter: entry => entry.level < logLevels.error }))\n const c2 = getConsoleReporter()!\n expect(c2.filter!({ level: logLevels.info } as any)).toBe(false)\n expect(c2.filter!({ level: logLevels.alert } as any)).toBe(false)\n })\n })\n })\n\n describe('getLogReporter()', () => {\n test('get log reporter by id', () => {\n expect(getLogReporter('console')).toBeDefined()\n })\n\n test('get log reporter with unknown id gets undefined', () => {\n expect(getLogReporter('blah')).toBeUndefined()\n })\n })\n\n describe('clearLogReporters()', () => {\n test('removes all reporters', () => {\n clearLogReporters()\n\n expect(store.value.reporters.length).toBe(0)\n })\n })\n\n describe('hasConsoleReporter()', () => {\n test('returns true if there is a console reporter', () => {\n expect(hasConsoleReporter()).toBeTruthy()\n })\n test('returns false if there is no console reporter', () => {\n clearLogReporters()\n expect(hasConsoleReporter()).toBeFalsy()\n addLogReporter(createMemoryLogReporter())\n expect(hasConsoleReporter()).toBeFalsy()\n })\n })\n})\n"]}
@@ -1,3 +0,0 @@
1
- import { LogReporter } from './types.js';
2
- export declare function addLogReporterInternal(reporter: LogReporter): void;
3
- //# sourceMappingURL=logReporterInternal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logReporterInternal.d.ts","sourceRoot":"","sources":["../ts/logReporterInternal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,WAAW,QAa3D"}
@@ -1,19 +0,0 @@
1
- import { getConsoleReporter } from './logReporter.js';
2
- import { store } from './store.js';
3
- export function addLogReporterInternal(reporter) {
4
- if (reporter.isConsoleReporter) {
5
- const r = getConsoleReporter();
6
- if (r && reporter.filter) {
7
- const f = r.filter;
8
- const f2 = reporter.filter;
9
- if (f)
10
- r.filter = entry => f(entry) && f2(entry);
11
- else
12
- r.filter = f2;
13
- }
14
- }
15
- else {
16
- store.value.reporters.push(reporter);
17
- }
18
- }
19
- //# sourceMappingURL=logReporterInternal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logReporterInternal.js","sourceRoot":"","sources":["../ts/logReporterInternal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGlC,MAAM,UAAU,sBAAsB,CAAC,QAAqB;IAC1D,IAAI,QAAQ,CAAC,iBAAiB,EAAE;QAC9B,MAAM,CAAC,GAAG,kBAAkB,EAAE,CAAA;QAC9B,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAM,EAAE;YACxB,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAA;YAClB,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAA;YAC1B,IAAI,CAAC;gBAAE,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAA;;gBAC3C,CAAC,CAAC,MAAM,GAAG,EAAE,CAAA;SACnB;KACF;SACI;QACH,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KACrC;AACH,CAAC","sourcesContent":["import { getConsoleReporter } from './logReporter.js'\nimport { store } from './store.js'\nimport { LogReporter } from './types.js'\n\nexport function addLogReporterInternal(reporter: LogReporter) {\n if (reporter.isConsoleReporter) {\n const r = getConsoleReporter()\n if (r && reporter.filter) {\n const f = r.filter\n const f2 = reporter.filter\n if (f) r.filter = entry => f(entry) && f2(entry)\n else r.filter = f2\n }\n }\n else {\n store.value.reporters.push(reporter)\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MemoryLogReporter.d.ts","sourceRoot":"","sources":["../../ts/memory/MemoryLogReporter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAa,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIhG,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;AAUvD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAQlD;AAGD,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAkCjG"}
@@ -1,51 +0,0 @@
1
- import { required } from 'type-plus';
2
- import { formatLogLevel } from '../formatter/index.js';
3
- import { assertLogModeIsNotProduction } from '../utils.js';
4
- import { toInspectLogEntry } from './toInspectStringForObject.js';
5
- function createGetLogMessage() {
6
- return function getLogMessage() {
7
- return this.logs.map(toInspectLogEntry)
8
- .map(log => log.args.join(' '))
9
- .join('\n');
10
- };
11
- }
12
- export function toMessageWithLevel(logs) {
13
- return logs.map(toInspectLogEntry)
14
- .map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)
15
- .join('\n')
16
- // if it has more than this log,
17
- // we assume it is running under tests,
18
- // and remove this log to simplify testing.
19
- .replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, '');
20
- }
21
- export function createMemoryLogReporter(options) {
22
- const opt = required({ id: 'memory', formatter: (e) => e }, options);
23
- const { id } = opt;
24
- let { formatter, filter } = opt;
25
- return {
26
- id,
27
- get formatter() {
28
- return formatter;
29
- },
30
- set formatter(value) {
31
- assertLogModeIsNotProduction('set Reporter.formatter', Object.getOwnPropertyDescriptor(this, 'formatter').set);
32
- formatter = value;
33
- },
34
- get filter() {
35
- return filter;
36
- },
37
- set filter(value) {
38
- assertLogModeIsNotProduction('set Reporter.filter', Object.getOwnPropertyDescriptor(this, 'filter').set);
39
- filter = value;
40
- },
41
- logs: [],
42
- write(entry) {
43
- if (filter && !filter(entry))
44
- return;
45
- this.logs.push(formatter(entry));
46
- },
47
- getLogMessage: createGetLogMessage(),
48
- getLogMessageWithLevel() { return toMessageWithLevel(this.logs); }
49
- };
50
- }
51
- //# sourceMappingURL=MemoryLogReporter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MemoryLogReporter.js","sourceRoot":"","sources":["../../ts/memory/MemoryLogReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAcjE,SAAS,mBAAmB;IAC1B,OAAO,SAAS,aAAa;QAC3B,OAAO,IA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4B,CAC1B,qBAAqB,EACrB,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,QAAQ,CAAE,CAAC,GAAI,CACtD,CAAA;YACD,MAAM,GAAG,KAAK,CAAA;QAChB,CAAC;QACD,IAAI,EAAE,EAAE;QACR,KAAK,CAAC,KAAK;YACT,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAE,OAAM;YACpC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;QAClC,CAAC;QACD,aAAa,EAAE,mBAAmB,EAAE;QACpC,sBAAsB,KAAK,OAAO,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;KAClE,CAAA;AACH,CAAC","sourcesContent":["import { required } from 'type-plus'\nimport { formatLogLevel } from '../formatter/index.js'\nimport { LogEntry, LogFilter, LogFormatter, LogReporter, LogReporterOptions } from '../types.js'\nimport { assertLogModeIsNotProduction } from '../utils.js'\nimport { toInspectLogEntry } from './toInspectStringForObject.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\nfunction createGetLogMessage() {\n return function getLogMessage(this: { logs: LogEntry[] }) {\n return this.logs.map(toInspectLogEntry)\n .map(log => log.args.join(' '))\n .join('\\n')\n }\n}\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\n\nexport function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter {\n const opt = required({ id: 'memory', formatter: (e: LogEntry) => e }, options)\n const { id } = opt\n let { formatter, filter } = opt\n return {\n id,\n get formatter() {\n return formatter\n },\n set formatter(value: MemoryLogFormatter) {\n assertLogModeIsNotProduction(\n 'set Reporter.formatter',\n Object.getOwnPropertyDescriptor(this, 'formatter')!.set!\n )\n formatter = value\n },\n get filter() {\n return filter\n },\n set filter(value: LogFilter) {\n assertLogModeIsNotProduction(\n 'set Reporter.filter',\n Object.getOwnPropertyDescriptor(this, 'filter')!.set!\n )\n filter = value\n },\n logs: [],\n write(entry) {\n if (filter && !filter(entry)) return\n this.logs.push(formatter(entry))\n },\n getLogMessage: createGetLogMessage(),\n getLogMessageWithLevel() { return toMessageWithLevel(this.logs) }\n }\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=MemoryLogReporter.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MemoryLogReporter.spec.d.ts","sourceRoot":"","sources":["../../ts/memory/MemoryLogReporter.spec.ts"],"names":[],"mappings":""}
@@ -1,111 +0,0 @@
1
- import a from 'assertron';
2
- import { config, createMemoryLogReporter, logLevels, ProhibitedDuringProduction } from '../index.js';
3
- import { configForTest } from '../configForTest.js';
4
- import { getLogger } from '../getLogger.js';
5
- import { store } from '../store.js';
6
- import { assertSSF } from '../testUtil.js';
7
- describe('production checks', () => {
8
- beforeEach(() => store.reset());
9
- test('set formatter in production mode throws', () => {
10
- config({ mode: 'production' });
11
- const reporter = createMemoryLogReporter();
12
- a.throws(() => { reporter.formatter = e => e; }, ProhibitedDuringProduction);
13
- });
14
- it('set formatter throws with ssf at call site', () => {
15
- config({ mode: 'production' });
16
- const reporter = createMemoryLogReporter();
17
- const err = a.throws(() => { reporter.formatter = e => e; }, ProhibitedDuringProduction);
18
- assertSSF(err, __filename);
19
- });
20
- test('set filter in production mode throws', () => {
21
- config({ mode: 'production' });
22
- const reporter = createMemoryLogReporter();
23
- a.throws(() => { reporter.filter = () => true; }, ProhibitedDuringProduction);
24
- });
25
- it('set filter throws with ssf at call site', () => {
26
- config({ mode: 'production' });
27
- const reporter = createMemoryLogReporter();
28
- const err = a.throws(() => { reporter.filter = () => true; }, ProhibitedDuringProduction);
29
- assertSSF(err, __filename);
30
- });
31
- describe('getLogMessageWithLevel()', () => {
32
- test('the production log is omitted', () => {
33
- const { reporter } = configForTest();
34
- config({ mode: 'production' });
35
- getLogger('test').warn('some test warnings');
36
- expect(reporter.getLogMessageWithLevel()).toEqual(`(WARN) some test warnings`);
37
- });
38
- });
39
- });
40
- describe('unit tests', () => {
41
- beforeEach(() => {
42
- store.reset();
43
- config({ mode: 'test' });
44
- });
45
- test('log entries are saved in the `logs` property', () => {
46
- const reporter = createMemoryLogReporter();
47
- const entry = { id: 'log', level: 1, args: ['some messages'], timestamp: new Date() };
48
- reporter.write(entry);
49
- expect(reporter.logs).toEqual([entry]);
50
- });
51
- test('can override id', () => {
52
- const reporter = createMemoryLogReporter({ id: 'custom-id-mem' });
53
- expect(reporter.id).toBe('custom-id-mem');
54
- });
55
- test('can filter', () => {
56
- const reporter = createMemoryLogReporter({ filter(entry) { return entry.id !== 'secret'; } });
57
- reporter.write({ id: 'ok', level: 1, args: ['some messages'], timestamp: new Date() });
58
- reporter.write({ id: 'secret', level: 1, args: ['some messages'], timestamp: new Date() });
59
- expect(reporter.logs.length).toBe(1);
60
- });
61
- test('can change filter', () => {
62
- const reporter = createMemoryLogReporter();
63
- const filter = reporter.filter;
64
- reporter.filter = entry => entry.id !== 'secret';
65
- expect(reporter.filter).not.toEqual(filter);
66
- });
67
- test('formatter can be used to pre-process the log', () => {
68
- const reporter = createMemoryLogReporter({
69
- formatter: (entry) => ({
70
- ...entry,
71
- args: entry.args.map(arg => arg === 'secret' ? '<censored>' : arg)
72
- })
73
- });
74
- const entry = { id: 'log', level: 1, args: ['a', 'secret', 'b'], timestamp: new Date() };
75
- reporter.write(entry);
76
- expect(reporter.logs[0].args[1]).toBe('<censored>');
77
- });
78
- test('can change formatter', () => {
79
- const reporter = createMemoryLogReporter();
80
- const formatter = reporter.formatter;
81
- reporter.formatter = e => ({ ...e, args: e.args.reverse() });
82
- expect(reporter.formatter).not.toEqual(formatter);
83
- });
84
- describe('getLogMessages()', () => {
85
- test('empty logs returns empty string', () => {
86
- const reporter = createMemoryLogReporter();
87
- expect(reporter.getLogMessage()).toEqual('');
88
- });
89
- test('print args', () => {
90
- const reporter = createMemoryLogReporter();
91
- const entry = { id: 'log', level: 1, args: ['miku', 'is', 'singing'], timestamp: new Date() };
92
- reporter.write(entry);
93
- expect(reporter.getLogMessage()).toEqual('miku is singing');
94
- });
95
- test('print object arg', () => {
96
- const reporter = createMemoryLogReporter();
97
- const entry = { id: 'log', level: 1, args: [{ 'miku': 'sing' }], timestamp: new Date() };
98
- reporter.write(entry);
99
- expect(reporter.getLogMessage()).toEqual("{ miku: 'sing' }");
100
- });
101
- });
102
- describe('getLogMessageWithLevel', () => {
103
- test('print with level', () => {
104
- const reporter = createMemoryLogReporter();
105
- reporter.write({ id: 'log', level: logLevels.info, args: ['msg 1'], timestamp: new Date() });
106
- reporter.write({ id: 'log', level: logLevels.warn, args: ['msg 2'], timestamp: new Date() });
107
- expect(reporter.getLogMessageWithLevel()).toEqual(`(INFO) msg 1\n(WARN) msg 2`);
108
- });
109
- });
110
- });
111
- //# sourceMappingURL=MemoryLogReporter.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MemoryLogReporter.spec.js","sourceRoot":"","sources":["../../ts/memory/MemoryLogReporter.spec.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,WAAW,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,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,EAAE,GAAG,EAAE;QACtC,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC5B,MAAM,QAAQ,GAAG,uBAAuB,EAAE,CAAA;YAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAA;YAC5F,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAA;YAC5F,MAAM,CAAC,QAAQ,CAAC,sBAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAA;QACjF,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import a from 'assertron'\nimport { config, createMemoryLogReporter, logLevels, ProhibitedDuringProduction } from '../index.js'\nimport { configForTest } from '../configForTest.js'\nimport { getLogger } from '../getLogger.js'\nimport { store } from '../store.js'\nimport { assertSSF } from '../testUtil.js'\n\ndescribe('production checks', () => {\n beforeEach(() => store.reset())\n test('set formatter in production mode throws', () => {\n config({ mode: 'production' })\n const reporter = createMemoryLogReporter()\n\n a.throws(() => { reporter.formatter = e => e }, ProhibitedDuringProduction)\n })\n it('set formatter throws with ssf at call site', () => {\n config({ mode: 'production' })\n const reporter = createMemoryLogReporter()\n\n const err = a.throws(() => { reporter.formatter = e => e }, ProhibitedDuringProduction)\n\n assertSSF(err, __filename)\n })\n\n test('set filter in production mode throws', () => {\n config({ mode: 'production' })\n const reporter = createMemoryLogReporter()\n a.throws(() => { reporter.filter = () => true }, ProhibitedDuringProduction)\n })\n\n it('set filter throws with ssf at call site', () => {\n config({ mode: 'production' })\n const reporter = createMemoryLogReporter()\n const err = a.throws(() => { reporter.filter = () => true }, ProhibitedDuringProduction)\n\n assertSSF(err, __filename)\n })\n\n describe('getLogMessageWithLevel()', () => {\n test('the production log is omitted', () => {\n const { reporter } = configForTest()\n config({ mode: 'production' })\n getLogger('test').warn('some test warnings')\n expect(reporter.getLogMessageWithLevel()).toEqual(`(WARN) some test warnings`)\n })\n })\n})\n\ndescribe('unit tests', () => {\n beforeEach(() => {\n store.reset()\n config({ mode: 'test' })\n })\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 reporter = createMemoryLogReporter({ filter(entry) { return entry.id !== 'secret' } })\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('can change filter', () => {\n const reporter = createMemoryLogReporter()\n const filter = reporter.filter\n reporter.filter = entry => entry.id !== 'secret'\n expect(reporter.filter).not.toEqual(filter)\n })\n\n test('formatter can be used to pre-process the log', () => {\n const reporter = createMemoryLogReporter({\n formatter: (entry) => ({\n ...entry,\n args: entry.args.map(arg => arg === 'secret' ? '<censored>' : arg)\n })\n })\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 test('can change formatter', () => {\n const reporter = createMemoryLogReporter()\n const formatter = reporter.formatter\n reporter.formatter = e => ({ ...e, args: e.args.reverse() })\n expect(reporter.formatter).not.toEqual(formatter)\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"]}
@@ -1,3 +0,0 @@
1
- export * from './logEntriesToString.js';
2
- export * from './MemoryLogReporter.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/memory/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './logEntriesToString.js';
2
- export * from './MemoryLogReporter.js';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/memory/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA","sourcesContent":["export * from './logEntriesToString.js'\nexport * from './MemoryLogReporter.js'\n"]}
@@ -1,3 +0,0 @@
1
- import { LogEntry } from '../types.js';
2
- export declare function logEntriesToString(logs: LogEntry[]): string;
3
- //# sourceMappingURL=logEntriesToString.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logEntriesToString.d.ts","sourceRoot":"","sources":["../../ts/memory/logEntriesToString.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAElD"}
@@ -1,6 +0,0 @@
1
- import { plainLogFormatter } from '../formatter/index.js';
2
- import { toInspectLogEntry } from './toInspectStringForObject.js';
3
- export function logEntriesToString(logs) {
4
- return logs.map(toInspectLogEntry).map(plainLogFormatter).join('\n');
5
- }
6
- //# sourceMappingURL=logEntriesToString.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logEntriesToString.js","sourceRoot":"","sources":["../../ts/memory/logEntriesToString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAEjE,MAAM,UAAU,kBAAkB,CAAC,IAAgB;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACtE,CAAC","sourcesContent":["import { plainLogFormatter } from '../formatter/index.js'\nimport { LogEntry } from '../types.js'\nimport { toInspectLogEntry } from './toInspectStringForObject.js'\n\nexport function logEntriesToString(logs: LogEntry[]) {\n return logs.map(toInspectLogEntry).map(plainLogFormatter).join('\\n')\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=logEntriesToString.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logEntriesToString.spec.d.ts","sourceRoot":"","sources":["../../ts/memory/logEntriesToString.spec.ts"],"names":[],"mappings":""}
@@ -1,42 +0,0 @@
1
- import { logLevels, logEntriesToString } from '../index.js';
2
- test('convert log entries to string', () => {
3
- const timestamp = new Date(2019, 6);
4
- const actual = logEntriesToString([
5
- { id: 'log', level: logLevels.emergency, args: ['emergency'], timestamp },
6
- { id: 'log', level: logLevels.critical, args: ['critical'], timestamp },
7
- { id: 'log', level: logLevels.alert, args: ['alert'], timestamp },
8
- { id: 'log', level: logLevels.error, args: ['error'], timestamp },
9
- { id: 'log', level: logLevels.warn, args: ['warn'], timestamp },
10
- { id: 'log', level: logLevels.notice, args: ['notice'], timestamp },
11
- { id: 'log', level: logLevels.info, args: ['info'], timestamp },
12
- { id: 'log', level: logLevels.debug, args: ['debug'], timestamp },
13
- { id: 'log', level: logLevels.trace, args: ['trace'], timestamp }
14
- ]);
15
- const iso = timestamp.toISOString();
16
- expect(actual).toEqual(`${iso},log,(EMERGENCY),emergency
17
- ${iso},log,(CRITICAL),critical
18
- ${iso},log,(ALERT),alert
19
- ${iso},log,(ERROR),error
20
- ${iso},log,(WARN),warn
21
- ${iso},log,(NOTICE),notice
22
- ${iso},log,(INFO),info
23
- ${iso},log,(DEBUG),debug
24
- ${iso},log,(TRACE),trace`);
25
- });
26
- test('print out object', () => {
27
- const timestamp = new Date(2021, 4);
28
- const actual = logEntriesToString([
29
- { id: 'log', level: logLevels.info, args: ['a', { a: 1 }], timestamp }
30
- ]);
31
- const iso = timestamp.toISOString();
32
- expect(actual).toEqual(`${iso},log,(INFO),a,{ a: 1 }`);
33
- });
34
- test('print out array', () => {
35
- const timestamp = new Date(2021, 4);
36
- const actual = logEntriesToString([
37
- { id: 'log', level: logLevels.info, args: ['a', [1, 2, 3]], timestamp }
38
- ]);
39
- const iso = timestamp.toISOString();
40
- expect(actual).toEqual(`${iso},log,(INFO),a,[ 1, 2, 3 ]`);
41
- });
42
- //# sourceMappingURL=logEntriesToString.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logEntriesToString.spec.js","sourceRoot":"","sources":["../../ts/memory/logEntriesToString.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAE3D,IAAI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A;AAC3D,CAAC,CAAC,CAAA","sourcesContent":["import { logLevels, logEntriesToString } from '../index.js'\n\ntest('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\ntest('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\ntest('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"]}
@@ -1,3 +0,0 @@
1
- import { LogEntry } from '../LogEntry.js';
2
- export declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
3
- //# sourceMappingURL=toInspectStringForObject.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toInspectStringForObject.d.ts","sourceRoot":"","sources":["../../ts/memory/toInspectStringForObject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,eAAO,MAAM,iBAAiB,MAIf,QAAQ,aAKD,CAAA"}
@@ -1,11 +0,0 @@
1
- import isNode from 'is-node';
2
- export const toInspectLogEntry = isNode
3
- ? (() => {
4
- // eslint-disable-next-line @typescript-eslint/no-var-requires
5
- const inspect = require('util').inspect;
6
- return (e) => (e.args = e.args.map(value => typeof value === 'object' && value !== null ? inspect(value) : value),
7
- e);
8
- })()
9
- // istanbul ignore next
10
- : (e) => e;
11
- //# sourceMappingURL=toInspectStringForObject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toInspectStringForObject.js","sourceRoot":"","sources":["../../ts/memory/toInspectStringForObject.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AAG5B,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM;IACrC,CAAC,CAAC,CAAC,GAAG,EAAE;QACN,8DAA8D;QAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAA;QACvC,OAAO,CAAC,CAAW,EAAE,EAAE,CAAC,CACtB,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;YAClG,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,EAAE;IACJ,uBAAuB;IACvB,CAAC,CAAC,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC,CAAA","sourcesContent":["import isNode from 'is-node'\nimport { LogEntry } from '../LogEntry.js'\n\nexport const toInspectLogEntry = isNode\n ? (() => {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const inspect = require('util').inspect\n return (e: LogEntry) => (\n e.args = e.args.map(value => typeof value === 'object' && value !== null ? inspect(value) : value),\n e)\n })()\n // istanbul ignore next\n : (e: LogEntry) => e\n"]}
@@ -1,8 +0,0 @@
1
- import { LogLevel } from './types.js';
2
- /**
3
- * Determines should you log.
4
- * @param loggerLevel Log level of the logger.
5
- * It can be undefined which the global log level will be used.
6
- */
7
- export declare function shouldLog(targetLevel: LogLevel, loggerLevel: LogLevel | undefined): boolean;
8
- //# sourceMappingURL=shouldLog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shouldLog.d.ts","sourceRoot":"","sources":["../ts/shouldLog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,GAAG,SAAS,WAEjF"}
package/esm/shouldLog.js DELETED
@@ -1,10 +0,0 @@
1
- import { store } from './store.js';
2
- /**
3
- * Determines should you log.
4
- * @param loggerLevel Log level of the logger.
5
- * It can be undefined which the global log level will be used.
6
- */
7
- export function shouldLog(targetLevel, loggerLevel) {
8
- return targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.value.logLevel);
9
- }
10
- //# sourceMappingURL=shouldLog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shouldLog.js","sourceRoot":"","sources":["../ts/shouldLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGlC;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,WAAqB,EAAE,WAAiC;IAChF,OAAO,WAAW,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;AACxF,CAAC","sourcesContent":["import { store } from './store.js'\nimport { LogLevel } from './types.js'\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 */\nexport function shouldLog(targetLevel: LogLevel, loggerLevel: LogLevel | undefined) {\n return targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.value.logLevel)\n}\n"]}
package/esm/store.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { LogStore } from './typesInternal.js';
2
- export declare const store: import("global-store").Store<LogStore>;
3
- //# sourceMappingURL=store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../ts/store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,eAAO,MAAM,KAAK,wCAmBhB,CAAA"}
package/esm/store.js DELETED
@@ -1,24 +0,0 @@
1
- import { createStore } from 'global-store';
2
- import { getLogModeFromEnvironment } from './getLogModeFromEnvironment.js';
3
- import { logLevels } from './logLevel.js';
4
- export const store = createStore({
5
- moduleName: 'standard-log',
6
- key: 'e53d0937-f420-40a0-9901-099725fa4a53',
7
- version: '2.0.0',
8
- initializer: (current) => {
9
- const mode = getLogModeFromEnvironment() || 'production';
10
- return {
11
- addCustomLogLevelListeners: [],
12
- configured: false,
13
- loggerClosures: {},
14
- redirects: {},
15
- reporters: [],
16
- customLevels: {},
17
- customLevelsReverse: [],
18
- mode,
19
- logLevel: logLevels.info,
20
- ...current
21
- };
22
- }
23
- });
24
- //# sourceMappingURL=store.js.map
package/esm/store.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../ts/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAW;IACzC,UAAU,EAAE,cAAc;IAC1B,GAAG,EAAE,sCAAsC;IAC3C,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE;QACvB,MAAM,IAAI,GAAG,yBAAyB,EAAE,IAAI,YAAY,CAAA;QACxD,OAAO;YACL,0BAA0B,EAAE,EAAE;YAC9B,UAAU,EAAE,KAAK;YACjB,cAAc,EAAE,EAAE;YAClB,SAAS,EAAE,EAAE;YACb,SAAS,EAAE,EAAE;YACb,YAAY,EAAE,EAAE;YAChB,mBAAmB,EAAE,EAAE;YACvB,IAAI;YACJ,QAAQ,EAAE,SAAS,CAAC,IAAI;YACxB,GAAG,OAAO;SACX,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { createStore } from 'global-store'\nimport { getLogModeFromEnvironment } from './getLogModeFromEnvironment.js'\nimport { logLevels } from './logLevel.js'\nimport { LogStore } from './typesInternal.js'\n\nexport const store = createStore<LogStore>({\n moduleName: 'standard-log',\n key: 'e53d0937-f420-40a0-9901-099725fa4a53',\n version: '2.0.0',\n initializer: (current) => {\n const mode = getLogModeFromEnvironment() || 'production'\n return {\n addCustomLogLevelListeners: [],\n configured: false,\n loggerClosures: {},\n redirects: {},\n reporters: [],\n customLevels: {},\n customLevelsReverse: [],\n mode,\n logLevel: logLevels.info,\n ...current\n }\n }\n})\n"]}
@@ -1,6 +0,0 @@
1
- import { Logger } from './types.js';
2
- /**
3
- * Suppress logging within the code block.
4
- */
5
- export declare function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R;
6
- //# sourceMappingURL=suppressLogs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"suppressLogs.d.ts","sourceRoot":"","sources":["../ts/suppressLogs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA"}
@@ -1,9 +0,0 @@
1
- import { logLevels } from './logLevel.js';
2
- export function suppressLogs(block, ...logs) {
3
- const origLevels = logs.map(l => l.level);
4
- logs.forEach(l => l.level = logLevels.none);
5
- const result = block();
6
- logs.forEach((l, i) => l.level = origLevels[i]);
7
- return result;
8
- }
9
- //# sourceMappingURL=suppressLogs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"suppressLogs.js","sourceRoot":"","sources":["../ts/suppressLogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAOzC,MAAM,UAAU,YAAY,CAAI,KAAc,EAAE,GAAG,IAAc;IAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACzC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;IAC3C,MAAM,MAAM,GAAG,KAAK,EAAE,CAAA;IACtB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/C,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { logLevels } from './logLevel.js'\nimport { Logger } from './types.js'\n\n/**\n * Suppress logging within the code block.\n */\nexport function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R\nexport function suppressLogs<R>(block: () => R, ...logs: Logger[]): R {\n const origLevels = logs.map(l => l.level)\n logs.forEach(l => l.level = logLevels.none)\n const result = block()\n logs.forEach((l, i) => l.level = origLevels[i])\n return result\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=suppressLogs.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"suppressLogs.spec.d.ts","sourceRoot":"","sources":["../ts/suppressLogs.spec.ts"],"names":[],"mappings":""}