@reliverse/relinka 1.3.8 → 1.4.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.
Files changed (57) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +206 -70
  3. package/bin/{core-impl/deprecated → deprecated}/components/levels/levels.d.ts +1 -1
  4. package/bin/{core-impl/deprecated → deprecated}/components/modes/basic.d.ts +1 -1
  5. package/bin/{core-impl/deprecated → deprecated}/components/modes/browser.d.ts +1 -1
  6. package/bin/deprecated/components/modes/shared.d.ts +2 -0
  7. package/bin/deprecated/components/modes/shared.js +1 -0
  8. package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/mod.d.ts +1 -1
  9. package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/relinka.d.ts +2 -2
  10. package/bin/{core-impl/deprecated → deprecated}/components/reporters/basic.d.ts +1 -1
  11. package/bin/{core-impl/deprecated → deprecated}/components/reporters/browser.d.ts +1 -1
  12. package/bin/{core-impl/deprecated → deprecated}/components/reporters/fancy.d.ts +2 -2
  13. package/bin/{core-impl/deprecated → deprecated}/components/reporters/fancy.js +1 -3
  14. package/bin/deprecated/impl-old.js +0 -0
  15. package/bin/{core-types.d.ts → deprecated/types.d.ts} +0 -32
  16. package/bin/deprecated/types.js +0 -0
  17. package/bin/deprecated/utils/format-new.d.ts +15 -0
  18. package/bin/deprecated/utils/format-new.js +13 -0
  19. package/bin/{core-impl/deprecated → deprecated}/utils/format.d.ts +2 -2
  20. package/bin/{core-impl/deprecated → deprecated}/utils/format.js +4 -4
  21. package/bin/impl.d.ts +147 -0
  22. package/bin/impl.js +600 -0
  23. package/bin/main.d.ts +24 -22
  24. package/bin/main.js +26 -23
  25. package/bin/types.d.ts +0 -0
  26. package/bin/types.js +0 -0
  27. package/package.json +43 -7
  28. package/bin/core-impl/deprecated/components/modes/shared.d.ts +0 -2
  29. package/bin/core-impl/deprecated/components/modes/shared.js +0 -4
  30. package/bin/core-impl/deprecated/components/relinka-deprecated/relinka.test.d.ts +0 -1
  31. package/bin/core-impl/deprecated/components/relinka-deprecated/relinka.test.js +0 -57
  32. package/bin/core-impl/impl-mod.d.ts +0 -19
  33. package/bin/core-impl/impl-mod.js +0 -321
  34. /package/bin/{core-impl/deprecated → deprecated}/components/levels/levels.js +0 -0
  35. /package/bin/{core-impl/deprecated → deprecated}/components/modes/basic.js +0 -0
  36. /package/bin/{core-impl/deprecated → deprecated}/components/modes/browser.js +0 -0
  37. /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/logger.d.ts +0 -0
  38. /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/logger.js +0 -0
  39. /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/mod.js +0 -0
  40. /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/relinka.js +0 -0
  41. /package/bin/{core-impl/deprecated → deprecated}/components/reporters/basic.js +0 -0
  42. /package/bin/{core-impl/deprecated → deprecated}/components/reporters/browser.js +0 -0
  43. /package/bin/{core-types.js → deprecated/impl-old.d.ts} +0 -0
  44. /package/bin/{core-impl/deprecated → deprecated}/utils/box.d.ts +0 -0
  45. /package/bin/{core-impl/deprecated → deprecated}/utils/box.js +0 -0
  46. /package/bin/{core-impl/deprecated → deprecated}/utils/deprecatedColors.d.ts +0 -0
  47. /package/bin/{core-impl/deprecated → deprecated}/utils/deprecatedColors.js +0 -0
  48. /package/bin/{core-impl/deprecated → deprecated}/utils/error.d.ts +0 -0
  49. /package/bin/{core-impl/deprecated → deprecated}/utils/error.js +0 -0
  50. /package/bin/{core-impl/deprecated → deprecated}/utils/log.d.ts +0 -0
  51. /package/bin/{core-impl/deprecated → deprecated}/utils/log.js +0 -0
  52. /package/bin/{core-impl/deprecated → deprecated}/utils/stream.d.ts +0 -0
  53. /package/bin/{core-impl/deprecated → deprecated}/utils/stream.js +0 -0
  54. /package/bin/{core-impl/deprecated → deprecated}/utils/string.d.ts +0 -0
  55. /package/bin/{core-impl/deprecated → deprecated}/utils/string.js +0 -0
  56. /package/bin/{core-impl/deprecated → deprecated}/utils/tree.d.ts +0 -0
  57. /package/bin/{core-impl/deprecated → deprecated}/utils/tree.js +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2025 blefnk Nazar Kornienko
