kerium 0.1.0 → 1.0.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.
- package/dist/log.d.ts +1 -1
- package/dist/log.js +65 -43
- package/package.json +5 -1
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 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kerium",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "POSIX-style errors, logging, and more",
|
|
5
5
|
"author": "James Prevett <jp@jamespre.dev> (https://jamespre.dev)",
|
|
6
6
|
"repository": {
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"type": "module",
|
|
20
20
|
"main": "dist/index.js",
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./dist/index.js",
|
|
24
|
+
"./log": "./dist/log.js"
|
|
25
|
+
},
|
|
22
26
|
"files": [
|
|
23
27
|
"dist"
|
|
24
28
|
],
|