@meadown/logger 1.3.0 → 1.3.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.
package/README.md
CHANGED
|
@@ -33,11 +33,27 @@ You'll see something like:
|
|
|
33
33
|
|
|
34
34
|
```text
|
|
35
35
|
[INFO] 2026-05-30T10:00:00.000Z (server.ts:42)
|
|
36
|
-
Auth user logged in
|
|
36
|
+
Auth user logged in
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
timestamp and the source location
|
|
39
|
+
The first line carries the level tag — `[INFO]`, `[WARN]`, or `[ERROR]` — the
|
|
40
|
+
timestamp, and the source location. Your message sits on the line below, indented so
|
|
41
|
+
it's easy to scan down a busy terminal.
|
|
42
|
+
|
|
43
|
+
### One thing if you re-export it
|
|
44
|
+
|
|
45
|
+
A lot of projects like to funnel everything through their own `lib/logger` file.
|
|
46
|
+
That's totally fine here — just pass the logger straight through instead of wrapping
|
|
47
|
+
it in a new function. The file and line are read from the call stack, so an extra
|
|
48
|
+
wrapper makes every log blame _that_ file instead of wherever you actually logged.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
// GOOD: pass it through — the (file:line) stays honest
|
|
52
|
+
export { default as customLog } from "@meadown/logger"
|
|
53
|
+
|
|
54
|
+
// BAD: now every log points at this file, not the real caller
|
|
55
|
+
export const customLog = (...args) => log(...args)
|
|
56
|
+
```
|
|
41
57
|
|
|
42
58
|
## Color-coded levels
|
|
43
59
|
|
|
@@ -51,7 +67,7 @@ codes in your log files. Nothing to configure.
|
|
|
51
67
|
|
|
52
68
|
## Click to open the source
|
|
53
69
|
|
|
54
|
-
That `(server.ts:42)` at the end of every log isn't just text — when you
|
|
70
|
+
That `(server.ts:42)` at the end of every log isn't just text — when you are in a
|
|
55
71
|
terminal, it's a **clickable link** that opens the file the log came from. No more
|
|
56
72
|
hunting for where a message came from, and the line number is right there in the
|
|
57
73
|
label.
|
|
@@ -52,6 +52,8 @@ function createLog(channel, tag) {
|
|
|
52
52
|
const tagOut = (0, color_js_1.supportsColor)(streamName)
|
|
53
53
|
? (0, color_js_1.colorize)(tag, TAG_COLOR[channel])
|
|
54
54
|
: tag;
|
|
55
|
-
console
|
|
55
|
+
// `\n ` + console's own separator space => the message is indented 2 spaces
|
|
56
|
+
// on its own line below the metadata.
|
|
57
|
+
console[channel](tagOut, (0, getTimeStamp_js_1.default)(), `(${location})`, `\n `, ...args, `\n`);
|
|
56
58
|
};
|
|
57
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLog.d.ts","sourceRoot":"","sources":["../../src/utils/createLog.ts"],"names":[],"mappings":"AAaA,iDAAiD;AACjD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAA;AA4BjD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,MAAM,GACV,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"createLog.d.ts","sourceRoot":"","sources":["../../src/utils/createLog.ts"],"names":[],"mappings":"AAaA,iDAAiD;AACjD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAA;AA4BjD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,MAAM,GACV,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAgB9B"}
|
package/dist/utils/createLog.js
CHANGED
|
@@ -46,7 +46,9 @@ export default function createLog(channel, tag) {
|
|
|
46
46
|
const tagOut = supportsColor(streamName)
|
|
47
47
|
? colorize(tag, TAG_COLOR[channel])
|
|
48
48
|
: tag;
|
|
49
|
-
|
|
49
|
+
// `\n ` + console's own separator space => the message is indented 2 spaces
|
|
50
|
+
// on its own line below the metadata.
|
|
51
|
+
console[channel](tagOut, getTimeStamp(), `(${location})`, `\n `, ...args, `\n`);
|
|
50
52
|
};
|
|
51
53
|
}
|
|
52
54
|
//# sourceMappingURL=createLog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLog.js","sourceRoot":"","sources":["../../src/utils/createLog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,SAA0B,MAAM,gBAAgB,CAAA;AACvD,OAAO,YAAY,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAc,MAAM,YAAY,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAK3C,+EAA+E;AAC/E,MAAM,SAAS,GAA8B;IAC3C,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,KAAK;CACb,CAAA;AAED;;;;;GAKG;AACH,SAAS,cAAc,CACrB,MAAc,EACd,UAA+B;IAE/B,IACE,MAAM,CAAC,IAAI,KAAK,IAAI;QACpB,MAAM,CAAC,IAAI,KAAK,IAAI;QACpB,kBAAkB,CAAC,UAAU,CAAC;QAE9B,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IACtD,OAAO,MAAM,CAAC,KAAK,CAAA;AACrB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,OAAmB,EACnB,GAAW;IAEX,MAAM,UAAU,GAAG,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAA;IAC1D,OAAO,CAAC,GAAG,IAAe,EAAQ,EAAE;QAClC,IAAI,CAAC,YAAY,EAAE;YAAE,OAAM;QAC3B,MAAM,MAAM,GAAG,SA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AAU,GAAG,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAA;IAC1D,OAAO,CAAC,GAAG,IAAe,EAAQ,EAAE;QAClC,IAAI,CAAC,YAAY,EAAE;YAAE,OAAM;QAC3B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;QAEnD,yDAAyD;QACzD,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC;YACtC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;YACnC,CAAC,CAAC,GAAG,CAAA;QAEP,4EAA4E;QAC5E,sCAAsC;QACtC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,IAAI,QAAQ,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,IAAI,CAAC,CAAA;IACjF,CAAC,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meadown/logger",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
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",
|