3
+ Copyright (c) 2025 Nazar Kornienko (blefnk), Reliverse
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,21 +1,21 @@
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. Whether you're building CLI tools, SDKs, or full-stack apps Relinka helps you log with intention.
6
6
 
7
- ## 🌟 Features
7
+ ## Why Relinka
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
+ - 🧙 Drop-in replacement for `node:console`, `consola`, or your internal logger
10
+ - 💬 Supports: `info`, `warn`, `success`, `error`, `verbose`, `fatal`, `clear`
11
+ - 🎨 Terminal output that *pops*, with automatic color handling
12
+ - 📁 Save logs to file (with daily rotation, cleanup, and max-file limits)
13
+ - 🧠 Structured message formatting (objects, errors, stacks — handled!)
14
+ - ⚙️ Runtime config via `relinka.config.ts` (powered by `reconf`)
15
+ - 🚨 `fatal` logs halt execution and trigger `debugger` in dev
16
+ - 🧩 Sync-first, async, & CLI-friendly thanks to buffer flushing
17
17
 
18
- ## 🚀 Getting Started
18
+ ## Getting Started
19
19
 
20
20
  ### 1. Install
21
21
 
@@ -23,68 +23,173 @@
23
23
  bun add @reliverse/relinka
24
24
  ```
25
25
 
26
- And, optionally, install the CLI globally to manage your config:
26
+ ### 2. Use It
27
27
 
28
- ```bash
29
- bun i -g @reliverse/relinka-cli
28
+ #### Direct Method (Recommended)
29
+
30
+ - Place this **at the START** of your app's main function:
31
+
32
+ ```ts
33
+ await relinkaConfig;
30
34
  ```
31
35
 
32
- ### 2. Basic Usage
36
+ - Place this **at the END** of your app's main function:
33
37
 
34
38
  ```ts
35
- import { relinkaConfig, relinka } from "@reliverse/relinka";
39
+ await relinkaShutdown();
40
+ ```
41
+
42
+ **Usage example**:
43
+
44
+ ```ts
45
+ import {
46
+ relinka,
47
+ relinkaAsync,
48
+ relinkaConfig,
49
+ relinkaShutdown,
50
+ } from "@reliverse/relinka";
51
+
36
52
  export async function main() {
37
- await relinkaConfig;
53
+ await relinkaAsync(
54
+ // this automatically loads the config
55
+ "verbose",
56
+ "This ASYNC verbose message can be seen only if verbose=true (in user config)",
57
+ );
58
+ await relinkaConfig; // place this at your main function or just at the top of your entry file
38
59
  relinka(
39
60
  "verbose",
40
- "This message can be seen only if config was loaded AND debug is enabled",
61
+ "This SYNC verbose message can be seen only if verbose=true (in user config) AND config was loaded ",
41
62
  );
63
+ relinka("log", "Hello! 👋");
64
+ relinka("log", "Great to see you here!");
42
65
  relinka("info", "Everything is running smoothly");
43
66
  relinka("warn", "This might be a problem");
44
- relinka("error", "Uh oh, something broke");
45
- relinka("success", "Thanks for using Relinka! 👋");
67
+ relinka(
68
+ "error", // non-fatal issue level can be recovered
69
+ "Uh oh, something broke",
70
+ );
71
+ // relinka(
72
+ // "fatal",
73
+ // "We should never reach this code! This should never happen! (see <anonymous> line)",
74
+ // ); // fatal level throws error and halts execution
75
+ relinka("success", "Thanks for using Relinka!");
76
+
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();
80
+
81
+ // Make sure to exit the program after your CLI is done
82
+ // It's not required for Bun-only apps, but recommended
83
+ // for other runtimes, esp. for Node.js (incl. `tsx`)
84
+ process.exit(0);
46
85
  }
86
+
47
87
  await main();
48
88
  ```
