@visulima/pail 1.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.
- package/CHANGELOG.md +53 -0
- package/LICENSE.md +21 -0
- package/README.md +420 -0
- package/dist/abstract-pretty-reporter-dDQbeuZX.d.cts +37 -0
- package/dist/abstract-pretty-reporter-doXJ0wsq.d.ts +37 -0
- package/dist/chunk-32FAOPTJ.cjs +10 -0
- package/dist/chunk-32FAOPTJ.cjs.map +1 -0
- package/dist/chunk-46NTLZF7.cjs +10 -0
- package/dist/chunk-46NTLZF7.cjs.map +1 -0
- package/dist/chunk-4RK45K5E.cjs +7 -0
- package/dist/chunk-4RK45K5E.cjs.map +1 -0
- package/dist/chunk-57OYT2NC.js +7 -0
- package/dist/chunk-57OYT2NC.js.map +1 -0
- package/dist/chunk-6ATEEAVC.cjs +9 -0
- package/dist/chunk-6ATEEAVC.cjs.map +1 -0
- package/dist/chunk-7OFJLC7L.cjs +7 -0
- package/dist/chunk-7OFJLC7L.cjs.map +1 -0
- package/dist/chunk-EBP7SMYV.js +5 -0
- package/dist/chunk-EBP7SMYV.js.map +1 -0
- package/dist/chunk-FJCEDFRI.js +9 -0
- package/dist/chunk-FJCEDFRI.js.map +1 -0
- package/dist/chunk-G62M5WJH.js +8 -0
- package/dist/chunk-G62M5WJH.js.map +1 -0
- package/dist/chunk-GZRIZCRG.cjs +32 -0
- package/dist/chunk-GZRIZCRG.cjs.map +1 -0
- package/dist/chunk-HKIS52YX.js +22 -0
- package/dist/chunk-HKIS52YX.js.map +1 -0
- package/dist/chunk-ICPHL4AR.js +8 -0
- package/dist/chunk-ICPHL4AR.js.map +1 -0
- package/dist/chunk-IQF3SXQR.cjs +10 -0
- package/dist/chunk-IQF3SXQR.cjs.map +1 -0
- package/dist/chunk-JYHWIRFR.js +5 -0
- package/dist/chunk-JYHWIRFR.js.map +1 -0
- package/dist/chunk-MU2CRXVO.cjs +9 -0
- package/dist/chunk-MU2CRXVO.cjs.map +1 -0
- package/dist/chunk-PVAYQO5O.js +5 -0
- package/dist/chunk-PVAYQO5O.js.map +1 -0
- package/dist/chunk-Y36365SA.cjs +13 -0
- package/dist/chunk-Y36365SA.cjs.map +1 -0
- package/dist/chunk-YKHMQW6V.js +5 -0
- package/dist/chunk-YKHMQW6V.js.map +1 -0
- package/dist/index.browser.cjs +16 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.d.cts +11 -0
- package/dist/index.browser.d.ts +11 -0
- package/dist/index.browser.js +13 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.server.cjs +28 -0
- package/dist/index.server.cjs.map +1 -0
- package/dist/index.server.d.cts +31 -0
- package/dist/index.server.d.ts +31 -0
- package/dist/index.server.js +20 -0
- package/dist/index.server.js.map +1 -0
- package/dist/pail.browser-DH-2bBhK.d.ts +59 -0
- package/dist/pail.browser-eQgV1vak.d.cts +59 -0
- package/dist/processor.browser.cjs +13 -0
- package/dist/processor.browser.cjs.map +1 -0
- package/dist/processor.browser.d.cts +16 -0
- package/dist/processor.browser.d.ts +16 -0
- package/dist/processor.browser.js +4 -0
- package/dist/processor.browser.js.map +1 -0
- package/dist/processor.server.cjs +14 -0
- package/dist/processor.server.cjs.map +1 -0
- package/dist/processor.server.d.cts +22 -0
- package/dist/processor.server.d.ts +22 -0
- package/dist/processor.server.js +8 -0
- package/dist/processor.server.js.map +1 -0
- package/dist/reporter.browser.cjs +28 -0
- package/dist/reporter.browser.cjs.map +1 -0
- package/dist/reporter.browser.d.cts +18 -0
- package/dist/reporter.browser.d.ts +18 -0
- package/dist/reporter.browser.js +18 -0
- package/dist/reporter.browser.js.map +1 -0
- package/dist/reporter.server.cjs +27 -0
- package/dist/reporter.server.cjs.map +1 -0
- package/dist/reporter.server.d.cts +58 -0
- package/dist/reporter.server.d.ts +58 -0
- package/dist/reporter.server.js +16 -0
- package/dist/reporter.server.js.map +1 -0
- package/dist/types.d-RNxsa9NR.d.cts +155 -0
- package/dist/types.d-RNxsa9NR.d.ts +155 -0
- package/package.json +256 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
## @visulima/pail 1.0.0 (2024-02-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* added all tests to the is-ansi-color-supported, updated deps ([6639e75](https://github.com/visulima/visulima/commit/6639e75ab45fe4dfc0338b9f5b2527354e3cb36e))
|
|
7
|
+
* added correct badge display, adding new docs ([5c7ff29](https://github.com/visulima/visulima/commit/5c7ff297f7cebddaec6472ae8709036f93d3e6cf))
|
|
8
|
+
* added count and countReset, fixed time, timeLog and timeEnd ([bef8926](https://github.com/visulima/visulima/commit/bef8926b1813394f36cbaec0fe2b076d514fb2d3))
|
|
9
|
+
* added header images ([21e8d5a](https://github.com/visulima/visulima/commit/21e8d5a5e9fec47e7a3362e0f76d8e6840d02fc9))
|
|
10
|
+
* added more docs ([ec33d26](https://github.com/visulima/visulima/commit/ec33d268a66fd62d2e1841bc235a7734d736e581))
|
|
11
|
+
* added new color pacakge ([ca23c3d](https://github.com/visulima/visulima/commit/ca23c3d8582b0c0eb77870f57394696f587e72c4))
|
|
12
|
+
* added new interactive manager, fixed tests, fixed styling, and more ([e7359d3](https://github.com/visulima/visulima/commit/e7359d379f2e4b6f8d8953448055fcfa613fc41e))
|
|
13
|
+
* added tests ([e30de63](https://github.com/visulima/visulima/commit/e30de63aa522490914b8bd627e2d7b0185b9b3b6))
|
|
14
|
+
* added time, timeLog and timeEnd, better design for browser console, some fixes ([737378a](https://github.com/visulima/visulima/commit/737378a1f16d9d113dcee09ae5c129b15d9de46f))
|
|
15
|
+
* adding interactive mode ([a88ccb4](https://github.com/visulima/visulima/commit/a88ccb453375eeae9f7bdbb84b67151da1a3d875))
|
|
16
|
+
* adding new raw reporter and raw function to pail ([#320](https://github.com/visulima/visulima/issues/320)) ([e6cf56f](https://github.com/visulima/visulima/commit/e6cf56ffc98213f8631b25ad09775d65c109cc5f))
|
|
17
|
+
* fixed some design issues between server and browser, added trace ([57a34b6](https://github.com/visulima/visulima/commit/57a34b6aa2cac4ff7bad85ec52f9d3a64958e8fe))
|
|
18
|
+
* improvement ([1964590](https://github.com/visulima/visulima/commit/1964590e2699adb3c5d1e6856f177fa5269885c4))
|
|
19
|
+
* more work ([3d41672](https://github.com/visulima/visulima/commit/3d4167217305c293128853bc8ece457d899973c4))
|
|
20
|
+
* more work ([435ca60](https://github.com/visulima/visulima/commit/435ca608587932aab8cb66d0c7c4fdb81bc9aeb0))
|
|
21
|
+
* more work on the logger ([01f2f94](https://github.com/visulima/visulima/commit/01f2f9452d938c0a8bcda7ab217e4d5c2ca2495a))
|
|
22
|
+
* more work on the logger ([3b8b1f0](https://github.com/visulima/visulima/commit/3b8b1f0dab65a0b6e882f8786fa820e5e57460c3))
|
|
23
|
+
* more work on the logger ([93b658b](https://github.com/visulima/visulima/commit/93b658b9704f3ce4b3a734eed97efd677ce028f5))
|
|
24
|
+
* more work on the logger ([95e5f2a](https://github.com/visulima/visulima/commit/95e5f2a0ed77700c3ff574e28485f9e6440bfe5e))
|
|
25
|
+
* more work on the logger ([93a9d4c](https://github.com/visulima/visulima/commit/93a9d4c1cb07de4a827dade9e37ff31d9bf1e330))
|
|
26
|
+
* new color and support color package ([c580e05](https://github.com/visulima/visulima/commit/c580e05aaf516e4ecb939bcb39dcc5305ee17aed))
|
|
27
|
+
* new console interface func, fixed some eslint errors ([84917bd](https://github.com/visulima/visulima/commit/84917bdd14312716038ff390907cf53cfbffec4f))
|
|
28
|
+
* removed child handling ([39abe92](https://github.com/visulima/visulima/commit/39abe922ca57fd09dce6b4e13e0f03824e3da2e0))
|
|
29
|
+
* removed some deps ([bd6150a](https://github.com/visulima/visulima/commit/bd6150a69f1d7fc5693ab7d540b3548d2aca1307))
|
|
30
|
+
* speed up pail ([2caab01](https://github.com/visulima/visulima/commit/2caab01fb5052990905b18dfb623bbbd8222ee99))
|
|
31
|
+
* split pail into browser class and server class ([23dbcd6](https://github.com/visulima/visulima/commit/23dbcd692efa52b40e75f8b06de31cd4986348a5))
|
|
32
|
+
* updated readme ([69278b3](https://github.com/visulima/visulima/commit/69278b3b9745912508d2c195ac37be101d9b1968))
|
|
33
|
+
* updated readme ([faa6425](https://github.com/visulima/visulima/commit/faa6425ae9808740f3b29c61419d3ae2d773534a))
|
|
34
|
+
* updated readme ([10adfed](https://github.com/visulima/visulima/commit/10adfed8dae983c2613d98ce4cf274dc841be42e))
|
|
35
|
+
* updated string template to normale strings ([a796e0f](https://github.com/visulima/visulima/commit/a796e0f6766854d29bd4c77ce714b117e0d3f33c))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Bug Fixes
|
|
39
|
+
|
|
40
|
+
* added missing exports ([0d0ad93](https://github.com/visulima/visulima/commit/0d0ad9388017c562679f56d51a226b5d1eb86936))
|
|
41
|
+
* fixed build step ([a882a13](https://github.com/visulima/visulima/commit/a882a13e5041aed9dc3ce37e5f97b628b2501622))
|
|
42
|
+
* fixed cjs export, fixed eslint errors ([d401258](https://github.com/visulima/visulima/commit/d4012587828d78680e6f1a1370720d5a3660d094))
|
|
43
|
+
* fixed fmt handling ([a0b2352](https://github.com/visulima/visulima/commit/a0b23525935c68ea270803b2d907d87187f2eb0b))
|
|
44
|
+
* fixed found issues ([858bc32](https://github.com/visulima/visulima/commit/858bc3257d24b2159df801dcde948d4fcfc495b1))
|
|
45
|
+
* fixed package.json exports ([685b636](https://github.com/visulima/visulima/commit/685b636b471712e3888db645f1897e6bc7710f7c))
|
|
46
|
+
* fixed test ([c1b56f6](https://github.com/visulima/visulima/commit/c1b56f6202c8ec5ab9f1b4f9c44e4aa5fc0f71c5))
|
|
47
|
+
* fixed tests ([a3df0e2](https://github.com/visulima/visulima/commit/a3df0e2ec27314e4419d224a740dff93e121a19a))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Dependencies
|
|
52
|
+
|
|
53
|
+
* **@visulima/colorize:** upgraded to 1.2.2
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 visulima
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h3>Visulima Pail</h3>
|
|
3
|
+
<p>
|
|
4
|
+
Highly configurable Logger for Node.js, Edge and Browser, built on top of
|
|
5
|
+
|
|
6
|
+
[@visulima/fmt][fmt],
|
|
7
|
+
[@visulima/colorize](https://github.com/visulima/visulima/tree/main/packages/colorize),
|
|
8
|
+
[ansi-escapes](https://www.npmjs.com/package/ansi-escapes),
|
|
9
|
+
[safe-stable-stringify](https://www.npmjs.com/package/safe-stable-stringify),
|
|
10
|
+
[string-length](https://www.npmjs.com/package/string-length),
|
|
11
|
+
[terminal-size](https://www.npmjs.com/package/terminal-size) and
|
|
12
|
+
[wrap-ansi](https://www.npmjs.com/package/wrap-ansi)
|
|
13
|
+
|
|
14
|
+
</p>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<br />
|
|
18
|
+
|
|
19
|
+
<div align="center">
|
|
20
|
+
|
|
21
|
+
[![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
|
|
22
|
+
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<div align="center">
|
|
28
|
+
<p>
|
|
29
|
+
<sup>
|
|
30
|
+
Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
|
|
31
|
+
</sup>
|
|
32
|
+
</p>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Why Pail?
|
|
38
|
+
|
|
39
|
+
- Easy to use
|
|
40
|
+
- Hackable to the core
|
|
41
|
+
- Integrated timers
|
|
42
|
+
- Custom pluggable processors and reporters
|
|
43
|
+
- TypeScript support
|
|
44
|
+
- Interactive and regular modes
|
|
45
|
+
- Secrets & sensitive information filtering (soon)
|
|
46
|
+
- Filename, date and timestamp support
|
|
47
|
+
- Scoped loggers and timers
|
|
48
|
+
- Scaled logging levels mechanism
|
|
49
|
+
- String interpolation support
|
|
50
|
+
- Object and error interpolation
|
|
51
|
+
- Stack trace and pretty errors
|
|
52
|
+
- Simple and minimal syntax
|
|
53
|
+
- Spam prevention by throttling logs
|
|
54
|
+
- [Browser](./__assets__/header-browser.png) and [Server](./__assets__/header-server.png) support
|
|
55
|
+
- Redirect console and stdout/stderr to pail and easily restore redirect.
|
|
56
|
+
- `Pretty` or `JSON` output
|
|
57
|
+
- CJS & ESM with tree shaking support
|
|
58
|
+
- Supports circular structures
|
|
59
|
+
- Fast and powerful, see the [benchmarks](__bench__/README.md)
|
|
60
|
+
|
|
61
|
+
## Install
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npm install @visulima/pail
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
yarn add @visulima/pail
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
pnpm add @visulima/pail
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Concepts
|
|
76
|
+
|
|
77
|
+
> Most importantly, `pail` adheres to the log levels defined in [RFC 5424][rfc-5424] extended with `trace` level.
|
|
78
|
+
> This means that you can use the log levels to filter out messages that are not important to you.
|
|
79
|
+
|
|
80
|
+
### Log Levels
|
|
81
|
+
|
|
82
|
+
Pail supports the logging levels described by [RFC 5424][rfc-5424].
|
|
83
|
+
|
|
84
|
+
- `DEBUG`: Detailed debug information.
|
|
85
|
+
|
|
86
|
+
- `INFO`: Interesting events. Examples: User logs in, SQL logs.
|
|
87
|
+
|
|
88
|
+
- `NOTICE`: Normal but significant events.
|
|
89
|
+
|
|
90
|
+
- `TRACE`: Very detailed and fine-grained informational events.
|
|
91
|
+
|
|
92
|
+
- `WARNING`: Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
|
|
93
|
+
|
|
94
|
+
- `ERROR`: Runtime errors that do not require immediate action but should typically be logged and monitored.
|
|
95
|
+
|
|
96
|
+
- `CRITICAL`: Critical conditions. Example: Application component unavailable, unexpected exception.
|
|
97
|
+
|
|
98
|
+
- `ALERT`: Action must be taken immediately. Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
|
|
99
|
+
|
|
100
|
+
- `EMERGENCY`: Emergency: system is unusable.
|
|
101
|
+
|
|
102
|
+
### Reporters
|
|
103
|
+
|
|
104
|
+
Reporters are responsible for writing the log messages to the console or a file. `pail` comes with a few built-in reporters:
|
|
105
|
+
|
|
106
|
+
| Browser (console.{function}) | Server (stdout or stderr) |
|
|
107
|
+
| ---------------------------- | ------------------------- |
|
|
108
|
+
| `JsonReporter` | `JsonReporter` |
|
|
109
|
+
| `PrettyReporter` | `PrettyReporter` |
|
|
110
|
+
| x | `FileReporter` |
|
|
111
|
+
|
|
112
|
+
### Processors
|
|
113
|
+
|
|
114
|
+
Processors are responsible for processing the log message (Meta Object) before it's written to the console or a file.
|
|
115
|
+
This usually means that they add some metadata to the record's `context` property.
|
|
116
|
+
|
|
117
|
+
A processor can be added to a logger directly (and is subsequently applied to log records before they reach any handler).
|
|
118
|
+
|
|
119
|
+
`pail` comes with a few built-in processors:
|
|
120
|
+
|
|
121
|
+
- `CallerProcessor` - adds the caller information to the log message
|
|
122
|
+
- The Meta Object is extended with a file name, line number and column number
|
|
123
|
+
- `RedactProcessor` - redacts sensitive information from the log message (Soon)
|
|
124
|
+
- `MessageFormatterProcessor` - formats the log message (Util.format-like unescaped string formatting utility) [@visulima/fmt][fmt]
|
|
125
|
+
- `ErrorProcessor` - serializes the error with cause object to a std error object that can be serialized.
|
|
126
|
+
|
|
127
|
+
## Usage
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { pail } from "@visulima/pail";
|
|
131
|
+
|
|
132
|
+
pail.success("Operation successful");
|
|
133
|
+
pail.debug("Hello", "from", "L59");
|
|
134
|
+
pail.pending("Write release notes for %s", "1.2.0");
|
|
135
|
+
pail.fatal(new Error("Unable to acquire lock"));
|
|
136
|
+
pail.watch("Recursively watching build directory...");
|
|
137
|
+
pail.complete({
|
|
138
|
+
prefix: "[task]",
|
|
139
|
+
message: "Fix issue #59",
|
|
140
|
+
suffix: "(@prisis)",
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+

|
|
145
|
+
|
|
146
|
+
### Custom Loggers
|
|
147
|
+
|
|
148
|
+
To create a custom logger define an `options` object yielding a types field with the logger data and pass it as argument to the createPail function.
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { createPail } from "@visulima/pail";
|
|
152
|
+
|
|
153
|
+
const custom = createPail({
|
|
154
|
+
types: {
|
|
155
|
+
remind: {
|
|
156
|
+
badge: "**",
|
|
157
|
+
color: "yellow",
|
|
158
|
+
label: "reminder",
|
|
159
|
+
logLevel: "info",
|
|
160
|
+
},
|
|
161
|
+
santa: {
|
|
162
|
+
badge: "🎅",
|
|
163
|
+
color: "red",
|
|
164
|
+
label: "santa",
|
|
165
|
+
logLevel: "info",
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
custom.remind("Improve documentation.");
|
|
171
|
+
custom.santa("Hoho! You have an unused variable on L45.");
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+

|
|
175
|
+
|
|
176
|
+
Here is an example where we override the default `error` and `success` loggers.
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { pail, createPail } from "@visulima/pail";
|
|
180
|
+
|
|
181
|
+
pail.error("Default Error Log");
|
|
182
|
+
pail.success("Default Success Log");
|
|
183
|
+
|
|
184
|
+
const custom = createPail({
|
|
185
|
+
scope: "custom",
|
|
186
|
+
types: {
|
|
187
|
+
error: {
|
|
188
|
+
badge: "!!",
|
|
189
|
+
label: "fatal error",
|
|
190
|
+
},
|
|
191
|
+
success: {
|
|
192
|
+
badge: "++",
|
|
193
|
+
label: "huge success",
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
custom.error("Custom Error Log");
|
|
199
|
+
custom.success("Custom Success Log");
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+

|
|
203
|
+
|
|
204
|
+
## Scoped Loggers
|
|
205
|
+
|
|
206
|
+
To create a scoped logger from scratch, define the `scope` field inside the options object and pass it as argument to the createPail function.
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
import { createPail } from "@visulima/pail";
|
|
210
|
+
|
|
211
|
+
const mayAppLogger = createPail({
|
|
212
|
+
scope: "my-app",
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
mayAppLogger.info("Hello from my app");
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+

|
|
219
|
+
|
|
220
|
+
To create a scoped logger based on an already existing one, use the `scope()` function, which will return a new pail instance, inheriting all custom loggers, timers, secrets, streams, configuration, log level, interactive mode & disabled statuses from the initial one.
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
import { pail } from "@visulima/pail";
|
|
224
|
+
|
|
225
|
+
const global = pail.scope("global scope");
|
|
226
|
+
|
|
227
|
+
global.success("Hello from the global scope");
|
|
228
|
+
|
|
229
|
+
function foo() {
|
|
230
|
+
const outer = global.scope("outer", "scope");
|
|
231
|
+
outer.success("Hello from the outer scope");
|
|
232
|
+
|
|
233
|
+
setTimeout(() => {
|
|
234
|
+
const inner = outer.scope("inner", "scope");
|
|
235
|
+
inner.success("Hello from the inner scope");
|
|
236
|
+
}, 500);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
foo();
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+

|
|
243
|
+
|
|
244
|
+
## Interactive Loggers (Only on if stdout and stderr is a TTY)
|
|
245
|
+
|
|
246
|
+
To initialize an interactive logger, create a new pail instance with the `interactive` attribute set to `true`.
|
|
247
|
+
While into the interactive mode, previously logged messages originating from an interactive logger, will be overridden only by new ones originating from the same or a different interactive logger.
|
|
248
|
+
Note that regular messages originating from regular loggers are not overridden by the interactive ones.
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import { createPail } from "@visulima/pail";
|
|
252
|
+
|
|
253
|
+
console.log("\n");
|
|
254
|
+
|
|
255
|
+
const pail = createPail();
|
|
256
|
+
|
|
257
|
+
const interactive = createPail({ interactive: true });
|
|
258
|
+
|
|
259
|
+
pail.info("This is a log message 1");
|
|
260
|
+
|
|
261
|
+
setTimeout(() => {
|
|
262
|
+
interactive.await("[%d/4] - Process A", 1);
|
|
263
|
+
setTimeout(() => {
|
|
264
|
+
interactive.success("[%d/4] - Process A", 2);
|
|
265
|
+
setTimeout(() => {
|
|
266
|
+
interactive.await("[%d/4] - Process B", 3);
|
|
267
|
+
setTimeout(() => {
|
|
268
|
+
interactive.error("[%d/4] - Process B", 4);
|
|
269
|
+
}, 1000);
|
|
270
|
+
}, 1000);
|
|
271
|
+
}, 1000);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
pail.info("This is a log message 2");
|
|
275
|
+
pail.info("This is a log message 3");
|
|
276
|
+
pail.info("This is a log message 4");
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
For a more complex example, use can use the `getInteractiveManager` function, see the following code:
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
import { createPail } from "@visulima/pail";
|
|
283
|
+
|
|
284
|
+
const interactive = createPail({ interactive: true });
|
|
285
|
+
|
|
286
|
+
const TICKS = 60;
|
|
287
|
+
const TIMEOUT = 80;
|
|
288
|
+
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
289
|
+
const messages = ["Swapping time and space...", "Have a good day.", "Don't panic...", "Updating Updater...", "42"];
|
|
290
|
+
let ticks = TICKS;
|
|
291
|
+
let i = 0;
|
|
292
|
+
|
|
293
|
+
const interactiveManager = interactive.getInteractiveManager();
|
|
294
|
+
|
|
295
|
+
interactiveManager.hook();
|
|
296
|
+
|
|
297
|
+
// eslint-disable-next-line no-console
|
|
298
|
+
console.log(" - log message");
|
|
299
|
+
// eslint-disable-next-line no-console
|
|
300
|
+
console.error(" - error message");
|
|
301
|
+
// eslint-disable-next-line no-console
|
|
302
|
+
console.warn(" - warn message");
|
|
303
|
+
|
|
304
|
+
const id = setInterval(() => {
|
|
305
|
+
if (--ticks < 0) {
|
|
306
|
+
clearInterval(id);
|
|
307
|
+
|
|
308
|
+
interactiveManager.update(["✔ Success", "", "Messages:", "this line will be deleted!!!"]);
|
|
309
|
+
interactiveManager.erase(1);
|
|
310
|
+
interactiveManager.unhook(false);
|
|
311
|
+
} else {
|
|
312
|
+
const frame = frames[(i = ++i % frames.length)];
|
|
313
|
+
const index = Math.round(ticks / 10) % messages.length;
|
|
314
|
+
const message = messages[index];
|
|
315
|
+
|
|
316
|
+
if (message) {
|
|
317
|
+
interactiveManager.update([`${frame} Some process...`, message]);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}, TIMEOUT);
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Timers
|
|
324
|
+
|
|
325
|
+
Timer are managed by the `time()`, `timeLog()` and `timeEnd()` functions.
|
|
326
|
+
A unique label can be used to identify a timer on initialization, though if none is provided the timer will be assigned one automatically.
|
|
327
|
+
In addition, calling the `timeEnd()` function without a specified label will have as effect the termination of the most recently initialized timer, that was created without providing a label.
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
import { pail } from "@visulima/pail";
|
|
331
|
+
|
|
332
|
+
pail.time("test");
|
|
333
|
+
pail.time();
|
|
334
|
+
pail.timeLog("default", "Hello");
|
|
335
|
+
|
|
336
|
+
setTimeout(() => {
|
|
337
|
+
pail.timeEnd();
|
|
338
|
+
pail.timeEnd("test");
|
|
339
|
+
}, 500);
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+

|
|
343
|
+
|
|
344
|
+
Its also possible to change the text inside `time()` and `timeEnd()` by using the options object.
|
|
345
|
+
|
|
346
|
+
```typescript
|
|
347
|
+
import { createPail } from "@visulima/pail";
|
|
348
|
+
|
|
349
|
+
const pail = createPail({
|
|
350
|
+
messages: {
|
|
351
|
+
timerStart: "Start Timer:",
|
|
352
|
+
timerEnd: "End Timer:",
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
pail.time("test");
|
|
357
|
+
pail.timeEnd("test");
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## Disable and Enable Loggers
|
|
361
|
+
|
|
362
|
+
To disable a logger, use the `disable()` function, which will prevent any log messages from being written to the console or a file.
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
365
|
+
import { pail } from "@visulima/pail";
|
|
366
|
+
|
|
367
|
+
pail.disable();
|
|
368
|
+
pail.success("This message will not be logged");
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
To enable a logger, use the `enable()` function, which will allow log messages to be written to the console or a file.
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
import { pail } from "@visulima/pail";
|
|
375
|
+
|
|
376
|
+
pail.disable();
|
|
377
|
+
pail.success("This message will not be logged");
|
|
378
|
+
pail.enable();
|
|
379
|
+
pail.success("This message will be logged");
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## Api
|
|
383
|
+
|
|
384
|
+
## Supported Node.js Versions
|
|
385
|
+
|
|
386
|
+
Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
|
|
387
|
+
Here’s [a post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
|
|
388
|
+
|
|
389
|
+
## Contributing
|
|
390
|
+
|
|
391
|
+
If you would like to help take a look at the [list of issues](https://github.com/visulima/visulima/issues) and check our [Contributing](.github/CONTRIBUTING.md) guild.
|
|
392
|
+
|
|
393
|
+
> **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
|
|
394
|
+
|
|
395
|
+
## Credits
|
|
396
|
+
|
|
397
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
398
|
+
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
399
|
+
|
|
400
|
+
## About
|
|
401
|
+
|
|
402
|
+
### Related Projects
|
|
403
|
+
|
|
404
|
+
- [pino](https://github.com/pinojs/pino) - 🌲 super fast, all natural json logger
|
|
405
|
+
- [winston](https://github.com/winstonjs/winston) - A logger for just about everything.
|
|
406
|
+
- [signale](https://github.com/klaudiosinani/signale) - Highly configurable logging utility
|
|
407
|
+
- [consola](https://github.com/unjs/consola) - 🐨 Elegant Console Logger for Node.js and Browser
|
|
408
|
+
|
|
409
|
+
## License
|
|
410
|
+
|
|
411
|
+
The visulima pail is open-sourced software licensed under the [MIT][license-url]
|
|
412
|
+
|
|
413
|
+
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
414
|
+
[typescript-url]: "typescript"
|
|
415
|
+
[license-image]: https://img.shields.io/npm/l/@visulima/pail?color=blueviolet&style=for-the-badge
|
|
416
|
+
[license-url]: LICENSE.md "license"
|
|
417
|
+
[npm-image]: https://img.shields.io/npm/v/@visulima/pail/latest.svg?style=for-the-badge&logo=npm
|
|
418
|
+
[npm-url]: https://www.npmjs.com/package/@visulima/pail/v/latest "npm"
|
|
419
|
+
[rfc-5424]: https://datatracker.ietf.org/doc/html/rfc5424#page-36
|
|
420
|
+
[fmt]: https://github.com/visulima/visulima/tree/main/packages/fmt
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { stringify } from 'safe-stable-stringify';
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
|
+
import { g as StringifyAwareReporter, f as ReadonlyMeta, E as ExtendedRfc5424LogLevels, c as LoggerTypesAwareReporter, d as LoggerTypesConfig, a as DefaultLogTypes } from './types.d-RNxsa9NR.cjs';
|
|
4
|
+
|
|
5
|
+
declare abstract class AbstractJsonReporter<L extends string = never> implements StringifyAwareReporter<L> {
|
|
6
|
+
protected _stringify: typeof stringify | undefined;
|
|
7
|
+
setStringify(function_: any): void;
|
|
8
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
9
|
+
protected abstract _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare abstract class AbstractPrettyReporter<T extends string = never, L extends string = never> implements LoggerTypesAwareReporter<T, L>, StringifyAwareReporter<L> {
|
|
13
|
+
protected readonly _styles: PrettyStyleOptions;
|
|
14
|
+
protected _loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
|
|
15
|
+
protected _stringify: typeof stringify | undefined;
|
|
16
|
+
protected constructor(options: Partial<PrettyStyleOptions>);
|
|
17
|
+
setStringify(function_: any): void;
|
|
18
|
+
setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
19
|
+
abstract log(meta: ReadonlyMeta<L>): void;
|
|
20
|
+
}
|
|
21
|
+
type PrettyStyleOptions = {
|
|
22
|
+
bold: {
|
|
23
|
+
label: boolean;
|
|
24
|
+
};
|
|
25
|
+
dateFormatter: (date: Date) => string;
|
|
26
|
+
messageLength: number | undefined;
|
|
27
|
+
underline: {
|
|
28
|
+
label: boolean;
|
|
29
|
+
prefix: boolean;
|
|
30
|
+
suffix: boolean;
|
|
31
|
+
};
|
|
32
|
+
uppercase: {
|
|
33
|
+
label: boolean;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { AbstractJsonReporter as A, type PrettyStyleOptions as P, AbstractPrettyReporter as a };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { stringify } from 'safe-stable-stringify';
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
|
+
import { g as StringifyAwareReporter, f as ReadonlyMeta, E as ExtendedRfc5424LogLevels, c as LoggerTypesAwareReporter, d as LoggerTypesConfig, a as DefaultLogTypes } from './types.d-RNxsa9NR.js';
|
|
4
|
+
|
|
5
|
+
declare abstract class AbstractJsonReporter<L extends string = never> implements StringifyAwareReporter<L> {
|
|
6
|
+
protected _stringify: typeof stringify | undefined;
|
|
7
|
+
setStringify(function_: any): void;
|
|
8
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
9
|
+
protected abstract _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare abstract class AbstractPrettyReporter<T extends string = never, L extends string = never> implements LoggerTypesAwareReporter<T, L>, StringifyAwareReporter<L> {
|
|
13
|
+
protected readonly _styles: PrettyStyleOptions;
|
|
14
|
+
protected _loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
|
|
15
|
+
protected _stringify: typeof stringify | undefined;
|
|
16
|
+
protected constructor(options: Partial<PrettyStyleOptions>);
|
|
17
|
+
setStringify(function_: any): void;
|
|
18
|
+
setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
19
|
+
abstract log(meta: ReadonlyMeta<L>): void;
|
|
20
|
+
}
|
|
21
|
+
type PrettyStyleOptions = {
|
|
22
|
+
bold: {
|
|
23
|
+
label: boolean;
|
|
24
|
+
};
|
|
25
|
+
dateFormatter: (date: Date) => string;
|
|
26
|
+
messageLength: number | undefined;
|
|
27
|
+
underline: {
|
|
28
|
+
label: boolean;
|
|
29
|
+
prefix: boolean;
|
|
30
|
+
suffix: boolean;
|
|
31
|
+
};
|
|
32
|
+
uppercase: {
|
|
33
|
+
label: boolean;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { AbstractJsonReporter as A, type PrettyStyleOptions as P, AbstractPrettyReporter as a };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk4RK45K5E_cjs = require('./chunk-4RK45K5E.cjs');
|
|
4
|
+
var chunk7OFJLC7L_cjs = require('./chunk-7OFJLC7L.cjs');
|
|
5
|
+
|
|
6
|
+
var t=class extends chunk7OFJLC7L_cjs.a{constructor(){super();}_log(r,n){chunk4RK45K5E_cjs.a(n)(r);}};
|
|
7
|
+
|
|
8
|
+
exports.a = t;
|
|
9
|
+
//# sourceMappingURL=out.js.map
|
|
10
|
+
//# sourceMappingURL=chunk-32FAOPTJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/reporter/json/json.browser.ts"],"names":["JsonReporter","AbstractJsonReporter","message","logLevel","writeConsoleLogBasedOnLevel"],"mappings":"kFAMO,IAAMA,EAAN,cAAqDC,CAAwB,CACzE,aAAc,CACjB,MAAM,CACV,CAGmB,KAAKC,EAAiBC,EAA2D,CACrEC,EAA4BD,CAAQ,EAE5CD,CAAO,CAC9B,CACJ","sourcesContent":["import type { LiteralUnion } from \"type-fest\";\n\nimport type { ExtendedRfc5424LogLevels } from \"../../types\";\nimport { writeConsoleLogBasedOnLevel } from \"../../util/write-console-log\";\nimport { AbstractJsonReporter } from \"./abstract-json-reporter\";\n\nexport class JsonReporter<L extends string = never> extends AbstractJsonReporter<L> {\n public constructor() {\n super();\n }\n\n // eslint-disable-next-line class-methods-use-this\n protected override _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void {\n const consoleLogFunction = writeConsoleLogBasedOnLevel(logLevel);\n\n consoleLogFunction(message);\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkMU2CRXVO_cjs = require('./chunk-MU2CRXVO.cjs');
|
|
4
|
+
|
|
5
|
+
var a=o=>{let e=Object.keys(o).map(t=>o[t].badge??"");return e.length===0?"":e.reduce((t,r)=>t.length>r.length?t:r)};var n=class{constructor(e){this._styles={bold:{label:!1},dateFormatter:t=>[t.getHours(),t.getMinutes(),t.getSeconds()].map(r=>String(r).padStart(2,"0")).join(":"),underline:{label:!1,message:!1,prefix:!1,suffix:!1},uppercase:{label:!1},...e},this._loggerTypes=chunkMU2CRXVO_cjs.b;}setStringify(e){this._stringify=e;}setLoggerTypes(e){this._loggerTypes=e;}};
|
|
6
|
+
|
|
7
|
+
exports.a = a;
|
|
8
|
+
exports.b = n;
|
|
9
|
+
//# sourceMappingURL=out.js.map
|
|
10
|
+
//# sourceMappingURL=chunk-46NTLZF7.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/get-longest-badge.ts","../src/reporter/pretty/abstract-pretty-reporter.ts"],"names":["getLongestBadge","types","badges","x","y","AbstractPrettyReporter","options","date","n","LOG_TYPES","function_"],"mappings":"yCAIO,IAAMA,EAAuDC,GAA0E,CAE1I,IAAMC,EAAS,OAAO,KAAKD,CAAK,EAAE,IAAKE,GAAMF,EAAME,CAAM,EAAE,OAAS,EAAE,EAEtE,OAAID,EAAO,SAAW,EACX,GAIJA,EAAO,OAAO,CAACC,EAAGC,IAAOD,EAAE,OAASC,EAAE,OAASD,EAAIC,CAAE,CAChE,ECRO,IAAeC,EAAf,KAEP,CAOc,YAAYC,EAAsC,CACxD,KAAK,QAAU,CACX,KAAM,CACF,MAAO,EACX,EACA,cAAgBC,GAAe,CAACA,EAAK,SAAS,EAAGA,EAAK,WAAW,EAAGA,EAAK,WAAW,CAAC,EAAE,IAAKC,GAAM,OAAOA,CAAC,EAAE,SAAS,EAAG,GAAG,CAAC,EAAE,KAAK,GAAG,EACtI,UAAW,CACP,MAAO,GACP,QAAS,GACT,OAAQ,GACR,OAAQ,EACZ,EACA,UAAW,CACP,MAAO,EACX,EACA,GAAGF,CACP,EAEA,KAAK,aAAeG,CACxB,CAGO,aAAaC,EAAsB,CACtC,KAAK,WAAaA,CACtB,CAEO,eAAeT,EAAqE,CACvF,KAAK,aAAeA,CACxB,CAGJ","sourcesContent":["import type { LiteralUnion } from \"type-fest\";\n\nimport type { DefaultLogTypes, LoggerTypesConfig } from \"../types\";\n\nexport const getLongestBadge = <L extends string, T extends string>(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n const badges = Object.keys(types).map((x) => types[x as T].badge ?? \"\");\n\n if (badges.length === 0) {\n return \"\";\n }\n\n // eslint-disable-next-line unicorn/no-array-reduce\n return badges.reduce((x, y) => (x.length > y.length ? x : y));\n};\n","import type { stringify } from \"safe-stable-stringify\";\nimport type { LiteralUnion } from \"type-fest\";\n\nimport { LOG_TYPES } from \"../../constants\";\nimport type { DefaultLogTypes, LoggerTypesAwareReporter, LoggerTypesConfig, ReadonlyMeta, StringifyAwareReporter } from \"../../types\";\n\nexport abstract class AbstractPrettyReporter<T extends string = never, L extends string = never>\n implements LoggerTypesAwareReporter<T, L>, StringifyAwareReporter<L>\n{\n protected readonly _styles: PrettyStyleOptions;\n\n protected _loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;\n\n protected _stringify: typeof stringify | undefined;\n\n protected constructor(options: Partial<PrettyStyleOptions>) {\n this._styles = {\n bold: {\n label: false,\n },\n dateFormatter: (date: Date) => [date.getHours(), date.getMinutes(), date.getSeconds()].map((n) => String(n).padStart(2, \"0\")).join(\":\"),\n underline: {\n label: false,\n message: false,\n prefix: false,\n suffix: false,\n },\n uppercase: {\n label: false,\n },\n ...options,\n } as PrettyStyleOptions;\n\n this._loggerTypes = LOG_TYPES as LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n public setStringify(function_: any): void {\n this._stringify = function_;\n }\n\n public setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void {\n this._loggerTypes = types;\n }\n\n public abstract log(meta: ReadonlyMeta<L>): void;\n}\n\nexport type PrettyStyleOptions = {\n bold: {\n label: boolean;\n };\n dateFormatter: (date: Date) => string;\n // Length of the message before a line break is inserted\n messageLength: number | undefined;\n underline: {\n label: boolean;\n prefix: boolean;\n suffix: boolean;\n };\n uppercase: {\n label: boolean;\n };\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var r=e=>e==="error"?console.__error??console.error:e==="warn"?console.__warn??console.warn:e==="trace"?console.__trace??console.trace:console.__log??console.log;
|
|
4
|
+
|
|
5
|
+
exports.a = r;
|
|
6
|
+
//# sourceMappingURL=out.js.map
|
|
7
|
+
//# sourceMappingURL=chunk-4RK45K5E.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/write-console-log.ts"],"names":["writeConsoleLogBasedOnLevel","level"],"mappings":"AAKO,IAAMA,EAAyDC,GAC9DA,IAAU,QAEF,QAAgB,SAAW,QAAQ,MAG3CA,IAAU,OAEF,QAAgB,QAAU,QAAQ,KAG1CA,IAAU,QAEF,QAAgB,SAAW,QAAQ,MAIvC,QAAgB,OAAS,QAAQ","sourcesContent":["import type { LiteralUnion } from \"type-fest\";\n\nimport type { ExtendedRfc5424LogLevels } from \"../types\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const writeConsoleLogBasedOnLevel = <L extends string = never>(level: LiteralUnion<ExtendedRfc5424LogLevels, L>): ((...data: any[]) => void) => {\n if (level === \"error\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__error ?? console.error;\n }\n\n if (level === \"warn\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__warn ?? console.warn;\n }\n\n if (level === \"trace\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__trace ?? console.trace;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__log ?? console.log;\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { b } from './chunk-EBP7SMYV.js';
|
|
2
|
+
|
|
3
|
+
var g=o=>{let e=Object.keys(o).map(t=>o[t].badge??"");return e.length===0?"":e.reduce((t,r)=>t.length>r.length?t:r)};var n=class{constructor(e){this._styles={bold:{label:!1},dateFormatter:t=>[t.getHours(),t.getMinutes(),t.getSeconds()].map(r=>String(r).padStart(2,"0")).join(":"),underline:{label:!1,message:!1,prefix:!1,suffix:!1},uppercase:{label:!1},...e},this._loggerTypes=b;}setStringify(e){this._stringify=e;}setLoggerTypes(e){this._loggerTypes=e;}};
|
|
4
|
+
|
|
5
|
+
export { g as a, n as b };
|
|
6
|
+
//# sourceMappingURL=out.js.map
|
|
7
|
+
//# sourceMappingURL=chunk-57OYT2NC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/get-longest-badge.ts","../src/reporter/pretty/abstract-pretty-reporter.ts"],"names":["getLongestBadge","types","badges","x","y","AbstractPrettyReporter","options","date","n","LOG_TYPES","function_"],"mappings":"wCAIO,IAAMA,EAAuDC,GAA0E,CAE1I,IAAMC,EAAS,OAAO,KAAKD,CAAK,EAAE,IAAKE,GAAMF,EAAME,CAAM,EAAE,OAAS,EAAE,EAEtE,OAAID,EAAO,SAAW,EACX,GAIJA,EAAO,OAAO,CAACC,EAAGC,IAAOD,EAAE,OAASC,EAAE,OAASD,EAAIC,CAAE,CAChE,ECRO,IAAeC,EAAf,KAEP,CAOc,YAAYC,EAAsC,CACxD,KAAK,QAAU,CACX,KAAM,CACF,MAAO,EACX,EACA,cAAgBC,GAAe,CAACA,EAAK,SAAS,EAAGA,EAAK,WAAW,EAAGA,EAAK,WAAW,CAAC,EAAE,IAAKC,GAAM,OAAOA,CAAC,EAAE,SAAS,EAAG,GAAG,CAAC,EAAE,KAAK,GAAG,EACtI,UAAW,CACP,MAAO,GACP,QAAS,GACT,OAAQ,GACR,OAAQ,EACZ,EACA,UAAW,CACP,MAAO,EACX,EACA,GAAGF,CACP,EAEA,KAAK,aAAeG,CACxB,CAGO,aAAaC,EAAsB,CACtC,KAAK,WAAaA,CACtB,CAEO,eAAeT,EAAqE,CACvF,KAAK,aAAeA,CACxB,CAGJ","sourcesContent":["import type { LiteralUnion } from \"type-fest\";\n\nimport type { DefaultLogTypes, LoggerTypesConfig } from \"../types\";\n\nexport const getLongestBadge = <L extends string, T extends string>(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n const badges = Object.keys(types).map((x) => types[x as T].badge ?? \"\");\n\n if (badges.length === 0) {\n return \"\";\n }\n\n // eslint-disable-next-line unicorn/no-array-reduce\n return badges.reduce((x, y) => (x.length > y.length ? x : y));\n};\n","import type { stringify } from \"safe-stable-stringify\";\nimport type { LiteralUnion } from \"type-fest\";\n\nimport { LOG_TYPES } from \"../../constants\";\nimport type { DefaultLogTypes, LoggerTypesAwareReporter, LoggerTypesConfig, ReadonlyMeta, StringifyAwareReporter } from \"../../types\";\n\nexport abstract class AbstractPrettyReporter<T extends string = never, L extends string = never>\n implements LoggerTypesAwareReporter<T, L>, StringifyAwareReporter<L>\n{\n protected readonly _styles: PrettyStyleOptions;\n\n protected _loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;\n\n protected _stringify: typeof stringify | undefined;\n\n protected constructor(options: Partial<PrettyStyleOptions>) {\n this._styles = {\n bold: {\n label: false,\n },\n dateFormatter: (date: Date) => [date.getHours(), date.getMinutes(), date.getSeconds()].map((n) => String(n).padStart(2, \"0\")).join(\":\"),\n underline: {\n label: false,\n message: false,\n prefix: false,\n suffix: false,\n },\n uppercase: {\n label: false,\n },\n ...options,\n } as PrettyStyleOptions;\n\n this._loggerTypes = LOG_TYPES as LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n public setStringify(function_: any): void {\n this._stringify = function_;\n }\n\n public setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void {\n this._loggerTypes = types;\n }\n\n public abstract log(meta: ReadonlyMeta<L>): void;\n}\n\nexport type PrettyStyleOptions = {\n bold: {\n label: boolean;\n };\n dateFormatter: (date: Date) => string;\n // Length of the message before a line break is inserted\n messageLength: number | undefined;\n underline: {\n label: boolean;\n prefix: boolean;\n suffix: boolean;\n };\n uppercase: {\n label: boolean;\n };\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var e=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var f=(a,b,c)=>(e(a,b,"read from private field"),c?c.call(a):b.get(a)),g=(a,b,c)=>{if(b.has(a))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(a):b.set(a,c);},h=(a,b,c,d)=>(e(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c);
|
|
4
|
+
|
|
5
|
+
exports.a = f;
|
|
6
|
+
exports.b = g;
|
|
7
|
+
exports.c = h;
|
|
8
|
+
//# sourceMappingURL=out.js.map
|
|
9
|
+
//# sourceMappingURL=chunk-6ATEEAVC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|