@meadown/logger 1.3.1 → 1.4.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 +7 -6
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/utils/color.d.ts +1 -0
- package/dist/cjs/utils/color.js +1 -0
- package/dist/cjs/utils/createLog.js +14 -10
- package/dist/cjs/utils/getTimeStamp.d.ts +6 -2
- package/dist/cjs/utils/getTimeStamp.js +19 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/utils/color.d.ts +1 -0
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/color.js +1 -0
- package/dist/utils/color.js.map +1 -1
- package/dist/utils/createLog.d.ts.map +1 -1
- package/dist/utils/createLog.js +14 -10
- package/dist/utils/createLog.js.map +1 -1
- package/dist/utils/getTimeStamp.d.ts +6 -2
- package/dist/utils/getTimeStamp.d.ts.map +1 -1
- package/dist/utils/getTimeStamp.js +19 -3
- package/dist/utils/getTimeStamp.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,13 +32,14 @@ customLog.error("Something went wrong")
|
|
|
32
32
|
You'll see something like:
|
|
33
33
|
|
|
34
34
|
```text
|
|
35
|
-
[INFO] 2026-05-
|
|
36
|
-
|
|
35
|
+
[INFO] 2026-05-30 04:00:00 PM GMT+6 (server.ts:42)
|
|
36
|
+
└── Auth user logged in
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
The first line carries the level tag — `[INFO]`, `[WARN]`, or `[ERROR]` — the
|
|
40
|
-
timestamp, and the source location. Your message
|
|
41
|
-
|
|
40
|
+
local timestamp with AM/PM and timezone, and the source location. Your message hangs
|
|
41
|
+
off a `└──` branch on the line below (colored to match the level), so it's easy to
|
|
42
|
+
scan down a busy terminal.
|
|
42
43
|
|
|
43
44
|
### One thing if you re-export it
|
|
44
45
|
|
|
@@ -58,8 +59,8 @@ export const customLog = (...args) => log(...args)
|
|
|
58
59
|
## Color-coded levels
|
|
59
60
|
|
|
60
61
|
The level tag is colored so you can spot what matters at a glance — `[INFO]` in
|
|
61
|
-
cyan, `[WARN]` in yellow, `[ERROR]` in red. The
|
|
62
|
-
|
|
62
|
+
cyan, `[WARN]` in yellow, `[ERROR]` in red. The `(file:line)` location is dimmed to
|
|
63
|
+
light gray so it stays out of the way, and the timestamp is left plain.
|
|
63
64
|
|
|
64
65
|
Colors appear automatically when you're in a terminal. When output is piped to a
|
|
65
66
|
file or another program, the tag prints as plain `[INFO]` text — no stray color
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ export interface LogFN {
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Logs to the console, but only outside production. Each line is prefixed with
|
|
9
|
-
* a level tag,
|
|
10
|
-
* was called from; all arguments are then printed as-is.
|
|
9
|
+
* a level tag, a local AM/PM timestamp with timezone, and a clickable link to
|
|
10
|
+
* the file it was called from; all arguments are then printed as-is.
|
|
11
11
|
* @example
|
|
12
12
|
* customLog("Auth", "user logged in")
|
|
13
|
-
* // [INFO] 2026-05-
|
|
13
|
+
* // [INFO] 2026-05-30 04:00:00 PM GMT+6 (server.ts:42) Auth user logged in
|
|
14
14
|
*/
|
|
15
15
|
declare const customLog: LogFN;
|
|
16
16
|
export { customLog };
|
package/dist/cjs/index.js
CHANGED
|
@@ -10,11 +10,11 @@ exports.customLog = 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
|
-
* a level tag,
|
|
14
|
-
* was called from; all arguments are then printed as-is.
|
|
13
|
+
* a level tag, a local AM/PM timestamp with timezone, and a clickable link to
|
|
14
|
+
* the file it was called from; all arguments are then printed as-is.
|
|
15
15
|
* @example
|
|
16
16
|
* customLog("Auth", "user logged in")
|
|
17
|
-
* // [INFO] 2026-05-
|
|
17
|
+
* // [INFO] 2026-05-30 04:00:00 PM GMT+6 (server.ts:42) Auth user logged in
|
|
18
18
|
*/
|
|
19
19
|
const customLog = Object.assign((0, index_js_1.createLog)("log", "[INFO]"), {
|
|
20
20
|
error: (0, index_js_1.createLog)("error", "[ERROR]"),
|
package/dist/cjs/utils/color.js
CHANGED
|
@@ -23,9 +23,10 @@ const TAG_COLOR = {
|
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
25
|
* Renders a caller as a `(file:line)` location. When the terminal supports
|
|
26
|
-
* OSC-8 hyperlinks, the location is a clickable link to the
|
|
27
|
-
* otherwise it's plain text. Pure (no
|
|
28
|
-
*
|
|
26
|
+
* OSC-8 hyperlinks, the location is a clickable link to the source file while
|
|
27
|
+
* the line stays visible in the label; otherwise it's plain text. Pure (no
|
|
28
|
+
* stack access), so it can be called from a helper without disturbing
|
|
29
|
+
* {@link getCaller}'s frame depth.
|
|
29
30
|
*/
|
|
30
31
|
function formatLocation(caller, streamName) {
|
|
31
32
|
if (caller.file !== null &&
|
|
@@ -48,12 +49,15 @@ function createLog(channel, tag) {
|
|
|
48
49
|
return;
|
|
49
50
|
const caller = (0, getCaller_js_1.default)();
|
|
50
51
|
const location = formatLocation(caller, streamName);
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
// On a real terminal: color the level tag and the `└──` connector (same
|
|
53
|
+
// color), and dim the location to gray. The timestamp stays plain.
|
|
54
|
+
const useColor = (0, color_js_1.supportsColor)(streamName);
|
|
55
|
+
const color = TAG_COLOR[channel];
|
|
56
|
+
const tagOut = useColor ? (0, color_js_1.colorize)(tag, color) : tag;
|
|
57
|
+
const locOut = useColor ? (0, color_js_1.colorize)(`(${location})`, "gray") : `(${location})`;
|
|
58
|
+
const connector = useColor ? (0, color_js_1.colorize)("└──", color) : "└──";
|
|
59
|
+
// `\n` + connector puts the message on its own line under a tree branch;
|
|
60
|
+
// console's separator space sits between the connector and the message.
|
|
61
|
+
console[channel](tagOut, (0, getTimeStamp_js_1.default)(), locOut, `\n${connector}`, ...args, `\n`);
|
|
58
62
|
};
|
|
59
63
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Returns local time as an ISO date plus a readable AM/PM time and timezone,
|
|
3
|
+
* e.g. `2026-05-29 04:00:00 PM GMT+6`. The date and time are both local, so they
|
|
4
|
+
* stay consistent.
|
|
5
|
+
*/
|
|
6
|
+
export default function getTimeStamp(date?: Date): string;
|
|
@@ -7,7 +7,23 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.default = getTimeStamp;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// Time-only formatter (date is built separately so it stays ISO `YYYY-MM-DD`).
|
|
11
|
+
const TIME_FORMATTER = new Intl.DateTimeFormat("en-US", {
|
|
12
|
+
hour: "2-digit",
|
|
13
|
+
minute: "2-digit",
|
|
14
|
+
second: "2-digit",
|
|
15
|
+
hour12: true,
|
|
16
|
+
timeZoneName: "short",
|
|
17
|
+
});
|
|
18
|
+
function pad(value) {
|
|
19
|
+
return String(value).padStart(2, "0");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns local time as an ISO date plus a readable AM/PM time and timezone,
|
|
23
|
+
* e.g. `2026-05-29 04:00:00 PM GMT+6`. The date and time are both local, so they
|
|
24
|
+
* stay consistent.
|
|
25
|
+
*/
|
|
26
|
+
function getTimeStamp(date = new Date()) {
|
|
27
|
+
const datePart = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
28
|
+
return `${datePart} ${TIME_FORMATTER.format(date)}`;
|
|
13
29
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ export interface LogFN {
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Logs to the console, but only outside production. Each line is prefixed with
|
|
9
|
-
* a level tag,
|
|
10
|
-
* was called from; all arguments are then printed as-is.
|
|
9
|
+
* a level tag, a local AM/PM timestamp with timezone, and a clickable link to
|
|
10
|
+
* the file it was called from; all arguments are then printed as-is.
|
|
11
11
|
* @example
|
|
12
12
|
* customLog("Auth", "user logged in")
|
|
13
|
-
* // [INFO] 2026-05-
|
|
13
|
+
* // [INFO] 2026-05-30 04:00:00 PM GMT+6 (server.ts:42) Auth user logged in
|
|
14
14
|
*/
|
|
15
15
|
declare const customLog: LogFN;
|
|
16
16
|
export { customLog };
|
package/dist/index.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
import { createLog } from "./utils/index.js";
|
|
8
8
|
/**
|
|
9
9
|
* Logs to the console, but only outside production. Each line is prefixed with
|
|
10
|
-
* a level tag,
|
|
11
|
-
* was called from; all arguments are then printed as-is.
|
|
10
|
+
* a level tag, a local AM/PM timestamp with timezone, and a clickable link to
|
|
11
|
+
* the file it was called from; all arguments are then printed as-is.
|
|
12
12
|
* @example
|
|
13
13
|
* customLog("Auth", "user logged in")
|
|
14
|
-
* // [INFO] 2026-05-
|
|
14
|
+
* // [INFO] 2026-05-30 04:00:00 PM GMT+6 (server.ts:42) Auth user logged in
|
|
15
15
|
*/
|
|
16
16
|
const customLog = Object.assign(createLog("log", "[INFO]"), {
|
|
17
17
|
error: createLog("error", "[ERROR]"),
|
package/dist/utils/color.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/utils/color.ts"],"names":[],"mappings":"AAOA,4DAA4D;AAC5D,QAAA,MAAM,KAAK
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/utils/color.ts"],"names":[],"mappings":"AAOA,4DAA4D;AAC5D,QAAA,MAAM,KAAK;;;;;;CAMD,CAAA;AAEV,4DAA4D;AAC5D,MAAM,MAAM,KAAK,GAAG,MAAM,OAAO,KAAK,CAAA;AAItC;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAItE"}
|
package/dist/utils/color.js
CHANGED
package/dist/utils/color.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../src/utils/color.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4DAA4D;AAC5D,MAAM,KAAK,GAAG;IACZ,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,EAAE;IACV,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,CAAC;CACE,CAAA;AAKV,MAAM,KAAK,GAAG,SAAS,CAAA;AAEvB;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,KAAY;IACjD,OAAO,QAAQ,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,KAAK,EAAE,CAAA;AAC/C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,UAA+B;IAC3D,IAAI,OAAO,OAAO,KAAK,WAAW;QAAE,OAAO,KAAK,CAAA;IAChD,MAAM,MAAM,GAAG,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAA;IACxE,OAAO,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAC/B,CAAC"}
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../src/utils/color.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4DAA4D;AAC5D,MAAM,KAAK,GAAG;IACZ,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,EAAE;IACV,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE,EAAE,uCAAuC;IACjD,GAAG,EAAE,CAAC;CACE,CAAA;AAKV,MAAM,KAAK,GAAG,SAAS,CAAA;AAEvB;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,KAAY;IACjD,OAAO,QAAQ,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,KAAK,EAAE,CAAA;AAC/C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,UAA+B;IAC3D,IAAI,OAAO,OAAO,KAAK,WAAW;QAAE,OAAO,KAAK,CAAA;IAChD,MAAM,MAAM,GAAG,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAA;IACxE,OAAO,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAC/B,CAAC"}
|
|
@@ -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;
|
|
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;AA6BjD;;;;;;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,CAmB9B"}
|
package/dist/utils/createLog.js
CHANGED
|
@@ -17,9 +17,10 @@ const TAG_COLOR = {
|
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* Renders a caller as a `(file:line)` location. When the terminal supports
|
|
20
|
-
* OSC-8 hyperlinks, the location is a clickable link to the
|
|
21
|
-
* otherwise it's plain text. Pure (no
|
|
22
|
-
*
|
|
20
|
+
* OSC-8 hyperlinks, the location is a clickable link to the source file while
|
|
21
|
+
* the line stays visible in the label; otherwise it's plain text. Pure (no
|
|
22
|
+
* stack access), so it can be called from a helper without disturbing
|
|
23
|
+
* {@link getCaller}'s frame depth.
|
|
23
24
|
*/
|
|
24
25
|
function formatLocation(caller, streamName) {
|
|
25
26
|
if (caller.file !== null &&
|
|
@@ -42,13 +43,16 @@ export default function createLog(channel, tag) {
|
|
|
42
43
|
return;
|
|
43
44
|
const caller = getCaller();
|
|
44
45
|
const location = formatLocation(caller, streamName);
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
// On a real terminal: color the level tag and the `└──` connector (same
|
|
47
|
+
// color), and dim the location to gray. The timestamp stays plain.
|
|
48
|
+
const useColor = supportsColor(streamName);
|
|
49
|
+
const color = TAG_COLOR[channel];
|
|
50
|
+
const tagOut = useColor ? colorize(tag, color) : tag;
|
|
51
|
+
const locOut = useColor ? colorize(`(${location})`, "gray") : `(${location})`;
|
|
52
|
+
const connector = useColor ? colorize("└──", color) : "└──";
|
|
53
|
+
// `\n` + connector puts the message on its own line under a tree branch;
|
|
54
|
+
// console's separator space sits between the connector and the message.
|
|
55
|
+
console[channel](tagOut, getTimeStamp(), locOut, `\n${connector}`, ...args, `\n`);
|
|
52
56
|
};
|
|
53
57
|
}
|
|
54
58
|
//# 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
|
|
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;;;;;;GAMG;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,SAAS,EAAE,CAAA;QAC1B,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;QAEnD,wEAAwE;QACxE,mEAAmE;QACnE,MAAM,QAAQ,GAAG,aAAa,CAAC,UAAU,CAAC,CAAA;QAC1C,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;QAChC,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;QACpD,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAA;QAC7E,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QAE3D,yEAAyE;QACzE,wEAAwE;QACxE,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,EAAE,GAAG,IAAI,EAAE,IAAI,CAAC,CAAA;IACnF,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Returns local time as an ISO date plus a readable AM/PM time and timezone,
|
|
3
|
+
* e.g. `2026-05-29 04:00:00 PM GMT+6`. The date and time are both local, so they
|
|
4
|
+
* stay consistent.
|
|
5
|
+
*/
|
|
6
|
+
export default function getTimeStamp(date?: Date): string;
|
|
3
7
|
//# sourceMappingURL=getTimeStamp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTimeStamp.d.ts","sourceRoot":"","sources":["../../src/utils/getTimeStamp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getTimeStamp.d.ts","sourceRoot":"","sources":["../../src/utils/getTimeStamp.ts"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,IAAI,OAAa,GAAG,MAAM,CAG9D"}
|
|
@@ -4,8 +4,24 @@
|
|
|
4
4
|
* Copyright (c) 2026 dewan-meadown
|
|
5
5
|
* All rights reserved
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
// Time-only formatter (date is built separately so it stays ISO `YYYY-MM-DD`).
|
|
8
|
+
const TIME_FORMATTER = new Intl.DateTimeFormat("en-US", {
|
|
9
|
+
hour: "2-digit",
|
|
10
|
+
minute: "2-digit",
|
|
11
|
+
second: "2-digit",
|
|
12
|
+
hour12: true,
|
|
13
|
+
timeZoneName: "short",
|
|
14
|
+
});
|
|
15
|
+
function pad(value) {
|
|
16
|
+
return String(value).padStart(2, "0");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns local time as an ISO date plus a readable AM/PM time and timezone,
|
|
20
|
+
* e.g. `2026-05-29 04:00:00 PM GMT+6`. The date and time are both local, so they
|
|
21
|
+
* stay consistent.
|
|
22
|
+
*/
|
|
23
|
+
export default function getTimeStamp(date = new Date()) {
|
|
24
|
+
const datePart = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
25
|
+
return `${datePart} ${TIME_FORMATTER.format(date)}`;
|
|
10
26
|
}
|
|
11
27
|
//# sourceMappingURL=getTimeStamp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTimeStamp.js","sourceRoot":"","sources":["../../src/utils/getTimeStamp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH
|
|
1
|
+
{"version":3,"file":"getTimeStamp.js","sourceRoot":"","sources":["../../src/utils/getTimeStamp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+EAA+E;AAC/E,MAAM,cAAc,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;IACtD,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,IAAI;IACZ,YAAY,EAAE,OAAO;CACtB,CAAC,CAAA;AAEF,SAAS,GAAG,CAAC,KAAa;IACxB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE;IACpD,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAA;IAC3F,OAAO,GAAG,QAAQ,IAAI,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAA;AACrD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meadown/logger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.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",
|