49
89
 
50
- ## 🧪 Advanced Usage
90
+ #### [🔜 Soon] Singleton Method
91
+
92
+ ```ts
93
+ const logger = initRelinkaInstance({/* per-project config */});
94
+ logger("info", "Looks great!");
95
+ ```
51
96
 
52
- Want a clean blank line?
97
+ #### [🔜 Soon] Object Method
53
98
 
54
99
  ```ts
55
- relinka("clear", ""); // Acts just like `console.clear()`
56
- relinka("info", ""); // Just prints a blank newline
100
+ await relinkaConfig;
101
+ relinka.info("Looks great!");
57
102
  ```
58
103
 
59
- 🔜 Use the async logger if you want some advanced features (like typing text animation - soon):
104
+ ## Advanced Usage
60
105
 
61
106
  ```ts
107
+ // Clear terminal:
108
+ relinka("clear", "");
109
+ // Blank line:
110
+ relinka("info", "");
111
+ // Async variant:
62
112
  import { relinkaAsync } from "@reliverse/relinka";
63
-
113
+ await relinkaAsync("info", "Logged from async context");
114
+ // Coming soon:
64
115
  await relinkaAsync("info", "Something happened", { animate: true });
65
116
  ```
66
117
 
67
- ## ⚙️ Configuration
118
+ ## Config
68
119
 
69
- Create a `relinka.config.ts` file with a content like:
120
+ Create `relinka.config.ts`:
70
121
 
71
122
  ```ts
72
123
  import { defineConfig } from "@reliverse/relinka";
124
+ /**
125
+ * RELINKA CONFIGURATION FILE
126
+ * - Hover over a field to see the information
127
+ * - Use intellisense to see available options
128
+ * @see https://github.com/reliverse/relinka
129
+ */
73
130
  export default defineConfig({
74
- // Enable debug to see verbose logs
75
- debug: true,
76
- // Show timestamp in each log message
77
- withTimestamp: false,
131
+ // Enable to see verbose logs
132
+ verbose: false,
133
+
134
+ // Timestamp configuration
135
+ timestamp: {
136
+ enabled: false,
137
+ format: "HH:mm:ss",
138
+ },
139
+
78
140
  // Control whether logs are saved to a file
79
141
  saveLogsToFile: true,
142
+
80
143
  // Disable colors in the console
81
144
  disableColors: false,
145
+
82
146
  // Log file path
83
147
  logFilePath: "relinka.log",
148
+
149
+ levels: {
150
+ success: {
151
+ symbol: "✓",
152
+ fallbackSymbol: "[OK]",
153
+ color: "greenBright",
154
+ spacing: 3,
155
+ },
156
+ info: {
157
+ symbol: "i",
158
+ fallbackSymbol: "[i]",
159
+ color: "cyanBright",
160
+ spacing: 3,
161
+ },
162
+ error: {
163
+ symbol: "✖",
164
+ fallbackSymbol: "[ERR]",
165
+ color: "redBright",
166
+ spacing: 3,
167
+ },
168
+ warn: {
169
+ symbol: "⚠",
170
+ fallbackSymbol: "[WARN]",
171
+ color: "yellowBright",
172
+ spacing: 3,
173
+ },
174
+ fatal: {
175
+ symbol: "‼",
176
+ fallbackSymbol: "[FATAL]",
177
+ color: "redBright",
178
+ spacing: 3,
179
+ },
180
+ verbose: {
181
+ symbol: "✧",
182
+ fallbackSymbol: "[VERBOSE]",
183
+ color: "gray",
184
+ spacing: 3,
185
+ },
186
+ log: { symbol: "│", fallbackSymbol: "|", color: "dim", spacing: 3 },
187
+ },
188
+
84
189
  // Directory settings
85
190
  dirs: {
86
191
  dailyLogs: true,
87
- logDir: ".reliverse/logs", // store logs in a custom folder
192
+ logDir: "logs", // store logs in a custom folder
88
193
  maxLogFiles: 5, // keep only the 5 most recent log files
89
194
  specialDirs: {
90
195
  distDirNames: [],
@@ -94,62 +199,93 @@ export default defineConfig({
94
199
  });
95
200
  ```
