@meadown/logger 1.5.2 → 1.7.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/README.md +12 -12
- package/dist/cjs/index.d.ts +13 -3
- package/dist/cjs/index.js +5 -6
- package/dist/index.d.ts +13 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,13 +24,13 @@ yarn add @meadown/logger
|
|
|
24
24
|
## Using it
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
|
-
import
|
|
27
|
+
import logger from "@meadown/logger"
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
logger("Hello world")
|
|
30
|
+
logger("Auth", "user logged in") // every argument is printed as-is, like console.log
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
logger.warn("This is deprecated")
|
|
33
|
+
logger.error("Something went wrong")
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
You'll see something like:
|
|
@@ -55,10 +55,10 @@ wrapper makes every log blame _that_ file instead of wherever you actually logge
|
|
|
55
55
|
|
|
56
56
|
```ts
|
|
57
57
|
// GOOD: pass it through — the (file:line) stays honest
|
|
58
|
-
export { default as
|
|
58
|
+
export { default as logger } from "@meadown/logger"
|
|
59
59
|
|
|
60
60
|
// BAD: now every log points at this file, not the real caller
|
|
61
|
-
export const
|
|
61
|
+
export const logger = (...args) => log(...args)
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
## Color-coded levels
|
|
@@ -91,14 +91,14 @@ chatty multi-line message is drowning out your terminal, you can cap how many
|
|
|
91
91
|
lines each message shows:
|
|
92
92
|
|
|
93
93
|
```ts
|
|
94
|
-
import
|
|
94
|
+
import logger from "@meadown/logger"
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
logger.maxLines = 5 // show the first 5 lines, then "... N more lines"
|
|
97
|
+
logger.maxLines = 0 // back to the default — show everything
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
It only trims the _message_, never the tag, timestamp, or location, and the setting
|
|
101
|
-
applies to `
|
|
101
|
+
applies to `logger`, `.error`, and `.warn` alike.
|
|
102
102
|
|
|
103
103
|
## What about production?
|
|
104
104
|
|
|
@@ -117,7 +117,7 @@ quietly step aside.
|
|
|
117
117
|
## Security
|
|
118
118
|
|
|
119
119
|
It's a tiny, zero-dependency package with no file, network, or dynamic-code access.
|
|
120
|
-
See [SECURITY.md](https://
|
|
120
|
+
See [SECURITY.md](https://www.npmjs.com/package/@meadown/logger?activeTab=code)
|
|
121
121
|
for the security model and how to report a vulnerability. One thing to know: like
|
|
122
122
|
`console.log`, log arguments are written to the terminal as-is and are not
|
|
123
123
|
sanitized — don't log untrusted data to a terminal you trust.
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -9,6 +9,16 @@ export interface LogFN {
|
|
|
9
9
|
*/
|
|
10
10
|
maxLines: number;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Logs to the console, but only outside production. Each line is prefixed with
|
|
14
|
+
* a level tag, a short local timestamp, and a clickable link to the file it was
|
|
15
|
+
* called from; all arguments are then printed as-is.
|
|
16
|
+
* @example
|
|
17
|
+
* logger("Auth", "user logged in")
|
|
18
|
+
* // [INFO] 05-30 04:00:00 PM (server.ts:42) Auth user logged in
|
|
19
|
+
* @example
|
|
20
|
+
* logger.maxLines = 5 // long messages collapse to 5 lines; 0 = show all
|
|
21
|
+
*/
|
|
22
|
+
declare const logger: LogFN;
|
|
23
|
+
export { logger };
|
|
24
|
+
export default logger;
|
package/dist/cjs/index.js
CHANGED
|
@@ -6,22 +6,23 @@
|
|
|
6
6
|
* All rights reserved
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.logger = void 0;
|
|
10
10
|
const index_js_1 = require("./utils/index.js");
|
|
11
11
|
/**
|
|
12
12
|
* Logs to the console, but only outside production. Each line is prefixed with
|
|
13
13
|
* a level tag, a short local timestamp, and a clickable link to the file it was
|
|
14
14
|
* called from; all arguments are then printed as-is.
|
|
15
15
|
* @example
|
|
16
|
-
*
|
|
16
|
+
* logger("Auth", "user logged in")
|
|
17
17
|
* // [INFO] 05-30 04:00:00 PM (server.ts:42) Auth user logged in
|
|
18
18
|
* @example
|
|
19
|
-
*
|
|
19
|
+
* logger.maxLines = 5 // long messages collapse to 5 lines; 0 = show all
|
|
20
20
|
*/
|
|
21
21
|
const logger = Object.assign((0, index_js_1.createLog)("log", "[INFO]"), {
|
|
22
22
|
error: (0, index_js_1.createLog)("error", "[ERROR]"),
|
|
23
23
|
warn: (0, index_js_1.createLog)("warn", "[WARN]"),
|
|
24
24
|
});
|
|
25
|
+
exports.logger = logger;
|
|
25
26
|
// `maxLines` is a live getter/setter backed by the shared collapse setting, so
|
|
26
27
|
// setting it once affects info, error, and warn alike.
|
|
27
28
|
Object.defineProperty(logger, "maxLines", {
|
|
@@ -30,6 +31,4 @@ Object.defineProperty(logger, "maxLines", {
|
|
|
30
31
|
enumerable: true,
|
|
31
32
|
configurable: true,
|
|
32
33
|
});
|
|
33
|
-
|
|
34
|
-
exports.customLog = customLog;
|
|
35
|
-
exports.default = customLog;
|
|
34
|
+
exports.default = logger;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,17 @@ export interface LogFN {
|
|
|
9
9
|
*/
|
|
10
10
|
maxLines: number;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Logs to the console, but only outside production. Each line is prefixed with
|
|
14
|
+
* a level tag, a short local timestamp, and a clickable link to the file it was
|
|
15
|
+
* called from; all arguments are then printed as-is.
|
|
16
|
+
* @example
|
|
17
|
+
* logger("Auth", "user logged in")
|
|
18
|
+
* // [INFO] 05-30 04:00:00 PM (server.ts:42) Auth user logged in
|
|
19
|
+
* @example
|
|
20
|
+
* logger.maxLines = 5 // long messages collapse to 5 lines; 0 = show all
|
|
21
|
+
*/
|
|
22
|
+
declare const logger: LogFN;
|
|
23
|
+
export { logger };
|
|
24
|
+
export default logger;
|
|
15
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,gFAAgF;AAChF,MAAM,WAAW,KAAK;IACpB,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC1B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC/B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC9B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAA;CACjB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,gFAAgF;AAChF,MAAM,WAAW,KAAK;IACpB,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC1B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC/B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC9B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;GASG;AACH,QAAA,MAAM,MAAM,EAGN,KAAK,CAAA;AAWX,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,eAAe,MAAM,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -10,10 +10,10 @@ import { createLog, getVisibleLines, setVisibleLines } from "./utils/index.js";
|
|
|
10
10
|
* a level tag, a short local timestamp, and a clickable link to the file it was
|
|
11
11
|
* called from; all arguments are then printed as-is.
|
|
12
12
|
* @example
|
|
13
|
-
*
|
|
13
|
+
* logger("Auth", "user logged in")
|
|
14
14
|
* // [INFO] 05-30 04:00:00 PM (server.ts:42) Auth user logged in
|
|
15
15
|
* @example
|
|
16
|
-
*
|
|
16
|
+
* logger.maxLines = 5 // long messages collapse to 5 lines; 0 = show all
|
|
17
17
|
*/
|
|
18
18
|
const logger = Object.assign(createLog("log", "[INFO]"), {
|
|
19
19
|
error: createLog("error", "[ERROR]"),
|
|
@@ -27,7 +27,6 @@ Object.defineProperty(logger, "maxLines", {
|
|
|
27
27
|
enumerable: true,
|
|
28
28
|
configurable: true,
|
|
29
29
|
});
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
export default customLog;
|
|
30
|
+
export { logger };
|
|
31
|
+
export default logger;
|
|
33
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAc9E;;;;;;;;;GASG;AACH,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE;IACvD,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC;IACpC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC;CAClC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAc9E;;;;;;;;;GASG;AACH,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE;IACvD,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC;IACpC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC;CAClC,CAAU,CAAA;AAEX,+EAA+E;AAC/E,uDAAuD;AACvD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE;IACxC,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,eAAe;IACpB,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;CACnB,CAAC,CAAA;AAEF,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,eAAe,MAAM,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meadown/logger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "A tiny, zero-dependency logger for Node.js and TypeScript that tags each line, timestamps it, shows the source file and line, and goes quiet in production.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logger",
|