standard-log 8.0.0 → 9.0.1

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 (614) 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 -55
  9. package/cjs/console.spec.js.map +1 -0
  10. package/cjs/errors.d.ts +1 -11
  11. package/cjs/errors.d.ts.map +1 -1
  12. package/cjs/errors.js +3 -45
  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 +548 -0
  70. package/cjs/standardLog.spec.js.map +1 -0
  71. package/cjs/testUtil.d.ts +7 -4
  72. package/cjs/testUtil.d.ts.map +1 -1
  73. package/cjs/testUtil.js +16 -13
  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 +326 -1079
  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 +309 -1146
  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 -52
  93. package/esm/console.spec.js.map +1 -0
  94. package/esm/errors.d.ts +1 -11
  95. package/esm/errors.d.ts.map +1 -1
  96. package/esm/errors.js +2 -36
  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 +446 -0
  153. package/esm/standardLog.spec.js.map +1 -0
  154. package/esm/testUtil.d.ts +7 -4
  155. package/esm/testUtil.d.ts.map +1 -1
  156. package/esm/testUtil.js +11 -11
  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 +12 -20
  162. package/ts/console.ts +72 -0
  163. package/ts/errors.ts +2 -14
  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 -66
  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 -19
  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 -481
  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 -86
  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 -111
  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 -5
  368. package/cjs/utils.d.ts.map +0 -1
  369. package/cjs/utils.js +0 -14
  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 -61
  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 -14
  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 -381
  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 -81
  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 -98
  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 -5
  569. package/esm/utils.d.ts.map +0 -1
  570. package/esm/utils.js +0 -10
  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 -42
  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 -66
  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/testUtil.ts +0 -19
  612. package/ts/typesInternal.ts +0 -21
  613. package/ts/utils.ts +0 -9
  614. package/ts/writeToReporters.ts +0 -20