96
201
 
97
- Supported config file names:
202
+ Supported files:
98
203
 
99
204
  - `relinka.config.ts`
100
- - 🔜 `.relinka.config.js`
101
- - 🔜 `.relinkarc`
102
- - 🔜 or any other supported by c12
205
+ - 🔜 other formats, supported by `reconf`, are coming soon
206
+
207
+ ## Log Files
208
+
209
+ - Default: `logs/relinka.log`
210
+ - Daily mode: `2025-04-11-relinka.log`
211
+ - Auto-cleanup: keep latest N logs
212
+
213
+ ## API Summary
214
+
215
+ ```ts
216
+ relinka("info", "message", optionalDetails);
217
+ relinka("fatal", "something broke"); // throws
218
+ relinka("clear", ""); // clears terminal
219
+
220
+ await relinkaAsync("warn", "something async");
221
+ ```
222
+
223
+ ```ts
224
+ defineConfig({ ... }) // helper for relinka.config.ts
225
+ ```
226
+
227
+ ## Built-in Utilities
228
+
229
+ - ✅ Timestamping
230
+ - ✅ File-safe formatting
231
+ - ✅ Log rotation
232
+ - ✅ Fatal logging (with debugger)
233
+ - ✅ Colorized terminal output
103
234
 
104
- ## 📁 Log Files
235
+ ## FAQ
105
236
 
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`
237
+ ### Why `relinka.config.ts` doesn't works for me?
109
238
 
110
- ## 📚 API Summary
239
+ You forget to load user's config by using `await relinkaConfig;` **at the START** of your app's main function.
111
240
 
112
- ### relinka(level, message, ...args)
241
+ ### Why my terminal stucks after last relinka() usage?
113
242
 
114
- Logs synchronously. Skips debug logs if `debug: false`.
243
+ You forget to flush the buffer. Place `await relinkaShutdown();` **at the END** of your app's main function.
115
244
 
116
- ### relinkaAsync(level, message, ...args)
245
+ ### Why does TS linter tells that something wrong with `relinka("info", args)`?
117
246
 
118
- Async logger that waits for config automatically, and provides some additional advanced features.
247
+ Add empty string: `relinka("info", "", args)`
119
248
 
120
- ### defineConfig(config)
249
+ ### Does `fatal` throw?
121
250
 
122
- Helper to define typed config in `relinka.config.ts`
251
+ Yes, always. It will halt execution and trigger `debugger` in dev mode.
123
252
 
124
- ## 🧰 Utilities
253
+ ### What's coming next?
125
254
 
126
- Timestamping
127
- Log file rotation
128
- ✅ File-safe formatting
129
- ANSI color support
130
- Error object handling
255
+ - Relinka is designed to be used in the different ways:
256
+ - Use `relinka(level, message, ...args)` (recommended).
257
+ - 🔜 Or, just `relinka.level(message, ...args)`
258
+ - 🔜 Both designed to work with both sync (default) and async/await.
259
+ - 🔜 Both designed to work with both direct and wrapper methods.
260
+ - 🔜 Use the async logger if you want some advanced features (like typing text streaming animation).
131
261
 
132
- ## 💡 Tips
262
+ ## Tips
133
263
 
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).
264
+ - Building CLIs? Use with [`@reliverse/prompts`](https://npmjs.com/@reliverse/prompts)
265
+ - Want type-safe injections? Try [`@reliverse/reinject`](https://npmjs.com/@reliverse/reinject)
266
+ - For advanced bundling? Pair with [`@reliverse/relidler`](https://npmjs.com/@reliverse/relidler)
136
267
 
137
- ## ✅ TODO
268
+ ## Roadmap
138
269
 
139
- - [x] File-based logging
140
- - [x] Timestamp support
270
+ - [x] File logging
271
+ - [x] Timestamps
141
272
  - [x] Daily logs
142
- - [x] Smart config
143
273
  - [x] Log rotation
144
- - [ ] CLI interface (optional)
145
- - [ ] Plugin support (custom formatters, log levels, etc)
274
+ - [x] `fatal` type
275
+ - [x] Runtime config
276
+ - [ ] Implement per-project config redefinition
277
+ - [ ] Plugin support (custom formatters, hooks)
278
+ - [ ] CLI interface (to manage logs, config, etc)
146
279
 
147
- ## 🙌 Shoutout
280
+ ## Shoutouts
148
281
 
149
- Relinka was inspired by this gem:
282
+ Relinka wouldn't exist without these gems:
150
283
 
151
- - [unjs/consola](https://github.com/unjs/consola#readme)
284
+ - [unjs/consola](https://github.com/unjs/consola#readme)
285
+ - [winston](https://github.com/winstonjs/winston#readme)
286
+ - [pino](https://github.com/pinojs/pino#readme)
287
+ - [node-bunyan](https://github.com/trentm/node-bunyan#readme)
152
288
 
153
- ## 📄 License
289
+ ## License
154
290
 
155
- 💖 MIT © [blefnk (Nazar Kornienko)](https://github.com/blefnk)
291
+ 💖 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
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Compiles a format string with named or positional arguments to a standard format string.
3
+ * Uses @reliverse/repris's built-in compileFormat.
4
+ * @param {string} format - The format string containing named placeholders.
5
+ * @returns {string} The compiled format string with positional indices.
6
+ */
7
+ export declare function compile(format: string): string;
8
+ /**
9
+ * Formats a string using either an array or an object of arguments.
10
+ * Uses @reliverse/repris's built-in formatString.
11
+ * @param {string} format - The format string (named or positional).
12
+ * @param {any[] | Record<string, unknown>} args - Arguments to format into the string.
13
+ * @returns {string} The formatted string.
14
+ */
15
+ export declare function formatStr(format: string, args: any[] | Record<string, unknown>): string;
@@ -0,0 +1,13 @@
1
+ import { compileFormat, formatString } from "@reliverse/repris";
2
+ const _compileCache = {};
3
+ export function compile(format) {
4
+ if (_compileCache[format]) {
5
+ return _compileCache[format];
6
+ }
7
+ const compiled = compileFormat(format);
8
+ _compileCache[format] = compiled;
9
+ return compiled;
10
+ }
11
+ export function formatStr(format, args) {
12
+ return formatString(format, args);
13
+ }
@@ -4,11 +4,11 @@
4
4
  * @param {string} format - The format string containing the placeholders to replace.
5
5
  * @returns {string} The compiled format string with placeholders replaced by positional indices.
6
6
  */
7
- export declare function compileFormat(format: string): any;
7
+ export declare function compileFormatCompat(format: string): string;
8
8
  /**
9
9
  * Formats a string according to a custom format, using vsprintf for string formatting.
10
10
  * @param {string} format - The custom format string.
11
11
  * @param {any[]} argv - The arguments to format into the string.
12
12
  * @returns {string} The formatted string.
13
13
  */
14
- export declare function formatString(format: string, argv: any): string;
14
+ export declare function formatStringCompat(format: string, argv: any): string;
@@ -1,4 +1,4 @@
1
- import { vsprintf } from "printj";
1
+ import { vsprintf } from "@reliverse/repris";
2
2
  const FORMAT_ARGS = [
3
3
  ["additional", 5],
4
4
  ["message", 4],
@@ -7,7 +7,7 @@ const FORMAT_ARGS = [
7
7
  ["tag", 3]
8
8
  ];
9
9
  const _compileCache = {};
10
- export function compileFormat(format) {
10
+ export function compileFormatCompat(format) {
11
11
  if (_compileCache[format]) {
12
12
  return _compileCache[format];
13
13
  }
@@ -21,6 +21,6 @@ export function compileFormat(format) {
21
21
  _compileCache[format] = _format;
22
22
  return _format;
23
23
  }
24
- export function formatString(format, argv) {
25
- return vsprintf(compileFormat(format), argv);
24
+ export function formatStringCompat(format, argv) {
25
+ return vsprintf(compileFormatCompat(format), argv);
26
26
  }