@meadown/logger 1.5.1 → 1.6.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 CHANGED
@@ -24,13 +24,13 @@ yarn add @meadown/logger
24
24
  ## Using it
25
25
 
26
26
  ```ts
27
- import customLog from "@meadown/logger"
27
+ import logger from "@meadown/logger"
28
28
 
29
- customLog("Hello world")
30
- customLog("Auth", "user logged in") // every argument is printed as-is, like console.log
29
+ logger("Hello world")
30
+ logger("Auth", "user logged in") // every argument is printed as-is, like console.log
31
31
 
32
- customLog.warn("This is deprecated")
33
- customLog.error("Something went wrong")
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 customLog } from "@meadown/logger"
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 customLog = (...args) => log(...args)
61
+ export const logger = (...args) => log(...args)
62
62
  ```
63
63
 
64
64
  ## Color-coded levels
@@ -91,14 +91,26 @@ 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 customLog from "@meadown/logger"
94
+ import logger from "@meadown/logger"
95
95
 
96
- customLog.maxLines = 5 // show the first 5 lines, then "... N more lines"
97
- customLog.maxLines = 0 // back to the default — show everything
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 `customLog`, `.error`, and `.warn` alike.
101
+ applies to `logger`, `.error`, and `.warn` alike.
102
+
103
+ ## Deprecated alias
104
+
105
+ Older examples used `customLog`. That name still works as a named export for now,
106
+ but it is deprecated and new code should use `logger`:
107
+
108
+ ```ts
109
+ import logger, { customLog } from "@meadown/logger"
110
+
111
+ logger("new code")
112
+ customLog("old code still works") // deprecated
113
+ ```
102
114
 
103
115
  ## What about production?
104
116
 
@@ -9,6 +9,21 @@ export interface LogFN {
9
9
  */
10
10
  maxLines: number;
11
11
  }
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
+ /**
24
+ * @deprecated Use {@link logger} instead. This alias remains for compatibility
25
+ * with older examples and will be removed in a future major version.
26
+ */
12
27
  declare const customLog: LogFN;
13
- export { customLog };
14
- export default customLog;
28
+ export { customLog, logger };
29
+ 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.customLog = void 0;
9
+ exports.logger = 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
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
- * customLog("Auth", "user logged in")
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
- * customLog.maxLines = 5 // long messages collapse to 5 lines; 0 = show all
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,10 @@ Object.defineProperty(logger, "maxLines", {
30
31
  enumerable: true,
31
32
  configurable: true,
32
33
  });
34
+ /**
35
+ * @deprecated Use {@link logger} instead. This alias remains for compatibility
36
+ * with older examples and will be removed in a future major version.
37
+ */
33
38
  const customLog = logger;
34
39
  exports.customLog = customLog;
35
- exports.default = customLog;
40
+ exports.default = logger;
package/dist/index.d.ts CHANGED
@@ -9,7 +9,22 @@ export interface LogFN {
9
9
  */
10
10
  maxLines: number;
11
11
  }
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
+ /**
24
+ * @deprecated Use {@link logger} instead. This alias remains for compatibility
25
+ * with older examples and will be removed in a future major version.
26
+ */
12
27
  declare const customLog: LogFN;
13
- export { customLog };
14
- export default customLog;
28
+ export { customLog, logger };
29
+ export default logger;
15
30
  //# sourceMappingURL=index.d.ts.map
@@ -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;AA0BD,QAAA,MAAM,SAAS,EAAa,KAAK,CAAA;AAEjC,OAAO,EAAE,SAAS,EAAE,CAAA;AACpB,eAAe,SAAS,CAAA"}
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;;;GAGG;AACH,QAAA,MAAM,SAAS,OAAS,CAAA;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,CAAA;AAC5B,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
- * customLog("Auth", "user logged in")
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
- * customLog.maxLines = 5 // long messages collapse to 5 lines; 0 = show all
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,11 @@ Object.defineProperty(logger, "maxLines", {
27
27
  enumerable: true,
28
28
  configurable: true,
29
29
  });
30
+ /**
31
+ * @deprecated Use {@link logger} instead. This alias remains for compatibility
32
+ * with older examples and will be removed in a future major version.
33
+ */
30
34
  const customLog = logger;
31
- export { customLog };
32
- export default customLog;
35
+ export { customLog, logger };
36
+ export default logger;
33
37
  //# 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,CAAC,CAAA;AAEF,+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,MAAM,SAAS,GAAG,MAAe,CAAA;AAEjC,OAAO,EAAE,SAAS,EAAE,CAAA;AACpB,eAAe,SAAS,CAAA"}
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;;;GAGG;AACH,MAAM,SAAS,GAAG,MAAM,CAAA;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,CAAA;AAC5B,eAAe,MAAM,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meadown/logger",
3
- "version": "1.5.1",
3
+ "version": "1.6.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",