@reliverse/relinka 1.3.5 → 1.3.7
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 +114 -76
- package/bin/main.d.ts +22 -1
- package/bin/main.js +58 -1
- package/bin/relinka-impl/deprecated/components/levels/levels.d.ts +13 -0
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/modes/basic.d.ts +3 -3
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/modes/browser.d.ts +4 -4
- package/bin/relinka-impl/deprecated/components/modes/shared.d.ts +2 -0
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/mod.d.ts +3 -3
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/relinka.d.ts +18 -18
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/relinka.js +6 -6
- package/bin/relinka-impl/deprecated/components/relinka-deprecated/relinka.test.d.ts +1 -0
- package/bin/relinka-impl/deprecated/components/relinka-deprecated/relinka.test.js +57 -0
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/basic.d.ts +3 -3
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/browser.d.ts +1 -1
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/fancy.d.ts +2 -2
- package/bin/relinka-impl/impl-mod.d.ts +19 -0
- package/bin/relinka-impl/impl-mod.js +317 -0
- package/bin/{types.d.ts → relinka-types.d.ts} +51 -7
- package/package.json +9 -26
- package/bin/libs/core/core-impl/deprecated/components/levels/levels.d.ts +0 -26
- package/bin/libs/core/core-impl/deprecated/components/modes/shared.d.ts +0 -3
- package/bin/libs/core/core-main.d.ts +0 -23
- package/bin/libs/core/core-main.js +0 -49
- package/bin/libs/core/core-types.d.ts +0 -1
- package/bin/libs/core/core-types.js +0 -1
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/levels/levels.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/modes/basic.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/modes/browser.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/modes/shared.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/logger.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/logger.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/mod.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/basic.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/browser.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/fancy.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/box.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/box.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/deprecatedColors.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/deprecatedColors.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/error.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/error.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/format.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/format.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/log.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/log.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/stream.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/stream.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/string.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/string.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/tree.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/tree.js +0 -0
- /package/bin/{types.js → relinka-types.js} +0 -0
package/README.md
CHANGED
|
@@ -1,116 +1,154 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Relinka: Stylish Logging Made Simple
|
|
2
2
|
|
|
3
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)
|
|
4
4
|
|
|
5
|
-
**@reliverse/relinka** is your next
|
|
5
|
+
**@reliverse/relinka** is your next favorite logging library — built to make your terminal (and browser console — soon) 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.
|
|
6
6
|
|
|
7
|
-
## Features
|
|
7
|
+
## 🌟 Features
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
- ✨ Packed with powerful features under the hood
|
|
18
|
-
- 📝 Highly configurable flow via a configuration file
|
|
19
|
-
- 🔌 Plugin system with one built-in plugin included
|
|
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
|
|
20
17
|
|
|
21
|
-
## Getting Started
|
|
18
|
+
## 🚀 Getting Started
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
### 1. Install
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
```bash
|
|
23
|
+
bun add @reliverse/relinka
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
And, optionally, install the CLI globally to manage your config:
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
```bash
|
|
29
|
+
bun i -g @reliverse/relinka-cli
|
|
30
|
+
```
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
### 2. Basic Usage
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { relinkaConfig, relinka } from "@reliverse/relinka";
|
|
36
|
+
export async function main() {
|
|
37
|
+
await relinkaConfig;
|
|
38
|
+
relinka(
|
|
39
|
+
"verbose",
|
|
40
|
+
"This message can be seen only if config was loaded AND debug is enabled",
|
|
41
|
+
);
|
|
42
|
+
relinka("info", "Everything is running smoothly");
|
|
43
|
+
relinka("warn", "This might be a problem");
|
|
44
|
+
relinka("error", "Uh oh, something broke");
|
|
45
|
+
relinka("success", "Thanks for using Relinka! 👋");
|
|
46
|
+
}
|
|
47
|
+
await main();
|
|
34
48
|
```
|
|
35
49
|
|
|
36
|
-
|
|
50
|
+
## 🧪 Advanced Usage
|
|
51
|
+
|
|
52
|
+
Want a clean blank line?
|
|
37
53
|
|
|
38
|
-
|
|
54
|
+
```ts
|
|
55
|
+
relinka("info", ""); // Just prints a newline
|
|
56
|
+
```
|
|
39
57
|
|
|
40
|
-
|
|
41
|
-
bun i -g @reliverse/relidler
|
|
42
|
-
```
|
|
58
|
+
🔜 Use the async logger if you want some advanced features (like typing text animation - soon):
|
|
43
59
|
|
|
44
|
-
|
|
60
|
+
```ts
|
|
61
|
+
import { relinkaAsync } from "@reliverse/relinka";
|
|
45
62
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```
|
|
63
|
+
await relinkaAsync("info", "Something happened", { animate: true });
|
|
64
|
+
```
|
|
49
65
|
|
|
50
|
-
|
|
66
|
+
## ⚙️ Configuration
|
|
67
|
+
|
|
68
|
+
Create a `relinka.config.ts` file with a content like:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { defineConfig } from "@reliverse/relinka";
|
|
72
|
+
export default defineConfig({
|
|
73
|
+
// Enable debug to see verbose logs
|
|
74
|
+
debug: true,
|
|
75
|
+
// Show timestamp in each log message
|
|
76
|
+
withTimestamp: false,
|
|
77
|
+
// Control whether logs are saved to a file
|
|
78
|
+
saveLogsToFile: true,
|
|
79
|
+
// Disable colors in the console
|
|
80
|
+
disableColors: false,
|
|
81
|
+
// Log file path
|
|
82
|
+
logFilePath: "relinka.log",
|
|
83
|
+
// Directory settings
|
|
84
|
+
dirs: {
|
|
85
|
+
dailyLogs: true,
|
|
86
|
+
logDir: ".reliverse/logs", // store logs in a custom folder
|
|
87
|
+
maxLogFiles: 5, // keep only the 5 most recent log files
|
|
88
|
+
specialDirs: {
|
|
89
|
+
distDirNames: [],
|
|
90
|
+
useParentConfigInDist: true,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
```
|
|
51
95
|
|
|
52
|
-
|
|
96
|
+
Supported config file names:
|
|
53
97
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
echo "dist-libs" >> .gitignore
|
|
59
|
-
```
|
|
98
|
+
- `relinka.config.ts`
|
|
99
|
+
- 🔜 `.relinka.config.js`
|
|
100
|
+
- 🔜 `.relinkarc`
|
|
101
|
+
- 🔜 or any other supported by c12
|
|
60
102
|
|
|
61
|
-
|
|
103
|
+
## 📁 Log Files
|
|
62
104
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
105
|
+
- Stored in `.reliverse/logs/` by default
|
|
106
|
+
- Filename: `relinka.log` or `YYYY-MM-DD-relinka.log` if daily logs are enabled
|
|
107
|
+
- Auto-rotates based on `maxLogFiles`
|
|
66
108
|
|
|
67
|
-
|
|
109
|
+
## 📚 API Summary
|
|
68
110
|
|
|
69
|
-
|
|
70
|
-
relidler
|
|
71
|
-
```
|
|
111
|
+
### relinka(level, message, ...args)
|
|
72
112
|
|
|
73
|
-
|
|
74
|
-
- **It's recommended to customize this file according to your needs.**
|
|
75
|
-
- Supported names: `relidler.cfg.ts` • `relidler.config.ts` • `build.pub.ts` • `build.cfg.ts`.
|
|
113
|
+
Logs synchronously. Skips debug logs if `debug: false`.
|
|
76
114
|
|
|
77
|
-
|
|
115
|
+
### relinkaAsync(level, message, ...args)
|
|
78
116
|
|
|
79
|
-
|
|
80
|
-
relidler
|
|
81
|
-
```
|
|
117
|
+
Async logger that waits for config automatically, and provides some additional advanced features.
|
|
82
118
|
|
|
83
|
-
|
|
119
|
+
### defineConfig(config)
|
|
84
120
|
|
|
85
|
-
|
|
121
|
+
Helper to define typed config in `relinka.config.ts`
|
|
86
122
|
|
|
87
|
-
|
|
123
|
+
## 🧰 Utilities
|
|
88
124
|
|
|
89
|
-
|
|
125
|
+
✅ Timestamping
|
|
126
|
+
✅ Log file rotation
|
|
127
|
+
✅ File-safe formatting
|
|
128
|
+
✅ ANSI color support
|
|
129
|
+
✅ Error object handling
|
|
90
130
|
|
|
91
|
-
|
|
131
|
+
## 💡 Tips
|
|
92
132
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
```
|
|
133
|
+
- Want `@ts-expect-error` auto-injection? Check out [`@reliverse/reinject`](https://npmjs.com/@reliverse/reinject).
|
|
134
|
+
- Using this in a CLI tool? Combine with [`@reliverse/prompts`](https://npmjs.com/@reliverse/prompts).
|
|
96
135
|
|
|
97
|
-
## TODO
|
|
136
|
+
## ✅ TODO
|
|
98
137
|
|
|
99
|
-
- [x]
|
|
100
|
-
- [
|
|
101
|
-
- [
|
|
102
|
-
- [
|
|
103
|
-
- [
|
|
104
|
-
- [ ]
|
|
105
|
-
- [ ]
|
|
106
|
-
- [ ] Make config file optional with sensible defaults
|
|
138
|
+
- [x] File-based logging
|
|
139
|
+
- [x] Timestamp support
|
|
140
|
+
- [x] Daily logs
|
|
141
|
+
- [x] Smart config
|
|
142
|
+
- [x] Log rotation
|
|
143
|
+
- [ ] CLI interface (optional)
|
|
144
|
+
- [ ] Plugin support (custom formatters, log levels, etc)
|
|
107
145
|
|
|
108
|
-
##
|
|
146
|
+
## 🙌 Shoutout
|
|
109
147
|
|
|
110
|
-
|
|
148
|
+
Relinka was inspired by this gem:
|
|
111
149
|
|
|
112
150
|
- [unjs/consola](https://github.com/unjs/consola#readme)
|
|
113
151
|
|
|
114
|
-
## License
|
|
152
|
+
## 📄 License
|
|
115
153
|
|
|
116
|
-
|
|
154
|
+
💖 MIT © [blefnk (Nazar Kornienko)](https://github.com/blefnk)
|
package/bin/main.d.ts
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { LogLevelsDeprecated, LogTypesDeprecated, } from "./relinka-impl/deprecated/components/levels/levels.js";
|
|
2
|
+
export { createRelinkaBaseDeprecated, relinkaBasicDeprecated, } from "./relinka-impl/deprecated/components/modes/basic.js";
|
|
3
|
+
export { createRelinkaBrowserDeprecatedDeprecated, relinkaBrowserDeprecated, } from "./relinka-impl/deprecated/components/modes/browser.js";
|
|
4
|
+
export { relinkaDeprecated } from "./relinka-impl/deprecated/components/relinka-deprecated/logger.js";
|
|
5
|
+
export { createRelinkaSharedDeprecated, relinkaInstanceDeprecated, } from "./relinka-impl/deprecated/components/relinka-deprecated/mod.js";
|
|
6
|
+
export type { LogFn, RelinkaInstanceDeprecated, } from "./relinka-impl/deprecated/components/relinka-deprecated/relinka.js";
|
|
7
|
+
export { RelinkaInterface, createRelinkaDeprecated, } from "./relinka-impl/deprecated/components/relinka-deprecated/relinka.js";
|
|
8
|
+
export { BasicReporter } from "./relinka-impl/deprecated/components/reporters/basic.js";
|
|
9
|
+
export { BrowserReporter } from "./relinka-impl/deprecated/components/reporters/browser.js";
|
|
10
|
+
export { TYPE_COLOR_MAP, LEVEL_COLOR_MAP, FancyReporter, } from "./relinka-impl/deprecated/components/reporters/fancy.js";
|
|
11
|
+
export type { BoxBorderStyle, BoxStyle, BoxOpts, } from "./relinka-impl/deprecated/utils/box.js";
|
|
12
|
+
export { box } from "./relinka-impl/deprecated/utils/box.js";
|
|
13
|
+
export type { ColorName, ColorFunction, } from "./relinka-impl/deprecated/utils/deprecatedColors.js";
|
|
14
|
+
export { colors, getColor, colorize, } from "./relinka-impl/deprecated/utils/deprecatedColors.js";
|
|
15
|
+
export { parseStack } from "./relinka-impl/deprecated/utils/error.js";
|
|
16
|
+
export { compileFormat, formatString, } from "./relinka-impl/deprecated/utils/format.js";
|
|
17
|
+
export { isPlainObject, isLogObj, } from "./relinka-impl/deprecated/utils/log.js";
|
|
18
|
+
export { writeStream } from "./relinka-impl/deprecated/utils/stream.js";
|
|
19
|
+
export { stripAnsi, centerAlign, rightAlign, leftAlign, align, } from "./relinka-impl/deprecated/utils/string.js";
|
|
20
|
+
export type { TreeItemObject, TreeItem, TreeOptions, } from "./relinka-impl/deprecated/utils/tree.js";
|
|
21
|
+
export { formatTree } from "./relinka-impl/deprecated/utils/tree.js";
|
|
22
|
+
export { relinkaConfig, relinka, relinkaAsync, defineConfig, } from "./relinka-impl/impl-mod.js";
|
package/bin/main.js
CHANGED
|
@@ -1 +1,58 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {
|
|
2
|
+
LogLevelsDeprecated,
|
|
3
|
+
LogTypesDeprecated
|
|
4
|
+
} from "./relinka-impl/deprecated/components/levels/levels.js";
|
|
5
|
+
export {
|
|
6
|
+
createRelinkaBaseDeprecated,
|
|
7
|
+
relinkaBasicDeprecated
|
|
8
|
+
} from "./relinka-impl/deprecated/components/modes/basic.js";
|
|
9
|
+
export {
|
|
10
|
+
createRelinkaBrowserDeprecatedDeprecated,
|
|
11
|
+
relinkaBrowserDeprecated
|
|
12
|
+
} from "./relinka-impl/deprecated/components/modes/browser.js";
|
|
13
|
+
export { relinkaDeprecated } from "./relinka-impl/deprecated/components/relinka-deprecated/logger.js";
|
|
14
|
+
export {
|
|
15
|
+
createRelinkaSharedDeprecated,
|
|
16
|
+
relinkaInstanceDeprecated
|
|
17
|
+
} from "./relinka-impl/deprecated/components/relinka-deprecated/mod.js";
|
|
18
|
+
export {
|
|
19
|
+
RelinkaInterface,
|
|
20
|
+
createRelinkaDeprecated
|
|
21
|
+
} from "./relinka-impl/deprecated/components/relinka-deprecated/relinka.js";
|
|
22
|
+
export { BasicReporter } from "./relinka-impl/deprecated/components/reporters/basic.js";
|
|
23
|
+
export { BrowserReporter } from "./relinka-impl/deprecated/components/reporters/browser.js";
|
|
24
|
+
export {
|
|
25
|
+
TYPE_COLOR_MAP,
|
|
26
|
+
LEVEL_COLOR_MAP,
|
|
27
|
+
FancyReporter
|
|
28
|
+
} from "./relinka-impl/deprecated/components/reporters/fancy.js";
|
|
29
|
+
export { box } from "./relinka-impl/deprecated/utils/box.js";
|
|
30
|
+
export {
|
|
31
|
+
colors,
|
|
32
|
+
getColor,
|
|
33
|
+
colorize
|
|
34
|
+
} from "./relinka-impl/deprecated/utils/deprecatedColors.js";
|
|
35
|
+
export { parseStack } from "./relinka-impl/deprecated/utils/error.js";
|
|
36
|
+
export {
|
|
37
|
+
compileFormat,
|
|
38
|
+
formatString
|
|
39
|
+
} from "./relinka-impl/deprecated/utils/format.js";
|
|
40
|
+
export {
|
|
41
|
+
isPlainObject,
|
|
42
|
+
isLogObj
|
|
43
|
+
} from "./relinka-impl/deprecated/utils/log.js";
|
|
44
|
+
export { writeStream } from "./relinka-impl/deprecated/utils/stream.js";
|
|
45
|
+
export {
|
|
46
|
+
stripAnsi,
|
|
47
|
+
centerAlign,
|
|
48
|
+
rightAlign,
|
|
49
|
+
leftAlign,
|
|
50
|
+
align
|
|
51
|
+
} from "./relinka-impl/deprecated/utils/string.js";
|
|
52
|
+
export { formatTree } from "./relinka-impl/deprecated/utils/tree.js";
|
|
53
|
+
export {
|
|
54
|
+
relinkaConfig,
|
|
55
|
+
relinka,
|
|
56
|
+
relinkaAsync,
|
|
57
|
+
defineConfig
|
|
58
|
+
} from "./relinka-impl/impl-mod.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { LogObject, LogTypeDeprecated } from "../../../../relinka-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A mapping of `LogTypeDeprecated` to its corresponding numeric log level.
|
|
4
|
+
*
|
|
5
|
+
* @type {Record<LogTypeDeprecated, number>} LogLevelsDeprecated - key-value pairs of log types to their numeric levels. See {@link LogTypeDeprecated}.
|
|
6
|
+
*/
|
|
7
|
+
export declare const LogLevelsDeprecated: Record<LogTypeDeprecated, number>;
|
|
8
|
+
/**
|
|
9
|
+
* Maps `LogTypeDeprecated` to a `Partial<LogObject>`, primarily defining the log level.
|
|
10
|
+
*
|
|
11
|
+
* @type {Record<LogTypeDeprecated, Partial<LogObject>>} LogTypesDeprecated - key-value pairs of log types to partial log objects, specifying log levels. See {@link LogTypeDeprecated} and {@link LogObject}.
|
|
12
|
+
*/
|
|
13
|
+
export declare const LogTypesDeprecated: Record<LogTypeDeprecated, Partial<LogObject>>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { RelinkaInstanceDeprecated } from "../relinka-deprecated/relinka.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { RelinkaOptionsDeprecated } from "../../../../relinka-types.js";
|
|
3
3
|
export * from "./shared.js";
|
|
4
4
|
/**
|
|
5
5
|
* Factory function to create a new Relinka instance
|
|
6
6
|
*
|
|
7
|
-
* @param {Partial<
|
|
7
|
+
* @param {Partial<RelinkaOptionsDeprecated & { fancy: boolean }>} [options={}] - Optional configuration options. See {@link RelinkaOptionsDeprecated}.
|
|
8
8
|
* @returns {RelinkaInstanceDeprecated} A new Relinka instance configured with the given options.
|
|
9
9
|
*/
|
|
10
|
-
export declare function createRelinkaBaseDeprecated(options?: Partial<
|
|
10
|
+
export declare function createRelinkaBaseDeprecated(options?: Partial<RelinkaOptionsDeprecated & {
|
|
11
11
|
fancy: boolean;
|
|
12
12
|
}>): RelinkaInstanceDeprecated;
|
|
13
13
|
/**
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RelinkaOptionsDeprecated } from "../../../../relinka-types.js";
|
|
2
2
|
import { type RelinkaInstanceDeprecated } from "../relinka-deprecated/relinka.js";
|
|
3
3
|
export * from "./shared.js";
|
|
4
4
|
/**
|
|
5
5
|
* Creates a new Relinka instance configured specifically for browser environments.
|
|
6
6
|
* This function sets up default reporters and a prompt method tailored to the browser's dialogue APIs.
|
|
7
7
|
*
|
|
8
|
-
* @param {Partial<
|
|
9
|
-
* The options can override the default reporter and prompt behavior. See {@link
|
|
8
|
+
* @param {Partial<RelinkaOptionsDeprecated>} [options={}] - Optional configuration options.
|
|
9
|
+
* The options can override the default reporter and prompt behavior. See {@link RelinkaOptionsDeprecated}.
|
|
10
10
|
* @returns {RelinkaInstanceDeprecated} A new Relinka instance optimized for use in browser environments.
|
|
11
11
|
*/
|
|
12
|
-
export declare function createRelinkaBrowserDeprecatedDeprecated(options?: Partial<
|
|
12
|
+
export declare function createRelinkaBrowserDeprecatedDeprecated(options?: Partial<RelinkaOptionsDeprecated>): any;
|
|
13
13
|
/**
|
|
14
14
|
* A standard Relinka instance created with browser-specific configurations.
|
|
15
15
|
* This instance can be used throughout a browser-based project.
|
package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/mod.d.ts
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RelinkaOptionsDeprecated } from "../../../../relinka-types.js";
|
|
2
2
|
import type { RelinkaInstanceDeprecated } from "./relinka.js";
|
|
3
3
|
export * from "../modes/shared.js";
|
|
4
4
|
/**
|
|
5
5
|
* Factory function to create a new Relinka instance tailored for use in different environments.
|
|
6
6
|
* It automatically adjusts logging levels based on environment variables and execution context.
|
|
7
7
|
*
|
|
8
|
-
* @param {Partial<
|
|
8
|
+
* @param {Partial<RelinkaOptionsDeprecated & { fancy: boolean }>} [options={}] - Optional configuration options. See {@link RelinkaOptionsDeprecated}.
|
|
9
9
|
* @returns {RelinkaInstanceDeprecated} A new Relinka instance with configurations based on the given options and the execution environment.
|
|
10
10
|
*/
|
|
11
|
-
export declare function createRelinkaSharedDeprecated(options?: Partial<
|
|
11
|
+
export declare function createRelinkaSharedDeprecated(options?: Partial<RelinkaOptionsDeprecated & {
|
|
12
12
|
fancy: boolean;
|
|
13
13
|
}>): RelinkaInstanceDeprecated;
|
|
14
14
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { LogTypeDeprecated } from "
|
|
3
|
-
import type { InputLogObject, LogObject,
|
|
2
|
+
import type { LogTypeDeprecated } from "../../../../relinka-types.js";
|
|
3
|
+
import type { InputLogObject, LogObject, RelinkaOptionsDeprecated, RelinkaReporterDeprecated } from "../../../../relinka-types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Relinka class for logging management with support for pause/resume, mocking and customizable reporting.
|
|
6
6
|
* Provides flexible logging capabilities including level-based logging, custom reporters and integration options.
|
|
@@ -8,7 +8,7 @@ import type { InputLogObject, LogObject, RelinkaOptions, RelinkaReporter } from
|
|
|
8
8
|
* @class Relinka
|
|
9
9
|
*/
|
|
10
10
|
export declare class RelinkaInterface {
|
|
11
|
-
options:
|
|
11
|
+
options: RelinkaOptionsDeprecated;
|
|
12
12
|
_lastLog: {
|
|
13
13
|
serialized?: string;
|
|
14
14
|
object?: LogObject;
|
|
@@ -18,13 +18,13 @@ export declare class RelinkaInterface {
|
|
|
18
18
|
};
|
|
19
19
|
_paused: boolean;
|
|
20
20
|
_queue: any[];
|
|
21
|
-
_mockFn?:
|
|
21
|
+
_mockFn?: RelinkaOptionsDeprecated["mockFn"];
|
|
22
22
|
/**
|
|
23
23
|
* Creates an instance of Relinka with specified options or defaults.
|
|
24
24
|
*
|
|
25
|
-
* @param {Partial<
|
|
25
|
+
* @param {Partial<RelinkaOptionsDeprecated>} [options={}] - Configuration options for the Relinka instance.
|
|
26
26
|
*/
|
|
27
|
-
constructor(options?: Partial<
|
|
27
|
+
constructor(options?: Partial<RelinkaOptionsDeprecated>);
|
|
28
28
|
/**
|
|
29
29
|
* Gets the current log level of the Relinka instance.
|
|
30
30
|
*
|
|
@@ -40,10 +40,10 @@ export declare class RelinkaInterface {
|
|
|
40
40
|
/**
|
|
41
41
|
* Creates a new instance of Relinka, inheriting options from the current instance, with possible overrides.
|
|
42
42
|
*
|
|
43
|
-
* @param {Partial<
|
|
43
|
+
* @param {Partial<RelinkaOptionsDeprecated>} options - Optional overrides for the new instance. See {@link RelinkaOptionsDeprecated}.
|
|
44
44
|
* @returns {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
|
|
45
45
|
*/
|
|
46
|
-
create(options: Partial<
|
|
46
|
+
create(options: Partial<RelinkaOptionsDeprecated>): RelinkaInstanceDeprecated;
|
|
47
47
|
/**
|
|
48
48
|
* Creates a new Relinka instance with the specified default log object properties.
|
|
49
49
|
*
|
|
@@ -62,25 +62,25 @@ export declare class RelinkaInterface {
|
|
|
62
62
|
* Adds a custom reporter to the Relinka instance.
|
|
63
63
|
* Reporters will be called for each log message, depending on their implementation and log level.
|
|
64
64
|
*
|
|
65
|
-
* @param {
|
|
65
|
+
* @param {RelinkaReporterDeprecated} reporter - The reporter to add. See {@link RelinkaReporterDeprecated}.
|
|
66
66
|
* @returns {Relinka} The current Relinka instance.
|
|
67
67
|
*/
|
|
68
|
-
addReporter(reporter:
|
|
68
|
+
addReporter(reporter: RelinkaReporterDeprecated): this;
|
|
69
69
|
/**
|
|
70
70
|
* Removes a custom reporter from the Relinka instance.
|
|
71
71
|
* If no reporter is specified, all reporters will be removed.
|
|
72
72
|
*
|
|
73
|
-
* @param {
|
|
73
|
+
* @param {RelinkaReporterDeprecated} reporter - The reporter to remove. See {@link RelinkaReporterDeprecated}.
|
|
74
74
|
* @returns {Relinka} The current Relinka instance.
|
|
75
75
|
*/
|
|
76
|
-
removeReporter(reporter:
|
|
76
|
+
removeReporter(reporter: RelinkaReporterDeprecated): any;
|
|
77
77
|
/**
|
|
78
78
|
* Replaces all reporters of the Relinka instance with the specified array of reporters.
|
|
79
79
|
*
|
|
80
|
-
* @param {
|
|
80
|
+
* @param {RelinkaReporterDeprecated[]} reporters - The new reporters to set. See {@link RelinkaReporterDeprecated}.
|
|
81
81
|
* @returns {Relinka} The current Relinka instance.
|
|
82
82
|
*/
|
|
83
|
-
setReporters(reporters:
|
|
83
|
+
setReporters(reporters: RelinkaReporterDeprecated[]): this;
|
|
84
84
|
wrapAll(): void;
|
|
85
85
|
restoreAll(): void;
|
|
86
86
|
/**
|
|
@@ -120,9 +120,9 @@ export declare class RelinkaInterface {
|
|
|
120
120
|
/**
|
|
121
121
|
* Replaces logging methods with mocks if a mock function is provided.
|
|
122
122
|
*
|
|
123
|
-
* @param {
|
|
123
|
+
* @param {RelinkaOptionsDeprecated["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link RelinkaOptionsDeprecated["mockFn"]}.
|
|
124
124
|
*/
|
|
125
|
-
mockTypes(mockFn?:
|
|
125
|
+
mockTypes(mockFn?: RelinkaOptionsDeprecated["mockFn"]): void;
|
|
126
126
|
_wrapLogFn(defaults: InputLogObject, isRaw?: boolean): (...args: any[]) => boolean;
|
|
127
127
|
_logFn(defaults: InputLogObject, args: any[], isRaw?: boolean): boolean;
|
|
128
128
|
_log(logObj: LogObject): void;
|
|
@@ -135,7 +135,7 @@ export type RelinkaInstanceDeprecated = RelinkaInterface & Record<LogTypeDepreca
|
|
|
135
135
|
/**
|
|
136
136
|
* Utility for creating a new Relinka instance with optional configuration.
|
|
137
137
|
*
|
|
138
|
-
* @param {Partial<
|
|
138
|
+
* @param {Partial<RelinkaOptionsDeprecated>} [options={}] - Optional configuration options for the new Relinka instance. See {@link RelinkaOptionsDeprecated}.
|
|
139
139
|
* @returns {RelinkaInstanceDeprecated} A new instance of RelinkaInterface. See {@link RelinkaInstanceDeprecated}.
|
|
140
140
|
*/
|
|
141
|
-
export declare function createRelinkaDeprecated(options?: Partial<
|
|
141
|
+
export declare function createRelinkaDeprecated(options?: Partial<RelinkaOptionsDeprecated>): RelinkaInstanceDeprecated;
|
package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/relinka.js
RENAMED
|
@@ -11,7 +11,7 @@ export class RelinkaInterface {
|
|
|
11
11
|
/**
|
|
12
12
|
* Creates an instance of Relinka with specified options or defaults.
|
|
13
13
|
*
|
|
14
|
-
* @param {Partial<
|
|
14
|
+
* @param {Partial<RelinkaOptionsDeprecated>} [options={}] - Configuration options for the Relinka instance.
|
|
15
15
|
*/
|
|
16
16
|
constructor(options = {}) {
|
|
17
17
|
const types = options.types || LogTypesDeprecated;
|
|
@@ -72,7 +72,7 @@ export class RelinkaInterface {
|
|
|
72
72
|
/**
|
|
73
73
|
* Creates a new instance of Relinka, inheriting options from the current instance, with possible overrides.
|
|
74
74
|
*
|
|
75
|
-
* @param {Partial<
|
|
75
|
+
* @param {Partial<RelinkaOptionsDeprecated>} options - Optional overrides for the new instance. See {@link RelinkaOptionsDeprecated}.
|
|
76
76
|
* @returns {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
|
|
77
77
|
*/
|
|
78
78
|
create(options) {
|
|
@@ -115,7 +115,7 @@ export class RelinkaInterface {
|
|
|
115
115
|
* Adds a custom reporter to the Relinka instance.
|
|
116
116
|
* Reporters will be called for each log message, depending on their implementation and log level.
|
|
117
117
|
*
|
|
118
|
-
* @param {
|
|
118
|
+
* @param {RelinkaReporterDeprecated} reporter - The reporter to add. See {@link RelinkaReporterDeprecated}.
|
|
119
119
|
* @returns {Relinka} The current Relinka instance.
|
|
120
120
|
*/
|
|
121
121
|
addReporter(reporter) {
|
|
@@ -126,7 +126,7 @@ export class RelinkaInterface {
|
|
|
126
126
|
* Removes a custom reporter from the Relinka instance.
|
|
127
127
|
* If no reporter is specified, all reporters will be removed.
|
|
128
128
|
*
|
|
129
|
-
* @param {
|
|
129
|
+
* @param {RelinkaReporterDeprecated} reporter - The reporter to remove. See {@link RelinkaReporterDeprecated}.
|
|
130
130
|
* @returns {Relinka} The current Relinka instance.
|
|
131
131
|
*/
|
|
132
132
|
removeReporter(reporter) {
|
|
@@ -143,7 +143,7 @@ export class RelinkaInterface {
|
|
|
143
143
|
/**
|
|
144
144
|
* Replaces all reporters of the Relinka instance with the specified array of reporters.
|
|
145
145
|
*
|
|
146
|
-
* @param {
|
|
146
|
+
* @param {RelinkaReporterDeprecated[]} reporters - The new reporters to set. See {@link RelinkaReporterDeprecated}.
|
|
147
147
|
* @returns {Relinka} The current Relinka instance.
|
|
148
148
|
*/
|
|
149
149
|
setReporters(reporters) {
|
|
@@ -250,7 +250,7 @@ export class RelinkaInterface {
|
|
|
250
250
|
/**
|
|
251
251
|
* Replaces logging methods with mocks if a mock function is provided.
|
|
252
252
|
*
|
|
253
|
-
* @param {
|
|
253
|
+
* @param {RelinkaOptionsDeprecated["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link RelinkaOptionsDeprecated["mockFn"]}.
|
|
254
254
|
*/
|
|
255
255
|
mockTypes(mockFn) {
|
|
256
256
|
const _mockFn = mockFn || this.options.mockFn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, test, expect } from "vitest";
|
|
2
|
+
import { createRelinkaDeprecated } from "./relinka.js";
|
|
3
|
+
import {
|
|
4
|
+
LogLevelsDeprecated
|
|
5
|
+
} from "./mod.js";
|
|
6
|
+
describe("relinka", () => {
|
|
7
|
+
test("can set level", () => {
|
|
8
|
+
const relinka = createRelinkaDeprecated();
|
|
9
|
+
expect(relinka.level).toBe(1);
|
|
10
|
+
for (let i = 0; i <= 5; i++) {
|
|
11
|
+
relinka.level = i;
|
|
12
|
+
expect(relinka.level).toBe(i);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
test("silent log level does't print logs", async () => {
|
|
16
|
+
const logs = [];
|
|
17
|
+
const TestReporter = {
|
|
18
|
+
log(logObj) {
|
|
19
|
+
logs.push(logObj);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const relinka = createRelinkaDeprecated({
|
|
23
|
+
throttle: 100,
|
|
24
|
+
level: LogLevelsDeprecated.silent,
|
|
25
|
+
reporters: [TestReporter]
|
|
26
|
+
});
|
|
27
|
+
for (let i = 0; i < 10; i++) {
|
|
28
|
+
relinka.log("SPAM");
|
|
29
|
+
}
|
|
30
|
+
await wait(200);
|
|
31
|
+
expect(logs.length).toBe(0);
|
|
32
|
+
});
|
|
33
|
+
test("can see spams without ending log", async () => {
|
|
34
|
+
const logs = [];
|
|
35
|
+
const TestReporter = {
|
|
36
|
+
log(logObj) {
|
|
37
|
+
logs.push(logObj);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const relinka = createRelinkaDeprecated({
|
|
41
|
+
throttle: 100,
|
|
42
|
+
level: LogLevelsDeprecated.info,
|
|
43
|
+
reporters: [TestReporter]
|
|
44
|
+
});
|
|
45
|
+
for (let i = 0; i < 10; i++) {
|
|
46
|
+
relinka.log("SPAM");
|
|
47
|
+
}
|
|
48
|
+
await wait(300);
|
|
49
|
+
expect(logs.length).toBe(7);
|
|
50
|
+
expect(logs.at(-1).args).toEqual(["SPAM", "(repeated 4 times)"]);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
function wait(delay) {
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
|
+
setTimeout(resolve, delay);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { LogObject,
|
|
2
|
-
export declare class BasicReporter implements
|
|
1
|
+
import type { LogObject, RelinkaReporterDeprecated, FormatOptions, RelinkaOptionsDeprecated } from "../../../../relinka-types.js";
|
|
2
|
+
export declare class BasicReporter implements RelinkaReporterDeprecated {
|
|
3
3
|
formatStack(stack: string): string;
|
|
4
4
|
formatArgs(args: any[], opts: FormatOptions): string;
|
|
5
5
|
formatDate(date: Date, opts: FormatOptions): string;
|
|
6
6
|
filterAndJoin(arr: any[]): string;
|
|
7
7
|
formatLogObj(logObj: LogObject, opts: FormatOptions): string;
|
|
8
8
|
log(logObj: LogObject, ctx: {
|
|
9
|
-
options:
|
|
9
|
+
options: RelinkaOptionsDeprecated;
|
|
10
10
|
}): any;
|
|
11
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LogLevelDeprecated, LogTypeDeprecated } from "
|
|
2
|
-
import type { FormatOptions, LogObject } from "../../../../
|
|
1
|
+
import type { LogLevelDeprecated, LogTypeDeprecated } from "../../../../relinka-types.js";
|
|
2
|
+
import type { FormatOptions, LogObject } from "../../../../relinka-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>>;
|