@reliverse/relinka 1.2.3 → 1.2.4
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.
|
@@ -9,6 +9,8 @@ export declare class Relinka {
|
|
|
9
9
|
time?: Date;
|
|
10
10
|
timeout?: ReturnType<typeof setTimeout>;
|
|
11
11
|
};
|
|
12
|
+
_paused: boolean;
|
|
13
|
+
_queue: any[];
|
|
12
14
|
_mockFn?: RelinkaOptions["mockFn"];
|
|
13
15
|
constructor(options?: Partial<RelinkaOptions>);
|
|
14
16
|
get level(): any;
|
|
@@ -27,6 +29,7 @@ export declare class Relinka {
|
|
|
27
29
|
_wrapStream(stream: NodeJS.WriteStream | undefined, type: LogType): void;
|
|
28
30
|
restoreStd(): void;
|
|
29
31
|
_restoreStream(stream?: NodeJS.WriteStream): void;
|
|
32
|
+
clear(clearConsole?: boolean): void;
|
|
30
33
|
pauseLogs(): void;
|
|
31
34
|
resumeLogs(): void;
|
|
32
35
|
mockTypes(mockFn?: RelinkaOptions["mockFn"]): void;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { defu } from "defu";
|
|
2
2
|
import { LogTypes } from "../../components/levels/levels.js";
|
|
3
3
|
import { isLogObj } from "../../utils/log.js";
|
|
4
|
-
|
|
4
|
+
const paused = false;
|
|
5
5
|
const queue = [];
|
|
6
6
|
export class Relinka {
|
|
7
7
|
options;
|
|
8
8
|
_lastLog;
|
|
9
|
+
|
|
10
|
+
_paused;
|
|
11
|
+
_queue;
|
|
9
12
|
_mockFn;
|
|
10
13
|
constructor(options = {}) {
|
|
11
14
|
const types = options.types || LogTypes;
|
|
@@ -43,6 +46,8 @@ export class Relinka {
|
|
|
43
46
|
this.mockTypes();
|
|
44
47
|
}
|
|
45
48
|
this._lastLog = {};
|
|
49
|
+
this._paused = false;
|
|
50
|
+
this._queue = [];
|
|
46
51
|
}
|
|
47
52
|
get level() {
|
|
48
53
|
return this.options.level;
|
|
@@ -148,13 +153,21 @@ export class Relinka {
|
|
|
148
153
|
stream.write = stream.__write;
|
|
149
154
|
delete stream.__write;
|
|
150
155
|
}
|
|
156
|
+
}
|
|
157
|
+
clear(clearConsole = false) {
|
|
158
|
+
this._lastLog = {};
|
|
159
|
+
this._queue = [];
|
|
160
|
+
this._paused = false;
|
|
161
|
+
if (clearConsole && typeof console.clear === "function") {
|
|
162
|
+
console.clear();
|
|
163
|
+
}
|
|
151
164
|
}
|
|
152
165
|
pauseLogs() {
|
|
153
|
-
|
|
166
|
+
this._paused = true;
|
|
154
167
|
}
|
|
155
168
|
resumeLogs() {
|
|
156
|
-
|
|
157
|
-
const _queue =
|
|
169
|
+
this._paused = false;
|
|
170
|
+
const _queue = this._queue.splice(0);
|
|
158
171
|
for (const item of _queue) {
|
|
159
172
|
item[0]._logFn(item[1], item[2]);
|
|
160
173
|
}
|
|
@@ -170,10 +183,11 @@ export class Relinka {
|
|
|
170
183
|
this[type].raw = this[type];
|
|
171
184
|
}
|
|
172
185
|
}
|
|
186
|
+
|
|
173
187
|
_wrapLogFn(defaults, isRaw) {
|
|
174
188
|
return (...args) => {
|
|
175
|
-
if (
|
|
176
|
-
|
|
189
|
+
if (this._paused) {
|
|
190
|
+
this._queue.push([this, defaults, args, isRaw]);
|
|
177
191
|
return;
|
|
178
192
|
}
|
|
179
193
|
return this._logFn(defaults, args, isRaw);
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reliverse/relinka",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"author": "blefnk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "@reliverse/relinka is a powerful logger for your terminal.",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"dev": "
|
|
8
|
+
"dev": "tsx examples/main.ts",
|
|
9
9
|
"check": "redrun typecheck lint format attw",
|
|
10
10
|
"release": "bumpp && bun check && bun pub",
|
|
11
|
-
"build:jsr": "
|
|
12
|
-
"build:npm": "unbuild &&
|
|
11
|
+
"build:jsr": "tsx build.optim.ts --jsr",
|
|
12
|
+
"build:npm": "unbuild && tsx build.optim.ts",
|
|
13
13
|
"build": "redrun build:jsr build:npm optimize",
|
|
14
|
-
"pub:jsr": "
|
|
15
|
-
"pub:npm": "
|
|
16
|
-
"pub:dry": "
|
|
14
|
+
"pub:jsr": "tsx build.publish.ts --jsr",
|
|
15
|
+
"pub:npm": "tsx build.publish.ts",
|
|
16
|
+
"pub:dry": "tsx build.publish.ts --dry-run",
|
|
17
17
|
"pub": "redrun pub:npm pub:jsr",
|
|
18
18
|
"typecheck": "tsc --noEmit",
|
|
19
19
|
"lint": "eslint --cache --fix .",
|
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
"redrun": "^11.0.5",
|
|
115
115
|
"sentencer": "^0.2.1",
|
|
116
116
|
"strip-comments": "^2.0.1",
|
|
117
|
+
"tsx": "^4.19.2",
|
|
117
118
|
"typescript": "^5.7.2",
|
|
118
119
|
"typescript-eslint": "^8.16.0",
|
|
119
120
|
"unbuild": "^2.0.0",
|