@reliverse/relinka 1.3.8 → 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.
Files changed (54) hide show
  1. package/README.md +197 -71
  2. package/bin/{core-impl/deprecated → deprecated}/components/levels/levels.d.ts +1 -1
  3. package/bin/{core-impl/deprecated → deprecated}/components/modes/basic.d.ts +1 -1
  4. package/bin/{core-impl/deprecated → deprecated}/components/modes/browser.d.ts +1 -1
  5. package/bin/deprecated/components/modes/shared.d.ts +2 -0
  6. package/bin/deprecated/components/modes/shared.js +1 -0
  7. package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/mod.d.ts +1 -1
  8. package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/relinka.d.ts +2 -2
  9. package/bin/{core-impl/deprecated → deprecated}/components/reporters/basic.d.ts +1 -1
  10. package/bin/{core-impl/deprecated → deprecated}/components/reporters/browser.d.ts +1 -1
  11. package/bin/{core-impl/deprecated → deprecated}/components/reporters/fancy.d.ts +2 -2
  12. package/bin/{core-impl/deprecated → deprecated}/components/reporters/fancy.js +1 -3
  13. package/bin/deprecated/impl-old.js +0 -0
  14. package/bin/{core-types.d.ts → deprecated/types.d.ts} +0 -32
  15. package/bin/deprecated/types.js +0 -0
  16. package/bin/impl.d.ts +149 -0
  17. package/bin/impl.js +606 -0
  18. package/bin/main.d.ts +24 -22
  19. package/bin/main.js +24 -21
  20. package/bin/types.d.ts +0 -0
  21. package/bin/types.js +0 -0
  22. package/package.json +41 -6
  23. package/bin/core-impl/deprecated/components/modes/shared.d.ts +0 -2
  24. package/bin/core-impl/deprecated/components/modes/shared.js +0 -4
  25. package/bin/core-impl/deprecated/components/relinka-deprecated/relinka.test.d.ts +0 -1
  26. package/bin/core-impl/deprecated/components/relinka-deprecated/relinka.test.js +0 -57
  27. package/bin/core-impl/impl-mod.d.ts +0 -19
  28. package/bin/core-impl/impl-mod.js +0 -321
  29. /package/bin/{core-impl/deprecated → deprecated}/components/levels/levels.js +0 -0
  30. /package/bin/{core-impl/deprecated → deprecated}/components/modes/basic.js +0 -0
  31. /package/bin/{core-impl/deprecated → deprecated}/components/modes/browser.js +0 -0
  32. /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/logger.d.ts +0 -0
  33. /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/logger.js +0 -0
  34. /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/mod.js +0 -0
  35. /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/relinka.js +0 -0
  36. /package/bin/{core-impl/deprecated → deprecated}/components/reporters/basic.js +0 -0
  37. /package/bin/{core-impl/deprecated → deprecated}/components/reporters/browser.js +0 -0
  38. /package/bin/{core-types.js → deprecated/impl-old.d.ts} +0 -0
  39. /package/bin/{core-impl/deprecated → deprecated}/utils/box.d.ts +0 -0
  40. /package/bin/{core-impl/deprecated → deprecated}/utils/box.js +0 -0
  41. /package/bin/{core-impl/deprecated → deprecated}/utils/deprecatedColors.d.ts +0 -0
  42. /package/bin/{core-impl/deprecated → deprecated}/utils/deprecatedColors.js +0 -0
  43. /package/bin/{core-impl/deprecated → deprecated}/utils/error.d.ts +0 -0
  44. /package/bin/{core-impl/deprecated → deprecated}/utils/error.js +0 -0
  45. /package/bin/{core-impl/deprecated → deprecated}/utils/format.d.ts +0 -0
  46. /package/bin/{core-impl/deprecated → deprecated}/utils/format.js +0 -0
  47. /package/bin/{core-impl/deprecated → deprecated}/utils/log.d.ts +0 -0
  48. /package/bin/{core-impl/deprecated → deprecated}/utils/log.js +0 -0
  49. /package/bin/{core-impl/deprecated → deprecated}/utils/stream.d.ts +0 -0
  50. /package/bin/{core-impl/deprecated → deprecated}/utils/stream.js +0 -0
  51. /package/bin/{core-impl/deprecated → deprecated}/utils/string.d.ts +0 -0
  52. /package/bin/{core-impl/deprecated → deprecated}/utils/string.js +0 -0
  53. /package/bin/{core-impl/deprecated → deprecated}/utils/tree.d.ts +0 -0
  54. /package/bin/{core-impl/deprecated → deprecated}/utils/tree.js +0 -0