@@ -1,30 +1,40 @@
1
- import a from 'assertron';
2
- import { addCustomLogLevel, clearCustomLogLevel, config, configForTest, createConsoleLogReporter, logLevels, plainLogFormatter, ProhibitedDuringProduction } from '../index.js';
3
- import { store } from '../store.js';
4
- describe('production checks', () => {
5
- beforeEach(() => store.reset());
6
- test('set filter during production mode throws', () => {
7
- config({ mode: 'production' });
8
- const reporter = createConsoleLogReporter();
9
- a.throws(() => { reporter.filter = () => true; }, ProhibitedDuringProduction);
1
+ import { createStandardLog } from './standardLog.js';
2
+ import { createConsoleLogReporter, logLevels, plainLogFormatter, toConsoleMethod } from './index.js';
3
+ import { polyfill } from './platform.js';
4
+ describe('toConsoleMethod()', () => {
5
+ it('converts any level to standard console method names: debug, info, warn, error', () => {
6
+ expect(toConsoleMethod(1)).toEqual('error');
7
+ expect(toConsoleMethod(399)).toEqual('error');
8
+ expect(toConsoleMethod(400)).toEqual('error');
9
+ expect(toConsoleMethod(401)).toEqual('warn');
10
+ expect(toConsoleMethod(499)).toEqual('warn');
11
+ expect(toConsoleMethod(500)).toEqual('warn');
12
+ expect(toConsoleMethod(501)).toEqual('info');
13
+ expect(toConsoleMethod(700)).toEqual('info');
14
+ expect(toConsoleMethod(701)).toEqual('debug');
15
+ expect(toConsoleMethod(800)).toEqual('debug');
16
+ expect(toConsoleMethod(801)).toEqual('debug');
17
+ expect(toConsoleMethod(Infinity)).toEqual('debug');
10
18
  });
11
- const idFormatter = (entry) => [entry.id];
12
- test('set formatter during production mode throws', () => {
13
- config({ mode: 'production' });
14
- const reporter = createConsoleLogReporter();
15
- a.throws(() => reporter.formatter = idFormatter, ProhibitedDuringProduction);
19
+ it('converts to debug for 0 (none) or negative (not valid) level', () => {
20
+ // these are invalid input.
21
+ // so instead of hiding them and not logged,
22
+ // log them so that it is easier to discover.
23
+ expect(toConsoleMethod(-1)).toEqual('debug');
24
+ expect(toConsoleMethod(0)).toEqual('debug');
16
25
  });
17
26
  });
18
- describe('unit tests', () => {
19
- beforeEach(() => configForTest());
20
- describe('rendering tests', () => {
21
- test('plain rendering', () => {
22
- const reporter = createConsoleLogReporter({ formatter: plainLogFormatter });
23
- ['emergency', 'info', 'warn', 'debug'].forEach(level => {
24
- reporter.write({ id: 'plain', level: logLevels[level], args: ['hello', 'world'], timestamp: new Date() });
25
- });
27
+ describe('rendering tests', () => {
28
+ test('plain rendering', () => {
29
+ const reporter = createConsoleLogReporter({ formatter: plainLogFormatter });
30
+ ['emergency', 'info', 'warn', 'debug'].forEach(level => {
31
+ reporter.write({ id: 'plain', level: logLevels[level], args: ['hello', 'world'], timestamp: new Date() });
26
32
  });
27
33
  });
34
+ });
35
+ describe('createConsoleLogReporter', () => {
36
+ let fakeConsole = createFakeConsole();
37
+ beforeEach(() => polyfill.console = fakeConsole = createFakeConsole());
28
38
  describe('id', () => {
29
39
  test('default is "console"', () => {
30
40
  const reporter = createConsoleLogReporter();
@@ -39,7 +49,6 @@ describe('unit tests', () => {
39
49
  test('error, alert, critical and emergency logs are written to console.error', () => {
40
50
  const id = 'log';
41
51
  const reporter = createConsoleLogReporter();
42
- const fakeConsole = reporter.console = createFakeConsole();
43
52
  reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
44
53
  reporter.write({ id, level: logLevels.critical, args: ['critical'], timestamp: new Date() });
45
54
  reporter.write({ id, level: logLevels.alert, args: ['alert'], timestamp: new Date() });
@@ -49,14 +58,12 @@ describe('unit tests', () => {
49
58
  test('warn logs are written to console.warn', () => {
50
59
  const id = 'log';
51
60
  const reporter = createConsoleLogReporter();
52
- const fakeConsole = reporter.console = createFakeConsole();
53
61
  reporter.write({ id, level: logLevels.warn, args: ['warn'], timestamp: new Date() });
54
62
  expect(fakeConsole.warns.length).toBe(1);
55
63
  });
56
64
  test('notice and info logs are written to console.info', () => {
57
65
  const id = 'log';
58
66
  const reporter = createConsoleLogReporter();
59
- const fakeConsole = reporter.console = createFakeConsole();
60
67
  reporter.write({ id, level: logLevels.notice, args: ['notice'], timestamp: new Date() });
61
68
  reporter.write({ id, level: logLevels.info, args: ['info'], timestamp: new Date() });
62
69
  expect(fakeConsole.infos.length).toBe(2);
@@ -64,7 +71,6 @@ describe('unit tests', () => {
64
71
  test('debug, trace, and planck logs are written to console.debug', () => {
65
72
  const id = 'log';
66
73
  const reporter = createConsoleLogReporter();
67
- const fakeConsole = reporter.console = createFakeConsole();
68
74
  reporter.write({ id, level: logLevels.debug, args: ['debug'], timestamp: new Date() });
69
75
  reporter.write({ id, level: logLevels.trace, args: ['trace'], timestamp: new Date() });
70
76
  reporter.write({ id, level: logLevels.planck, args: ['planck'], timestamp: new Date() });
@@ -72,19 +78,24 @@ describe('unit tests', () => {
72
78
  });
73
79
  });
74
80
  describe('custom logs', () => {
75
- afterEach(() => clearCustomLogLevel());
76
81
  test('are written according to their log level value', () => {
77
- addCustomLogLevel('high', 50);
78
- addCustomLogLevel('important', 450);
79
- addCustomLogLevel('interest', 650);
80
- addCustomLogLevel('silly', 1000);
81
82
  const id = 'log';
82
83
  const reporter = createConsoleLogReporter();
83
- const fakeConsole = reporter.console = createFakeConsole();
84
- reporter.write({ id, level: 50, args: ['a'], timestamp: new Date() });
85
- reporter.write({ id, level: 450, args: ['b'], timestamp: new Date() });
86
- reporter.write({ id, level: 650, args: ['c'], timestamp: new Date() });
87
- reporter.write({ id, level: 1000, args: ['d'], timestamp: new Date() });
84
+ const sl = createStandardLog({
85
+ logLevel: logLevels.all,
86
+ customLevels: {
87
+ 'high': 50,
88
+ 'important': 450,
89
+ 'interest': 650,
90
+ 'silly': 1000
91
+ },
92
+ reporters: [reporter]
93
+ });
94
+ const log = sl.getLogger([id]);
95
+ log.high('a');
96
+ log.important('b');
97
+ log.interest('c');
98
+ log.silly('d');
88
99
  expect(fakeConsole.errors.length).toBe(1);
89
100
  expect(fakeConsole.warns.length).toBe(1);
90
101
  expect(fakeConsole.infos.length).toBe(1);
@@ -96,37 +107,24 @@ describe('unit tests', () => {
96
107
  test('use specific formatter', () => {
97
108
  const id = 'id-only';
98
109
  const reporter = createConsoleLogReporter({ formatter: idFormatter });
99
- const fakeConsole = reporter.console = createFakeConsole();
110
+ expect(reporter.formatter).toBe(idFormatter);
100
111
  reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
101
112
  expect(fakeConsole.errors).toEqual([['id-only']]);
102
113
  });
103
- test('formatter can be changed afterward', () => {
104
- const reporter = createConsoleLogReporter();
105
- const formatter = reporter.formatter;
106
- reporter.formatter = idFormatter;
107
- expect(reporter.formatter).not.toEqual(formatter);
108
- });
109
114
  });
110
115
  describe('filter', () => {
111
116
  const filter = (entry) => entry.id !== 'secret';
112
117
  test('use specific filter', () => {
113
118
  const reporter = createConsoleLogReporter({ formatter: idFormatter, filter });
114
- const fakeConsole = reporter.console = createFakeConsole();
119
+ expect(reporter.filter).toBe(filter);
115
120
  reporter.write({ id: 'normal', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
116
121
  reporter.write({ id: 'secret', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
117
122
  expect(fakeConsole.errors).toEqual([['normal']]);
118
123
  });
119
- test('can change filter', () => {
120
- const reporter = createConsoleLogReporter();
121
- const filter = reporter.filter;
122
- reporter.filter = entry => entry.id !== 'secret';
123
- expect(reporter.filter).not.toEqual(filter);
124
- });
125
124
  });
126
125
  test('write log entry with multiple arguments', () => {
127
126
  const id = 'log';
128
127
  const reporter = createConsoleLogReporter({ formatter: plainLogFormatter });
129
- const fakeConsole = reporter.console = createFakeConsole();
130
128
  const entry = { id, level: logLevels.info, args: ['a', 'b', 'c'], timestamp: new Date() };
131
129
  reporter.write(entry);
132
130
  expect(fakeConsole.infos).toEqual([
@@ -150,4 +148,4 @@ function createFakeConsole() {
150
148
  debug(...args) { debugs.push(args); }
151
149
  };
152
150
  }
153
- //# sourceMappingURL=createConsoleLogReporter.spec.js.map
151
+ //# sourceMappingURL=console.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.spec.js","sourceRoot":"","sources":["../ts/console.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EACgB,wBAAwB,EAClC,SAAS,EAAE,iBAAiB,EAAE,eAAe,EACzD,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,+EAA+E,EAAE,GAAG,EAAE;QACvF,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC3C,MAAM,CAAC,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B,MAAM,KAAK,GAAU,EAAE,CAAA;IACvB,MAAM,KAAK,GAAU,EAAE,CAAA;IACvB,MAAM,MAAM,GAAU,EAAE,CAAA;IACxB,OAAO;QACL,MAAM;QACN,KAAK;QACL,KAAK;QACL,MAAM;QACN,KAAK,CAAC,GAAG,IAAW,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,IAAW,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,IAAW,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QACzC,KAAK,CAAC,GAAG,IAAW,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;KAC5C,CAAA;AACH,CAAC","sourcesContent":["import { createStandardLog } from './standardLog.js'\nimport {\n ConsoleLogFormatter, createConsoleLogReporter,\n LogFilter, logLevels, plainLogFormatter, toConsoleMethod\n} from './index.js'\nimport { polyfill } from './platform.js'\n\ndescribe('toConsoleMethod()', () => {\n it('converts any level to standard console method names: debug, info, warn, error', () => {\n expect(toConsoleMethod(1)).toEqual('error')\n expect(toConsoleMethod(399)).toEqual('error')\n expect(toConsoleMethod(400)).toEqual('error')\n\n expect(toConsoleMethod(401)).toEqual('warn')\n expect(toConsoleMethod(499)).toEqual('warn')\n expect(toConsoleMethod(500)).toEqual('warn')\n\n expect(toConsoleMethod(501)).toEqual('info')\n expect(toConsoleMethod(700)).toEqual('info')\n\n expect(toConsoleMethod(701)).toEqual('debug')\n expect(toConsoleMethod(800)).toEqual('debug')\n expect(toConsoleMethod(801)).toEqual('debug')\n expect(toConsoleMethod(Infinity)).toEqual('debug')\n })\n it('converts to debug for 0 (none) or negative (not valid) level', () => {\n // these are invalid input.\n // so instead of hiding them and not logged,\n // log them so that it is easier to discover.\n expect(toConsoleMethod(-1)).toEqual('debug')\n expect(toConsoleMethod(0)).toEqual('debug')\n })\n})\ndescribe('rendering tests', () => {\n test('plain rendering', () => {\n const reporter = createConsoleLogReporter({ formatter: plainLogFormatter });\n ['emergency', 'info', 'warn', 'debug'].forEach(level => {\n reporter.write({ id: 'plain', level: (logLevels as any)[level], args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n})\n\n\ndescribe('createConsoleLogReporter', () => {\n let fakeConsole = createFakeConsole()\n beforeEach(() => polyfill.console = fakeConsole = createFakeConsole())\n\n describe('id', () => {\n test('default is \"console\"', () => {\n const reporter = createConsoleLogReporter()\n expect(reporter.id).toBe('console')\n })\n test('can be overridden', () => {\n const reporter = createConsoleLogReporter({ id: 'neo-console' })\n expect(reporter.id).toBe('neo-console')\n })\n })\n\n describe('log level', () => {\n test('error, alert, critical and emergency logs are written to console.error', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.critical, args: ['critical'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.alert, args: ['alert'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.error, args: ['error'], timestamp: new Date() })\n\n expect(fakeConsole.errors.length).toBe(4)\n })\n\n test('warn logs are written to console.warn', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n reporter.write({ id, level: logLevels.warn, args: ['warn'], timestamp: new Date() })\n\n expect(fakeConsole.warns.length).toBe(1)\n })\n\n test('notice and info logs are written to console.info', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n reporter.write({ id, level: logLevels.notice, args: ['notice'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.info, args: ['info'], timestamp: new Date() })\n\n expect(fakeConsole.infos.length).toBe(2)\n })\n\n\n test('debug, trace, and planck logs are written to console.debug', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n reporter.write({ id, level: logLevels.debug, args: ['debug'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.trace, args: ['trace'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.planck, args: ['planck'], timestamp: new Date() })\n\n expect(fakeConsole.debugs.length).toBe(3)\n })\n })\n\n describe('custom logs', () => {\n test('are written according to their log level value', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n const sl = createStandardLog({\n logLevel: logLevels.all,\n customLevels: {\n 'high': 50,\n 'important': 450,\n 'interest': 650,\n 'silly': 1000\n },\n reporters: [reporter]\n })\n const log = sl.getLogger([id])\n log.high('a')\n log.important('b')\n log.interest('c')\n log.silly('d')\n\n expect(fakeConsole.errors.length).toBe(1)\n expect(fakeConsole.warns.length).toBe(1)\n expect(fakeConsole.infos.length).toBe(1)\n expect(fakeConsole.debugs.length).toBe(1)\n })\n })\n\n const idFormatter: ConsoleLogFormatter = (entry) => [entry.id]\n\n describe('formatter', () => {\n test('use specific formatter', () => {\n const id = 'id-only'\n const reporter = createConsoleLogReporter({ formatter: idFormatter })\n expect(reporter.formatter).toBe(idFormatter)\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['id-only']])\n })\n })\n\n describe('filter', () => {\n const filter: LogFilter = (entry) => entry.id !== 'secret'\n test('use specific filter', () => {\n const reporter = createConsoleLogReporter({ formatter: idFormatter, filter })\n expect(reporter.filter).toBe(filter)\n\n reporter.write({ id: 'normal', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n reporter.write({ id: 'secret', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['normal']])\n })\n })\n\n test('write log entry with multiple arguments', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter({ formatter: plainLogFormatter })\n\n const entry = { id, level: logLevels.info, args: ['a', 'b', 'c'], timestamp: new Date() }\n\n reporter.write(entry)\n\n expect(fakeConsole.infos).toEqual([\n [entry.timestamp.toISOString(), 'log', '(INFO)', 'a', 'b', 'c']\n ])\n })\n})\n\nfunction createFakeConsole() {\n const errors: any[] = []\n const infos: any[] = []\n const warns: any[] = []\n const debugs: any[] = []\n return {\n errors,\n infos,\n warns,\n debugs,\n error(...args: any[]) { errors.push(args) },\n info(...args: any[]) { infos.push(args) },\n warn(...args: any[]) { warns.push(args) },\n debug(...args: any[]) { debugs.push(args) }\n }\n}\n"]}
package/esm/errors.d.ts CHANGED
@@ -4,16 +4,6 @@ export declare class StandardLogError extends ModuleError {
4
4
  }
5
5
  export declare class InvalidId extends StandardLogError {
6
6
  id: string;
7
- constructor(id: string);
8
- }
9
- export declare class ProhibitedDuringProduction extends StandardLogError {
10
- action: string;
11
- constructor(action: string);
12
- }
13
- export declare class InvalidEnvVar extends StandardLogError {
14
- name: string;
15
- value: string;
16
- possibleValues: string[];
17
- constructor(name: string, value: string, possibleValues: string[]);
7
+ constructor(id: string, options?: IsoError.Options);
18
8
  }
19
9
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG5D;AACD,qBAAa,SAAU,SAAQ,gBAAgB;IAC1B,EAAE,EAAE,MAAM;gBAAV,EAAE,EAAE,MAAM;CAG9B;AAED,qBAAa,0BAA2B,SAAQ,gBAAgB;IAC3C,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;CAGlC;AAED,qBAAa,aAAc,SAAQ,gBAAgB;IAC9B,IAAI,EAAE,MAAM;IAAS,KAAK,EAAE,MAAM;IAAS,cAAc,EAAE,MAAM,EAAE;gBAAnE,IAAI,EAAE,MAAM,EAAS,KAAK,EAAE,MAAM,EAAS,cAAc,EAAE,MAAM,EAAE;CAGvF"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG5D;AACD,qBAAa,SAAU,SAAQ,gBAAgB;IAC1B,EAAE,EAAE,MAAM;gBAAV,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG1D"}
package/esm/errors.js CHANGED
@@ -5,8 +5,8 @@ export class StandardLogError extends ModuleError {
5
5
  }
6
6
  }
7
7
  export class InvalidId extends StandardLogError {
8
- constructor(id) {
9
- super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`);
8
+ constructor(id, options) {
9
+ super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`, options);
10
10
  Object.defineProperty(this, "id", {
11
11
  enumerable: true,
12
12
  configurable: true,
@@ -15,38 +15,4 @@ export class InvalidId extends StandardLogError {
15
15
  });
16
16
  }
17
17
  }
18
- export class ProhibitedDuringProduction extends StandardLogError {
19
- constructor(action) {
20
- super(`Cannot perform ${action} during production`);
21
- Object.defineProperty(this, "action", {
22
- enumerable: true,
23
- configurable: true,
24
- writable: true,
25
- value: action
26
- });
27
- }
28
- }
29
- export class InvalidEnvVar extends StandardLogError {
30
- constructor(name, value, possibleValues) {
31
- super(`${name} contains invalid value '${value}'${` valid values: [${possibleValues.join()}]`}`);
32
- Object.defineProperty(this, "name", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: name
37
- });
38
- Object.defineProperty(this, "value", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: value
43
- });
44
- Object.defineProperty(this, "possibleValues", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: possibleValues
49
- });
50
- }
51
- }
52
18
  //# sourceMappingURL=errors.js.map
package/esm/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC/C,YAAY,WAAmB,EAAE,OAA0B;QACzD,KAAK,CAAC,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;CACF;AACD,MAAM,OAAO,SAAU,SAAQ,gBAAgB;IAC7C,YAAmB,EAAU;QAC3B,KAAK,CAAC,kFAAkF,EAAE,EAAE,CAAC,CAAA;;;;;mBAD5E;;IAEnB,CAAC;CACF;AAED,MAAM,OAAO,0BAA2B,SAAQ,gBAAgB;IAC9D,YAAmB,MAAc;QAC/B,KAAK,CAAC,kBAAkB,MAAM,oBAAoB,CAAC,CAAA;;;;;mBADlC;;IAEnB,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,gBAAgB;IACjD,YAAmB,IAAY,EAAS,KAAa,EAAS,cAAwB;QACpF,KAAK,CAAC,GAAG,IAAI,4BAA4B,KAAK,IAAI,mBAAmB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAA;;;;;mBAD/E;;;;;;mBAAqB;;;;;;mBAAsB;;IAE9D,CAAC;CACF","sourcesContent":["import { IsoError, ModuleError } from 'iso-error'\n\nexport class StandardLogError extends ModuleError {\n constructor(description: string, options?: IsoError.Options) {\n super('standard-log', description, options)\n }\n}\nexport class InvalidId extends StandardLogError {\n constructor(public id: string) {\n super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`)\n }\n}\n\nexport class ProhibitedDuringProduction extends StandardLogError {\n constructor(public action: string) {\n super(`Cannot perform ${action} during production`)\n }\n}\n\nexport class InvalidEnvVar extends StandardLogError {\n constructor(public name: string, public value: string, public possibleValues: string[]) {\n super(`${name} contains invalid value '${value}'${` valid values: [${possibleValues.join()}]`}`)\n }\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC/C,YAAY,WAAmB,EAAE,OAA0B;QACzD,KAAK,CAAC,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;CACF;AACD,MAAM,OAAO,SAAU,SAAQ,gBAAgB;IAC7C,YAAmB,EAAU,EAAE,OAA0B;QACvD,KAAK,CAAC,kFAAkF,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;;;;;mBADrF;;IAEnB,CAAC;CACF","sourcesContent":["import { IsoError, ModuleError } from 'iso-error'\n\nexport class StandardLogError extends ModuleError {\n constructor(description: string, options?: IsoError.Options) {\n super('standard-log', description, options)\n }\n}\nexport class InvalidId extends StandardLogError {\n constructor(public id: string, options?: IsoError.Options) {\n super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`, options)\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { LogEntry } from './types.js';
2
+ export declare type TimestampFormat = 'none' | 'iso' | 'elapsed';
3
+ export declare function createTimestampFormatter(format: TimestampFormat): ((_timestamp: Date) => undefined) | ((timestamp: Date) => string);
4
+ export declare function formatLogLevel(level: number): string;
5
+ export declare function plainLogFormatter({ id, level, args, timestamp }: LogEntry): any[];
6
+ //# sourceMappingURL=formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,oBAAY,eAAe,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAA;AAExD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,iBAGtC,IAAI,+BAEL,IAAI,aAW5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,UAE3C;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,SAEzE"}
@@ -1,4 +1,6 @@
1
1
  import ms from 'ms';
2
+ import { upperCase } from 'upper-case';
3
+ import { toLogLevelName } from './logLevels.js';
2
4
  export function createTimestampFormatter(format) {
3
5
  switch (format) {
4
6
  case 'none':
@@ -6,7 +8,7 @@ export function createTimestampFormatter(format) {
6
8
  case 'iso':
7
9
  return (timestamp) => timestamp.toISOString();
8
10
  case 'elapsed': {
9
- let lastTick = undefined;
11
+ let lastTick;
10
12
  return (timestamp) => {
11
13
  const newTick = timestamp.getTime();
12
14
  const result = ms(lastTick === undefined ? 0 : newTick - lastTick);
@@ -16,4 +18,10 @@ export function createTimestampFormatter(format) {
16
18
  }
17
19
  }
18
20
  }
19
- //# sourceMappingURL=createTimestampFormatter.js.map
21
+ export function formatLogLevel(level) {
22
+ return `(${upperCase(toLogLevelName(level))})`;
23
+ }
24
+ export function plainLogFormatter({ id, level, args, timestamp }) {
25
+ return [timestamp.toISOString(), id, formatLogLevel(level), ...args];
26
+ }
27
+ //# sourceMappingURL=formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAK/C,MAAM,UAAU,wBAAwB,CAAC,MAAuB;IAC9D,QAAQ,MAAM,EAAE;QACd,KAAK,MAAM;YACT,OAAO,CAAC,UAAgB,EAAE,EAAE,CAAC,SAAS,CAAA;QACxC,KAAK,KAAK;YACR,OAAO,CAAC,SAAe,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,CAAA;QACrD,KAAK,SAAS,CAAC,CAAC;YACd,IAAI,QAAgB,CAAA;YACpB,OAAO,CAAC,SAAe,EAAE,EAAE;gBACzB,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,EAAE,CAAA;gBACnC,MAAM,MAAM,GAAG,EAAE,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAA;gBAClE,QAAQ,GAAG,OAAO,CAAA;gBAClB,OAAO,MAAM,CAAA;YACf,CAAC,CAAA;SACF;KACF;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,IAAI,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,GAAG,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAY;IACxE,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAA;AACtE,CAAC","sourcesContent":["import ms from 'ms'\nimport { upperCase } from 'upper-case'\nimport { toLogLevelName } from './logLevels.js'\nimport type { LogEntry } from './types.js'\n\nexport type TimestampFormat = 'none' | 'iso' | 'elapsed'\n\nexport function createTimestampFormatter(format: TimestampFormat) {\n switch (format) {\n case 'none':\n return (_timestamp: Date) => undefined\n case 'iso':\n return (timestamp: Date) => timestamp.toISOString()\n case 'elapsed': {\n let lastTick: number\n return (timestamp: Date) => {\n const newTick = timestamp.getTime()\n const result = ms(lastTick === undefined ? 0 : newTick - lastTick)\n lastTick = newTick\n return result\n }\n }\n }\n}\n\nexport function formatLogLevel(level: number) {\n return `(${upperCase(toLogLevelName(level))})`\n}\n\nexport function plainLogFormatter({ id, level, args, timestamp }: LogEntry) {\n return [timestamp.toISOString(), id, formatLogLevel(level), ...args]\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=formatter.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.spec.d.ts","sourceRoot":"","sources":["../ts/formatter.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import { createTimestampFormatter, logLevels, plainLogFormatter } from './index.js';
2
+ describe('plainLogFormatter()', () => {
3
+ it('convert log entries to string', () => {
4
+ const timestamp = new Date(2019, 6);
5
+ const actual = plainLogFormatter({ id: 'plain', level: logLevels.emergency, args: ['emergency'], timestamp });
6
+ expect(actual).toEqual([timestamp.toISOString(), 'plain', `(EMERGENCY)`, `emergency`]);
7
+ });
8
+ });
9
+ describe('createTimestampFormatter()', () => {
10
+ test('none', () => {
11
+ const formatter = createTimestampFormatter('none');
12
+ const now = new Date();
13
+ const actual = [formatter(now)];
14
+ expect(actual).toEqual([undefined]);
15
+ });
16
+ test('iso', () => {
17
+ const formatter = createTimestampFormatter('iso');
18
+ const now = new Date();
19
+ const actual = [formatter(now)];
20
+ expect(actual).toEqual([now.toISOString()]);
21
+ });
22
+ test('elapsed', () => {
23
+ const formatter = createTimestampFormatter('elapsed');
24
+ const now = new Date();
25
+ const next = new Date(now.getTime() + 10);
26
+ const actual = [formatter(now), formatter(next)];
27
+ expect(actual).toEqual(['0ms', '10ms']);
28
+ });
29
+ });
30
+ //# sourceMappingURL=formatter.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.spec.js","sourceRoot":"","sources":["../ts/formatter.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnF,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;QACnC,MAAM,MAAM,GAAG,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,GAAG,EAAE,CAAC,CAAA;QACzC,MAAM,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;QAEhD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { createTimestampFormatter, logLevels, plainLogFormatter } from './index.js'\n\ndescribe('plainLogFormatter()', () => {\n it('convert log entries to string', () => {\n const timestamp = new Date(2019, 6)\n const actual = plainLogFormatter({ id: 'plain', level: logLevels.emergency, args: ['emergency'], timestamp })\n\n expect(actual).toEqual([timestamp.toISOString(), 'plain', `(EMERGENCY)`, `emergency`])\n })\n})\n\ndescribe('createTimestampFormatter()', () => {\n test('none', () => {\n const formatter = createTimestampFormatter('none')\n const now = new Date()\n const actual = [formatter(now)]\n expect(actual).toEqual([undefined])\n })\n\n test('iso', () => {\n const formatter = createTimestampFormatter('iso')\n const now = new Date()\n const actual = [formatter(now)]\n expect(actual).toEqual([now.toISOString()])\n })\n\n test('elapsed', () => {\n const formatter = createTimestampFormatter('elapsed')\n const now = new Date()\n const next = new Date(now.getTime() + 10)\n const actual = [formatter(now), formatter(next)]\n\n expect(actual).toEqual(['0ms', '10ms'])\n })\n})\n"]}
package/esm/index.d.ts CHANGED
@@ -1,17 +1,8 @@
1
- export * from './captureLogs.js';
2
- export * from './config.js';
3
- export * from './configForTest.js';
4
- export * from './console/index.js';
5
- export * from './customLogLevel.js';
1
+ export * from './console.js';
6
2
  export * from './errors.js';
7
- export * from './formatter/index.js';
8
- export * from './getLogger.js';
9
- export * from './logLevel.js';
10
- export * from './logLevelFn.js';
11
- export * from './logReporter.js';
12
- export * from './memory/index.js';
13
- export * from './shouldLog.js';
14
- export * from './suppressLogs.js';
3
+ export * from './formatter.js';
4
+ export * from './logLevels.js';
5
+ export * from './memory.js';
6
+ export * from './standardLog.js';
15
7
  export * from './types.js';
16
- export * from './utils.js';
17
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA"}
package/esm/index.js CHANGED
@@ -1,17 +1,8 @@
1
- export * from './captureLogs.js';
2
- export * from './config.js';
3
- export * from './configForTest.js';
4
- export * from './console/index.js';
5
- export * from './customLogLevel.js';
1
+ export * from './console.js';
6
2
  export * from './errors.js';
7
- export * from './formatter/index.js';
8
- export * from './getLogger.js';
9
- export * from './logLevel.js';
10
- export * from './logLevelFn.js';
11
- export * from './logReporter.js';
12
- export * from './memory/index.js';
13
- export * from './shouldLog.js';
14
- export * from './suppressLogs.js';
3
+ export * from './formatter.js';
4
+ export * from './logLevels.js';
5
+ export * from './memory.js';
6
+ export * from './standardLog.js';
15
7
  export * from './types.js';
16
- export * from './utils.js';
17
8
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA","sourcesContent":["export * from './captureLogs.js'\nexport * from './config.js'\nexport * from './configForTest.js'\nexport * from './console/index.js'\nexport * from './customLogLevel.js'\nexport * from './errors.js'\nexport * from './formatter/index.js'\nexport * from './getLogger.js'\nexport * from './logLevel.js'\nexport * from './logLevelFn.js'\nexport * from './logReporter.js'\nexport * from './memory/index.js'\nexport * from './shouldLog.js'\nexport * from './suppressLogs.js'\nexport * from './types.js'\nexport * from './utils.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA","sourcesContent":["export * from './console.js'\nexport * from './errors.js'\nexport * from './formatter.js'\nexport * from './logLevels.js'\nexport * from './memory.js'\nexport * from './standardLog.js'\nexport * from './types.js'\n"]}
@@ -0,0 +1,60 @@
1
+ export declare const logLevels: {
2
+ /**
3
+ * none: 0
4
+ */
5
+ none: number;
6
+ /**
7
+ * emergency: 100
8
+ */
9
+ emergency: number;
10
+ /**
11
+ * alert: 200
12
+ */
13
+ alert: number;
14
+ /**
15
+ * critical: 300
16
+ */
17
+ critical: number;
18
+ /**
19
+ * error: 400
20
+ */
21
+ error: number;
22
+ /**
23
+ * warn: 500
24
+ */
25
+ warn: number;
26
+ /**
27
+ * notice: 600
28
+ */
29
+ notice: number;
30
+ /**
31
+ * info: 700
32
+ */
33
+ info: number;
34
+ /**
35
+ * debug: 800
36
+ */
37
+ debug: number;
38
+ /**
39
+ * trace: 900
40
+ */
41
+ trace: number;
42
+ /**
43
+ * planck: Infinity
44
+ * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.
45
+ */
46
+ planck: number;
47
+ /**
48
+ * all: Infinity
49
+ */
50
+ all: number;
51
+ };
52
+ /**
53
+ * Convert default log level value to log level name.
54
+ */
55
+ export declare function toLogLevelName(level: number): "emergency" | "alert" | "critical" | "error" | "warn" | "notice" | "info" | "debug" | "trace" | "planck";
56
+ /**
57
+ * Convert default log level name to log level value.
58
+ */
59
+ export declare function toLogLevel(name: string): any;
60
+ //# sourceMappingURL=logLevels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logLevels.d.ts","sourceRoot":"","sources":["../ts/logLevels.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;IACpB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;CAEJ,CAAA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,4GAW3C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,OAEtC"}
@@ -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: 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,kBAAkB,GAAG,QAAQ,CAOpE;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