kerium 1.0.0 → 1.1.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/dist/error.d.ts +7 -1
- package/dist/error.js +11 -2
- package/dist/log.d.ts +1 -1
- package/dist/log.js +65 -43
- package/package.json +1 -1
package/dist/error.d.ts
CHANGED
|
@@ -414,7 +414,13 @@ export interface ErrnoExceptionJSON {
|
|
|
414
414
|
syscall: string;
|
|
415
415
|
}
|
|
416
416
|
/**
|
|
417
|
-
* An error with additional information about what happened
|
|
417
|
+
* An error with additional information about what happened.
|
|
418
|
+
*
|
|
419
|
+
* @remarks
|
|
420
|
+
*
|
|
421
|
+
* `Error.captureStackTrace` is used when available to hide irrelevant stack frames.
|
|
422
|
+
* This is being standardized, however it is not available in Deno and behind a flag in Firefox.
|
|
423
|
+
* See https://github.com/tc39/proposal-error-capturestacktrace for more details.
|
|
418
424
|
*/
|
|
419
425
|
export declare class ErrnoException extends Error implements NodeJS.ErrnoException {
|
|
420
426
|
errno: Errno;
|
package/dist/error.js
CHANGED
|
@@ -406,7 +406,13 @@ export function strerror(errno) {
|
|
|
406
406
|
return (_errno in errnoMessages ? errnoMessages[_errno] : '');
|
|
407
407
|
}
|
|
408
408
|
/**
|
|
409
|
-
* An error with additional information about what happened
|
|
409
|
+
* An error with additional information about what happened.
|
|
410
|
+
*
|
|
411
|
+
* @remarks
|
|
412
|
+
*
|
|
413
|
+
* `Error.captureStackTrace` is used when available to hide irrelevant stack frames.
|
|
414
|
+
* This is being standardized, however it is not available in Deno and behind a flag in Firefox.
|
|
415
|
+
* See https://github.com/tc39/proposal-error-capturestacktrace for more details.
|
|
410
416
|
*/
|
|
411
417
|
export class ErrnoException extends Error {
|
|
412
418
|
errno;
|
|
@@ -419,6 +425,7 @@ export class ErrnoException extends Error {
|
|
|
419
425
|
this.message = message;
|
|
420
426
|
this.syscall = syscall;
|
|
421
427
|
this.code = Errno[errno];
|
|
428
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
422
429
|
}
|
|
423
430
|
toString() {
|
|
424
431
|
return this.code + ': ' + this.message;
|
|
@@ -439,6 +446,8 @@ export class ErrnoException extends Error {
|
|
|
439
446
|
return err;
|
|
440
447
|
}
|
|
441
448
|
static With(code, syscall) {
|
|
442
|
-
|
|
449
|
+
const err = new ErrnoException(Errno[code], errnoMessages[Errno[code]], syscall);
|
|
450
|
+
Error.captureStackTrace?.(err, this);
|
|
451
|
+
return err;
|
|
443
452
|
}
|
|
444
453
|
}
|
package/dist/log.d.ts
CHANGED
package/dist/log.js
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
/* Logging utilities. The things in this file are named to work nicely when you import as a namespace. */
|
|
2
2
|
import { List } from 'utilium';
|
|
3
|
+
/**
|
|
4
|
+
* The log levels
|
|
5
|
+
*/
|
|
6
|
+
export var Level;
|
|
7
|
+
(function (Level) {
|
|
8
|
+
/** Emergency */
|
|
9
|
+
Level[Level["EMERG"] = 0] = "EMERG";
|
|
10
|
+
/** Alert */
|
|
11
|
+
Level[Level["ALERT"] = 1] = "ALERT";
|
|
12
|
+
/** Critical */
|
|
13
|
+
Level[Level["CRIT"] = 2] = "CRIT";
|
|
14
|
+
/** Error */
|
|
15
|
+
Level[Level["ERR"] = 3] = "ERR";
|
|
16
|
+
/** Warning */
|
|
17
|
+
Level[Level["WARN"] = 4] = "WARN";
|
|
18
|
+
/** Notice */
|
|
19
|
+
Level[Level["NOTICE"] = 5] = "NOTICE";
|
|
20
|
+
/** Informational */
|
|
21
|
+
Level[Level["INFO"] = 6] = "INFO";
|
|
22
|
+
/** Debug */
|
|
23
|
+
Level[Level["DEBUG"] = 7] = "DEBUG";
|
|
24
|
+
})(Level || (Level = {}));
|
|
3
25
|
/** An object mapping log levels to a textual representation of them */
|
|
4
26
|
export const levels = [
|
|
5
27
|
'emergency',
|
|
@@ -39,27 +61,27 @@ function _shortcut(level) {
|
|
|
39
61
|
}
|
|
40
62
|
// Shortcuts
|
|
41
63
|
/** Shortcut for logging emergencies */
|
|
42
|
-
export const emerg = _shortcut(
|
|
64
|
+
export const emerg = _shortcut(Level.EMERG);
|
|
43
65
|
/** Shortcut for logging alerts */
|
|
44
|
-
export const alert = _shortcut(
|
|
66
|
+
export const alert = _shortcut(Level.ALERT);
|
|
45
67
|
/** Shortcut for logging critical errors */
|
|
46
|
-
export const crit = _shortcut(
|
|
68
|
+
export const crit = _shortcut(Level.CRIT);
|
|
47
69
|
/** Shortcut for logging non-critical errors */
|
|
48
|
-
export const err = _shortcut(
|
|
70
|
+
export const err = _shortcut(Level.ERR);
|
|
49
71
|
/** Shortcut for logging warnings */
|
|
50
|
-
export const warn = _shortcut(
|
|
72
|
+
export const warn = _shortcut(Level.WARN);
|
|
51
73
|
/** Shortcut for logging notices */
|
|
52
|
-
export const notice = _shortcut(
|
|
74
|
+
export const notice = _shortcut(Level.NOTICE);
|
|
53
75
|
/** Shortcut for logging informational messages */
|
|
54
|
-
export const info = _shortcut(
|
|
76
|
+
export const info = _shortcut(Level.INFO);
|
|
55
77
|
/** Shortcut for logging debug messages */
|
|
56
|
-
export const debug = _shortcut(
|
|
78
|
+
export const debug = _shortcut(Level.DEBUG);
|
|
57
79
|
/**
|
|
58
80
|
* Shortcut for logging usage of deprecated functions at runtime
|
|
59
81
|
* @param symbol The thing that is deprecated
|
|
60
82
|
*/
|
|
61
83
|
export function deprecated(symbol) {
|
|
62
|
-
log(
|
|
84
|
+
log(Level.WARN, symbol + ' is deprecated and should not be used.');
|
|
63
85
|
}
|
|
64
86
|
// Formatting and output
|
|
65
87
|
function ansi(text, format) {
|
|
@@ -78,46 +100,46 @@ function _prettyMs(entry, style) {
|
|
|
78
100
|
}
|
|
79
101
|
const levelColor = {
|
|
80
102
|
ansi: {
|
|
81
|
-
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
103
|
+
[Level.EMERG]: '1;4;37;41',
|
|
104
|
+
[Level.ALERT]: '1;37;41',
|
|
105
|
+
[Level.CRIT]: '1;35',
|
|
106
|
+
[Level.ERR]: '1;31',
|
|
107
|
+
[Level.WARN]: '1;33',
|
|
108
|
+
[Level.NOTICE]: '1;36',
|
|
109
|
+
[Level.INFO]: '1;37',
|
|
110
|
+
[Level.DEBUG]: '0;2;37',
|
|
89
111
|
},
|
|
90
112
|
css: {
|
|
91
|
-
[
|
|
92
|
-
[
|
|
93
|
-
[
|
|
94
|
-
[
|
|
95
|
-
[
|
|
96
|
-
[
|
|
97
|
-
[
|
|
98
|
-
[
|
|
113
|
+
[Level.EMERG]: 'font-weight: bold; text-decoration: underline; color: white; background-color: red;',
|
|
114
|
+
[Level.ALERT]: 'font-weight: bold; color: white; background-color: red;',
|
|
115
|
+
[Level.CRIT]: 'font-weight: bold; color: magenta;',
|
|
116
|
+
[Level.ERR]: 'font-weight: bold; color: red;',
|
|
117
|
+
[Level.WARN]: 'font-weight: bold; color: yellow;',
|
|
118
|
+
[Level.NOTICE]: 'font-weight: bold; color: cyan;',
|
|
119
|
+
[Level.INFO]: 'font-weight: bold; color: white;',
|
|
120
|
+
[Level.DEBUG]: 'opacity: 0.8; color: white;',
|
|
99
121
|
},
|
|
100
122
|
};
|
|
101
123
|
const messageColor = {
|
|
102
124
|
ansi: {
|
|
103
|
-
[
|
|
104
|
-
[
|
|
105
|
-
[
|
|
106
|
-
[
|
|
107
|
-
[
|
|
108
|
-
[
|
|
109
|
-
[
|
|
110
|
-
[
|
|
125
|
+
[Level.EMERG]: '1;31',
|
|
126
|
+
[Level.ALERT]: '1;31',
|
|
127
|
+
[Level.CRIT]: '1;31',
|
|
128
|
+
[Level.ERR]: '31',
|
|
129
|
+
[Level.WARN]: '33',
|
|
130
|
+
[Level.NOTICE]: '1;37',
|
|
131
|
+
[Level.INFO]: '37',
|
|
132
|
+
[Level.DEBUG]: '2;37',
|
|
111
133
|
},
|
|
112
134
|
css: {
|
|
113
|
-
[
|
|
114
|
-
[
|
|
115
|
-
[
|
|
116
|
-
[
|
|
117
|
-
[
|
|
118
|
-
[
|
|
119
|
-
[
|
|
120
|
-
[
|
|
135
|
+
[Level.EMERG]: 'font-weight: bold; color: red;',
|
|
136
|
+
[Level.ALERT]: 'font-weight: bold; color: red;',
|
|
137
|
+
[Level.CRIT]: 'font-weight: bold; color: red;',
|
|
138
|
+
[Level.ERR]: 'color: red;',
|
|
139
|
+
[Level.WARN]: 'color: yellow;',
|
|
140
|
+
[Level.NOTICE]: 'font-weight: bold; color: white;',
|
|
141
|
+
[Level.INFO]: 'color: white;',
|
|
142
|
+
[Level.DEBUG]: 'opacity: 0.8; color: white;',
|
|
121
143
|
},
|
|
122
144
|
};
|
|
123
145
|
/**
|
|
@@ -135,7 +157,7 @@ export function fancy({ style, colorize }) {
|
|
|
135
157
|
yield entry.message;
|
|
136
158
|
return;
|
|
137
159
|
}
|
|
138
|
-
if (entry.level <
|
|
160
|
+
if (entry.level < Level.CRIT) {
|
|
139
161
|
yield* levelText;
|
|
140
162
|
yield ': ';
|
|
141
163
|
}
|
|
@@ -156,7 +178,7 @@ function output(entry) {
|
|
|
156
178
|
return;
|
|
157
179
|
_output(...format(entry));
|
|
158
180
|
}
|
|
159
|
-
let minLevel =
|
|
181
|
+
let minLevel = Level.ALERT;
|
|
160
182
|
let includeStack = false;
|
|
161
183
|
// Configuration
|
|
162
184
|
/** Whether log entries are being recorded */
|