package/README.md CHANGED
@@ -1,90 +1,189 @@
1
- # Relinka: Stylish Logging Made Simple
1
+ # Relinka: Logging that Actually Feels Good
2
2
 
3
- [💖 GitHub Sponsors](https://github.com/sponsors/blefnk) • [💬 Discord](https://discord.gg/Pb8uKbwpsJ) • [✨ Repo](https://github.com/reliverse/relinka-logger) • [📦 NPM](https://npmjs.com/@reliverse/relinka) • [📚 Docs](https://docs.reliverse.org)
3
+ [💖 GitHub Sponsors](https://github.com/sponsors/blefnk) • [💬 Discord](https://discord.gg/Pb8uKbwpsJ) • [✨ Repo](https://github.com/reliverse/relinka-logger) • [📦 NPM](https://npmjs.com/@reliverse/relinka)
4
4
 
5
- **@reliverse/relinka** is your next favorite logging library built to make your terminal (and browser consolesoon) output look good, stay clean, and be actually helpful. It’s styled, structured, and smart. Oh, and it works with configs, files, and colors out of the box.
5
+ **@reliverse/relinka** is a modern, minimal logging library that actually *feels* right. It's not just pretty outputit's a system: smart formatting, file-safe logging, runtime config support, and a `fatal` mode built for developers who care about correctness.
6
6
 
7
- ## 🌟 Features
7
+ Whether you're building CLI tools, SDKs, or full-stack apps — Relinka helps you log with intention.
8
8
 
9
- - 🧙 Drop-in replacement for `node:console` and `consola`
10
- - 💬 `relinka` supports: `info`, `warn`, `success`, `error`, `verbose`
11
- - 🎨 Beautiful, color-coded logs in the terminal
12
- - 🧠 Auto-formats messages, objects, and errors
13
- - 📁 Save logs to file (with daily logs, cleanup, and rotation)
14
- - 📦 Use it programmatically or through CLI-compatible tools
15
- - ⚙️ Smart customization via config
16
- - ✨ Extensible and future-proof
9
+ ## Why Relinka
17
10
 
18
- ## 🚀 Getting Started
11
+ - 🧙 Drop-in replacement for `node:console`, `consola`, or your internal logger
12
+ - 💬 Supports: `info`, `warn`, `success`, `error`, `verbose`, `fatal`, `clear`
13
+ - 🎨 Terminal output that *pops*, with automatic color handling
14
+ - 📁 Save logs to file (with daily rotation, cleanup, and max-file limits)
15
+ - 🧠 Structured message formatting (objects, errors, stacks — handled!)
16
+ - ⚙️ Runtime config via `relinka.config.ts` (powered by `reconf`)
17
+ - 🚨 `fatal` logs halt execution and trigger `debugger` in dev
18
+ - 🧩 Sync-first, async, & CLI-friendly thanks to buffer flushing
19
19
 
20
- ### 1. Install
20
+ ## Getting Started
21
+
22
+ ### 2️⃣ Install
21
23
 
22
24
  ```bash
23
25
  bun add @reliverse/relinka
24
26
  ```
25
27
 
26
- And, optionally, install the CLI globally to manage your config:
28
+ ### 2️⃣ Use It
27
29
 
28
- ```bash
29
- bun i -g @reliverse/relinka-cli
30
+ #### Direct Method (Recommended)
31
+
32
+ - Place this **at the START** of your app's main function:
33
+
34
+ ```ts
35
+ await relinkaConfig;
30
36
  ```
31
37
 
32
- ### 2. Basic Usage
38
+ - Place this **at the END** of your app's main function:
33
39
 
34
40
  ```ts
35
- import { relinkaConfig, relinka } from "@reliverse/relinka";
41
+ await relinkaShutdown();
42
+ ```
43
+
44
+ **Usage example**:
45
+
46
+ ```ts
47
+ import {
48
+ relinka,
49
+ relinkaAsync,
50
+ relinkaConfig,
51
+ relinkaShutdown,
52
+ } from "@reliverse/relinka";
36
53
  export async function main() {
37
- await relinkaConfig;
54
+ await relinkaAsync(
55
+ // this automatically loads the config
56
+ "verbose",
57
+ "This ASYNC verbose message can be seen only if verbose=true (in user config)",
58
+ );
59
+ await relinkaConfig; // place this at your main function or just at the top of your entry file
38
60
  relinka(
39
61
  "verbose",
40
- "This message can be seen only if config was loaded AND debug is enabled",
62
+ "This SYNC verbose message can be seen only if verbose=true (in user config) AND config was loaded ",
41
63
  );
64
+ relinka("log", "Hello! 👋");
65
+ relinka("log", "Great to see you here!");
42
66
  relinka("info", "Everything is running smoothly");
43
67
  relinka("warn", "This might be a problem");
44
- relinka("error", "Uh oh, something broke");
45
- relinka("success", "Thanks for using Relinka! 👋");
68
+ relinka(
69
+ "error", // non-fatal issue level can be recovered
70
+ "Uh oh, something broke",
71
+ );
72
+ // relinka(
73
+ // "fatal",
74
+ // "We should never reach this code! This should never happen! (see <anonymous> line)",
75
+ // ); // fatal level throws error and halts execution
76
+ relinka("success", "Thanks for using Relinka!");
77
+ // Make sure to shut down the logger at the end of your program
78
+ // This is important to flush all buffers and close file handles
79
+ await relinkaShutdown();
46
80
  }
47
81
  await main();
48
82
  ```
49
83
 
50
- ## 🧪 Advanced Usage
84
+ #### [🔜 Soon] Singleton Method
85
+
86
+ ```ts
87
+ const logger = initRelinkaInstance();
88
+ logger("info", "Looks great!");
89
+ ```
51
90
 
52
- Want a clean blank line?
91
+ #### [🔜 Soon] Object Method
53
92
 
54
93
  ```ts
55
- relinka("clear", ""); // Acts just like `console.clear()`
56
- relinka("info", ""); // Just prints a blank newline
94
+ await relinkaConfig;
95
+ relinka.info("Looks great!");
57
96
  ```
58
97
 
59
- 🔜 Use the async logger if you want some advanced features (like typing text animation - soon):
98
+ ## Advanced Usage
60
99
 
61
100
  ```ts
101
+ // Clear terminal:
102
+ relinka("clear", "");
103
+ // Blank line:
104
+ relinka("info", "");
105
+ // Async variant:
62
106
  import { relinkaAsync } from "@reliverse/relinka";
63
-
107
+ await relinkaAsync("info", "Logged from async context");
108
+ // Coming soon:
64
109
  await relinkaAsync("info", "Something happened", { animate: true });
65
110
  ```
66
111
 
67
- ## ⚙️ Configuration
112
+ ## Config
68
113
 
69
- Create a `relinka.config.ts` file with a content like:
114
+ Create `relinka.config.ts`:
70
115
 
71
116
  ```ts
72
117
  import { defineConfig } from "@reliverse/relinka";
118
+ /**
119
+ * RELINKA CONFIGURATION FILE
120
+ * - Hover over a field to see the information
121
+ * - Use intellisense to see available options
122
+ * @see https://github.com/reliverse/relinka
123
+ */
73
124
  export default defineConfig({
74
- // Enable debug to see verbose logs
75
- debug: true,
76
- // Show timestamp in each log message
77
- withTimestamp: false,
125
+ // Enable to see verbose logs
126
+ verbose: false,
127
+
128
+ // Timestamp configuration
129
+ timestamp: {
130
+ enabled: false,
131
+ format: "HH:mm:ss",
132
+ },
133
+
78
134
  // Control whether logs are saved to a file
79
135
  saveLogsToFile: true,
136
+
80
137
  // Disable colors in the console
81
138
  disableColors: false,
139
+
82
140
  // Log file path
83
141
  logFilePath: "relinka.log",
142
+
143
+ levels: {
144
+ success: {
145
+ symbol: "✓",
146
+ fallbackSymbol: "[OK]",
147
+ color: "greenBright",
148
+ spacing: 3,
149
+ },
150
+ info: {
151
+ symbol: "i",
152
+ fallbackSymbol: "[i]",
153
+ color: "cyanBright",
154
+ spacing: 3,
155
+ },
156
+ error: {
157
+ symbol: "✖",
158
+ fallbackSymbol: "[ERR]",
159
+ color: "redBright",
160
+ spacing: 3,
161
+ },
162
+ warn: {
163
+ symbol: "⚠",
164
+ fallbackSymbol: "[WARN]",
165
+ color: "yellowBright",
166
+ spacing: 3,
167
+ },
168
+ fatal: {
169
+ symbol: "‼",
170
+ fallbackSymbol: "[FATAL]",
171
+ color: "redBright",
172
+ spacing: 3,
173
+ },
174
+ verbose: {
175
+ symbol: "✧",
176
+ fallbackSymbol: "[VERBOSE]",
177
+ color: "gray",
178
+ spacing: 3,
179
+ },
180
+ log: { symbol: "│", fallbackSymbol: "|", color: "dim", spacing: 3 },
181
+ },
182
+
84
183
  // Directory settings
85
184
  dirs: {
86
185
  dailyLogs: true,
87
- logDir: ".reliverse/logs", // store logs in a custom folder
186
+ logDir: "logs", // store logs in a custom folder
88
187
  maxLogFiles: 5, // keep only the 5 most recent log files
89
188
  specialDirs: {
90
189
  distDirNames: [],
@@ -94,62 +193,89 @@ export default defineConfig({
94
193
  });
95
194
  ```
96
195
 
97
- Supported config file names:
196
+ Supported files:
98
197
 
99
198
  - `relinka.config.ts`
100
- - 🔜 `.relinka.config.js`
101
- - 🔜 `.relinkarc`
102
- - 🔜 or any other supported by c12
199
+ - 🔜 other formats, supported by `reconf`, are coming soon
200
+
201
+ ## Log Files
202
+
203
+ - Default: `logs/relinka.log`
204
+ - Daily mode: `2025-04-11-relinka.log`
205
+ - Auto-cleanup: keep latest N logs
206
+
207
+ ## API Summary
208
+
209
+ ```ts
210
+ relinka("info", "message", optionalDetails);
211
+ relinka("fatal", "something broke"); // throws
212
+ relinka("clear", ""); // clears terminal
213
+
214
+ await relinkaAsync("warn", "something async");
215
+ ```
216
+
217
+ ```ts
218
+ defineConfig({ ... }) // helper for relinka.config.ts
219
+ ```
220
+
221
+ ## Built-in Utilities
222
+
223
+ - ✅ Timestamping
224
+ - ✅ File-safe formatting
225
+ - ✅ Log rotation
226
+ - ✅ Fatal logging (with debugger)
227
+ - ✅ Colorized terminal output
103
228
 
104
- ## 📁 Log Files
229
+ ## FAQ
105
230
 
106
- - Stored in `.reliverse/logs/` by default
107
- - Filename: `relinka.log` or `YYYY-MM-DD-relinka.log` if daily logs are enabled
108
- - Auto-rotates based on `maxLogFiles`
231
+ ### Why `relinka.config.ts` doesn't works for me?
109
232
 
110
- ## 📚 API Summary
233
+ You forget to load user's config by using `await relinkaConfig;` **at the START** of your app's main function.
111
234
 
112
- ### relinka(level, message, ...args)
235
+ ### Why my terminal stucks after last relinka() usage?
113
236
 
114
- Logs synchronously. Skips debug logs if `debug: false`.
237
+ You forget to flush the buffer. Place `await relinkaShutdown();` **at the END** of your app's main function.
115
238
 
116
- ### relinkaAsync(level, message, ...args)
239
+ ### Why does TS linter tells that something wrong with `relinka("info", args)`?
117
240
 
118
- Async logger that waits for config automatically, and provides some additional advanced features.
241
+ Add empty string: `relinka("info", "", args)`
119
242
 
120
- ### defineConfig(config)
243
+ ### Does `fatal` throw?
121
244
 
122
- Helper to define typed config in `relinka.config.ts`
245
+ Yes, always. It will halt execution and trigger `debugger` in dev mode.
123
246
 
124
- ## 🧰 Utilities
247
+ ### What's coming next?
125
248
 
126
- Timestamping
127
- Log file rotation
128
- ✅ File-safe formatting
129
- ANSI color support
130
- Error object handling
249
+ - Relinka is designed to be used in the different ways:
250
+ - Use `relinka(level, message, ...args)` (recommended).
251
+ - 🔜 Or, just `relinka.level(message, ...args)`
252
+ - 🔜 Both designed to work with both sync (default) and async/await.
253
+ - 🔜 Both designed to work with both direct and wrapper methods.
254
+ - 🔜 Use the async logger if you want some advanced features (like typing text streaming animation).
131
255
 
132
- ## 💡 Tips
256
+ ## Tips
133
257
 
134
- - Want `@ts-expect-error` auto-injection? Check out [`@reliverse/reinject`](https://npmjs.com/@reliverse/reinject).
135
- - Using this in a CLI tool? Combine with [`@reliverse/prompts`](https://npmjs.com/@reliverse/prompts).
258
+ - Building CLIs? Use with [`@reliverse/prompts`](https://npmjs.com/@reliverse/prompts)
259
+ - Want type-safe injections? Try [`@reliverse/reinject`](https://npmjs.com/@reliverse/reinject)
260
+ - For advanced bundling? Pair with [`@reliverse/relidler`](https://npmjs.com/@reliverse/relidler)
136
261
 
137
- ## ✅ TODO
262
+ ## Roadmap
138
263
 
139
- - [x] File-based logging
140
- - [x] Timestamp support
264
+ - [x] File logging
265
+ - [x] Timestamps
141
266
  - [x] Daily logs
142
- - [x] Smart config
143
267
  - [x] Log rotation
144
- - [ ] CLI interface (optional)
145
- - [ ] Plugin support (custom formatters, log levels, etc)
268
+ - [x] `fatal` type
269
+ - [x] Runtime config
270
+ - [ ] CLI interface (to manage logs, config, etc.)
271
+ - [ ] Plugin support (custom formatters, hooks)
146
272
 
147
- ## 🙌 Shoutout
273
+ ## Thanks
148
274
 
149
- Relinka was inspired by this gem:
275
+ Relinka's DX design was inspired by this gem:
150
276
 
151
- - [unjs/consola](https://github.com/unjs/consola#readme)
277
+ - [unjs/consola](https://github.com/unjs/consola)
152
278
 
153
- ## 📄 License
279
+ ## License
154
280
 
155
- 💖 MIT © [blefnk (Nazar Kornienko)](https://github.com/blefnk)
281
+ 💖 MIT © 2025 [blefnk Nazar Kornienko](https://github.com/blefnk)
@@ -1,4 +1,4 @@
1
- import type { LogObject, LogTypeDeprecated } from "../../../../core-types.js";
1
+ import type { LogObject, LogTypeDeprecated } from "../../types.js";
2
2
  /**
3
3
  * A mapping of `LogTypeDeprecated` to its corresponding numeric log level.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import type { RelinkaInstanceDeprecated } from "../relinka-deprecated/relinka.js";
2
- import type { RelinkaOptionsDeprecated } from "../../../../core-types.js";
2
+ import type { RelinkaOptionsDeprecated } from "../../types.js";
3
3
  export * from "./shared.js";
4
4
  /**
5
5
  * Factory function to create a new Relinka instance
@@ -1,4 +1,4 @@
1
- import type { RelinkaOptionsDeprecated } from "../../../../core-types.js";
1
+ import type { RelinkaOptionsDeprecated } from "../../types.js";
2
2
  import { type RelinkaInstanceDeprecated } from "../relinka-deprecated/relinka.js";
3
3
  export * from "./shared.js";
4
4
  /**
@@ -0,0 +1,2 @@
1
+ export { LogTypesDeprecated } from "../levels/levels.js";
2
+ export type * from "../../types.js";
@@ -0,0 +1 @@
1
+ export { LogTypesDeprecated } from "../levels/levels.js";
@@ -1,4 +1,4 @@
1
- import type { RelinkaOptionsDeprecated } from "../../../../core-types.js";
1
+ import type { RelinkaOptionsDeprecated } from "../../types.js";
2
2
  import type { RelinkaInstanceDeprecated } from "./relinka.js";
3
3
  export * from "../modes/shared.js";
4
4
  /**
@@ -1,5 +1,5 @@
1
- import type { LogTypeDeprecated } from "../../../../core-types.js";
2
- import type { InputLogObject, LogObject, RelinkaOptionsDeprecated, RelinkaReporterDeprecated } from "../../../../core-types.js";
1
+ import type { LogTypeDeprecated } from "../../types.js";
2
+ import type { InputLogObject, LogObject, RelinkaOptionsDeprecated, RelinkaReporterDeprecated } from "../../types.js";
3
3
  /**
4
4
  * Relinka class for logging management with support for pause/resume, mocking and customizable reporting.
5
5
  * Provides flexible logging capabilities including level-based logging, custom reporters and integration options.
@@ -1,4 +1,4 @@
1
- import type { LogObject, RelinkaReporterDeprecated, FormatOptions, RelinkaOptionsDeprecated } from "../../../../core-types.js";
1
+ import type { LogObject, RelinkaReporterDeprecated, FormatOptions, RelinkaOptionsDeprecated } from "../../types.js";
2
2
  export declare class BasicReporter implements RelinkaReporterDeprecated {
3
3
  formatStack(stack: string): string;
4
4
  formatArgs(args: any[], opts: FormatOptions): string;
@@ -1,4 +1,4 @@
1
- import type { LogObject } from "../../../../core-types.js";
1
+ import type { LogObject } from "../../types.js";
2
2
  export declare class BrowserReporter {
3
3
  options: any;
4
4
  defaultColor: string;
@@ -1,5 +1,5 @@
1
- import type { LogLevelDeprecated, LogTypeDeprecated } from "../../../../core-types.js";
2
- import type { FormatOptions, LogObject } from "../../../../core-types.js";
1
+ import type { LogLevelDeprecated, LogTypeDeprecated } from "../../types.js";
2
+ import type { FormatOptions, LogObject } from "../../types.js";
3
3
  import { BasicReporter } from "./basic.js";
4
4
  export declare const TYPE_COLOR_MAP: Partial<Record<LogTypeDeprecated, string>>;
5
5
  export declare const LEVEL_COLOR_MAP: Partial<Record<LogLevelDeprecated, string>>;
@@ -1,9 +1,7 @@
1
1
  import { isUnicodeSupported } from "@reliverse/runtime";
2
2
  import stringWidth from "string-width";
3
3
  import { BasicReporter } from "./basic.js";
4
- import {
5
- box
6
- } from "../../utils/box.js";
4
+ import { box } from "../../utils/box.js";
7
5
  import { colors } from "../../utils/deprecatedColors.js";
8
6
  import { parseStack } from "../../utils/error.js";
9
7
  import { stripAnsi } from "../../utils/string.js";
File without changes
@@ -1,35 +1,3 @@
1
- /** Configuration for special directory handling. */
2
- export type RelinkaSpecialDirsConfig = {
3
- distDirNames?: string[];
4
- useParentConfigInDist?: boolean;
5
- };
6
- /** Configuration for directory-related settings. */
7
- export type RelinkaDirsConfig = {
8
- dailyLogs?: boolean;
9
- logDir?: string;
10
- maxLogFiles?: number;
11
- specialDirs?: RelinkaSpecialDirsConfig;
12
- };
13
- /**
14
- * Configuration options for the Relinka logger.
15
- * All properties are optional to allow for partial configuration.
16
- * Defaults will be applied during initialization.
17
- */
18
- export type RelinkaConfig = {
19
- debug?: boolean;
20
- dirs?: RelinkaDirsConfig;
21
- disableColors?: boolean;
22
- logFilePath?: string;
23
- saveLogsToFile?: boolean;
24
- withTimestamp?: boolean;
25
- };
26
- /** Represents information about a log file for cleanup purposes. */
27
- export type LogFileInfo = {
28
- path: string;
29
- mtime: number;
30
- };
31
- /** Log level types used by the logger. */
32
- export type LogLevel = "error" | "info" | "success" | "verbose" | "warn";
33
1
  /**
34
2
  * Defines the level of logs as specific numbers or special number types.
35
3
  *
File without changes
package/bin/impl.d.ts ADDED
@@ -0,0 +1,149 @@
1
+ import type { DefaultColorKeys } from "@reliverse/relico";
2
+ /** Configuration for special directory handling. */
3
+ export type RelinkaSpecialDirsConfig = {
4
+ distDirNames?: string[];
5
+ useParentConfigInDist?: boolean;
6
+ };
7
+ /** Configuration for directory-related settings. */
8
+ export type RelinkaDirsConfig = {
9
+ dailyLogs?: boolean;
10
+ logDir?: string;
11
+ maxLogFiles?: number;
12
+ specialDirs?: RelinkaSpecialDirsConfig;
13
+ };
14
+ /** Configuration for a single log level. */
15
+ export type LogLevelConfig = {
16
+ /**
17
+ * Symbol to display for this log level.
18
+ * @see https://symbl.cc
19
+ */
20
+ symbol: string;
21
+ /**
22
+ * Fallback symbol to use if Unicode is not supported.
23
+ */
24
+ fallbackSymbol: string;
25
+ /**
26
+ * Color to use for this log level.
27
+ */
28
+ color: DefaultColorKeys;
29
+ /**
30
+ * Number of spaces after the symbol/fallback
31
+ */
32
+ spacing?: number;
33
+ };
34
+ /** Configuration for all log levels. */
35
+ export type LogLevelsConfig = Partial<Record<LogLevel, LogLevelConfig>>;
36
+ /** Log level types used by the logger. */
37
+ export type LogLevel = "error" | "fatal" | "info" | "success" | "verbose" | "warn" | "log";
38
+ /**
39
+ * Configuration options for the Relinka logger.
40
+ * All properties are optional to allow for partial configuration.
41
+ * Defaults will be applied during initialization.
42
+ */
43
+ export type RelinkaConfig = {
44
+ /**
45
+ * Enables verbose (aka debug) mode for detailed logging.
46
+ *
47
+ * `true` here works only for end-users of CLIs/libs when theirs developers
48
+ * has been awaited for user's config via `@reliverse/relinka`'s `await relinkaConfig;`
49
+ */
50
+ verbose?: boolean;
51
+ /**
52
+ * Configuration for directory-related settings.
53
+ * - `dailyLogs`: If true, logs will be stored in a daily subdirectory.
54
+ * - `logDir`: The base directory for logs.
55
+ * - `maxLogFiles`: The maximum number of log files to keep before cleanup.
56
+ * - `specialDirs`: Configuration for special directory handling.
57
+ * - `distDirNames`: An array of directory names to check for special handling.
58
+ * - `useParentConfigInDist`: If true, use the parent config in dist directories.
59
+ */
60
+ dirs?: RelinkaDirsConfig;
61
+ /**
62
+ * Disables color output in the console.
63
+ */
64
+ disableColors?: boolean;
65
+ /**
66
+ * Path to the log file.
67
+ */
68
+ logFilePath?: string;
69
+ /**
70
+ * If true, logs will be saved to a file.
71
+ */
72
+ saveLogsToFile?: boolean;
73
+ /**
74
+ * Configuration for timestamp in log messages.
75
+ */
76
+ timestamp?: {
77
+ /**
78
+ * If true, timestamps will be added to log messages.
79
+ */
80
+ enabled: boolean;
81
+ /**
82
+ * The format for timestamps. Default is YYYY-MM-DD HH:mm:ss.SSS
83
+ */
84
+ format?: string;
85
+ };
86
+ /**
87
+ * Allows to customize the log levels.
88
+ */
89
+ levels?: LogLevelsConfig;
90
+ /**
91
+ * Controls how often the log cleanup runs (in milliseconds)
92
+ * Default: 10000 (10 seconds)
93
+ */
94
+ cleanupInterval?: number;
95
+ /**
96
+ * Maximum size of the log write buffer before flushing to disk (in bytes)
97
+ * Default: 4096 (4KB)
98
+ */
99
+ bufferSize?: number;
100
+ /**
101
+ * Maximum time to hold logs in buffer before flushing to disk (in milliseconds)
102
+ * Default: 5000 (5 seconds)
103
+ */
104
+ maxBufferAge?: number;
105
+ };
106
+ /** Represents information about a log file for cleanup purposes. */
107
+ export type LogFileInfo = {
108
+ path: string;
109
+ mtime: number;
110
+ };
111
+ /**
112
+ * Promise that resolves once `reconf` loads and merges the config.
113
+ */
114
+ export declare const relinkaConfig: Promise<RelinkaConfig>;
115
+ /**
116
+ * Shuts down the logger, flushing all buffers and clearing timers.
117
+ * As Relinka user - call this at the end of your program to prevent hanging.
118
+ */
119
+ export declare function relinkaShutdown(): Promise<void>;
120
+ /**
121
+ * Flushes all log buffers to disk. Used before process exit or on demand.
122
+ */
123
+ export declare function flushAllLogBuffers(): Promise<void>;
124
+ /**
125
+ * If something truly impossible happened, log + throw.
126
+ */
127
+ export declare function shouldNeverHappen(message: string, ...args: unknown[]): never;
128
+ /**
129
+ * Truncates a string to a specified length, adding "…" if truncated.
130
+ */
131
+ export declare function truncateString(msg: string, maxLength?: number): string;
132
+ /**
133
+ * Exhaustiveness check. If we land here, we missed a union case.
134
+ */
135
+ export declare function casesHandled(unexpectedCase: never): never;
136
+ /**
137
+ * Logs a message synchronously using the current config.
138
+ * If type === "fatal", logs a fatal error and throws (never returns).
139
+ */
140
+ export declare function relinka(type: LogLevel | "clear", message: string, ...args: unknown[]): undefined | never;
141
+ /**
142
+ * Logs a message asynchronously, waiting for the config to be fully loaded.
143
+ * If type === "fatal", logs a fatal error and throws (never returns).
144
+ */
145
+ export declare function relinkaAsync(type: LogLevel, message: string, ...args: unknown[]): Promise<void>;
146
+ /**
147
+ * Type helper for user config files.
148
+ */
149
+ export declare function defineConfig(config: Partial<RelinkaConfig>): Partial<RelinkaConfig>;