kerium 0.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/README.md +14 -0
- package/dist/error.d.ts +431 -0
- package/dist/error.js +444 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/log.d.ts +129 -0
- package/dist/log.js +176 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Kerium
|
|
2
|
+
|
|
3
|
+
Kerium is a small library containing some POSIX-style code.
|
|
4
|
+
The focus is on providing shared utilities for other projects.
|
|
5
|
+
|
|
6
|
+
# Logging
|
|
7
|
+
|
|
8
|
+
Kerium exposes a flexible logging API that uses the same levels as syslog.
|
|
9
|
+
|
|
10
|
+
# Errors
|
|
11
|
+
|
|
12
|
+
The entire set of POSIX errnos are exposed through the `Errno` enum.
|
|
13
|
+
The `ErrnoException` class extends the built-in `Error` with errnos, and provides JSON functionality.
|
|
14
|
+
You can use `strerror` to get a human-readable description of an errno.
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard POSIX error codes.
|
|
3
|
+
* @see https://en.wikipedia.org/wiki/Errno.h
|
|
4
|
+
*/
|
|
5
|
+
export declare enum Errno {
|
|
6
|
+
/** Operation not permitted */
|
|
7
|
+
EPERM = 1,
|
|
8
|
+
/** No such file or directory */
|
|
9
|
+
ENOENT = 2,
|
|
10
|
+
/** No such process */
|
|
11
|
+
ESRCH = 3,
|
|
12
|
+
/** Interrupted system call */
|
|
13
|
+
EINTR = 4,
|
|
14
|
+
/** Input/output error */
|
|
15
|
+
EIO = 5,
|
|
16
|
+
/** No such device or address */
|
|
17
|
+
ENXIO = 6,
|
|
18
|
+
/** Argument list too long */
|
|
19
|
+
E2BIG = 7,
|
|
20
|
+
/** Exec format error */
|
|
21
|
+
ENOEXEC = 8,
|
|
22
|
+
/** Bad file descriptor */
|
|
23
|
+
EBADF = 9,
|
|
24
|
+
/** No child processes */
|
|
25
|
+
ECHILD = 10,
|
|
26
|
+
/** Resource temporarily unavailable */
|
|
27
|
+
EAGAIN = 11,
|
|
28
|
+
/** Out of memory */
|
|
29
|
+
ENOMEM = 12,
|
|
30
|
+
/** Permission denied */
|
|
31
|
+
EACCES = 13,
|
|
32
|
+
/** Bad address */
|
|
33
|
+
EFAULT = 14,
|
|
34
|
+
/** Block device required */
|
|
35
|
+
ENOTBLK = 15,
|
|
36
|
+
/** Resource busy or locked */
|
|
37
|
+
EBUSY = 16,
|
|
38
|
+
/** File exists */
|
|
39
|
+
EEXIST = 17,
|
|
40
|
+
/** Invalid cross-device link */
|
|
41
|
+
EXDEV = 18,
|
|
42
|
+
/** No such device */
|
|
43
|
+
ENODEV = 19,
|
|
44
|
+
/** File is not a directory */
|
|
45
|
+
ENOTDIR = 20,
|
|
46
|
+
/** File is a directory */
|
|
47
|
+
EISDIR = 21,
|
|
48
|
+
/** Invalid argument */
|
|
49
|
+
EINVAL = 22,
|
|
50
|
+
/** Too many open files in system */
|
|
51
|
+
ENFILE = 23,
|
|
52
|
+
/** Too many open files */
|
|
53
|
+
EMFILE = 24,
|
|
54
|
+
/** Text file busy */
|
|
55
|
+
ETXTBSY = 26,
|
|
56
|
+
/** File is too big */
|
|
57
|
+
EFBIG = 27,
|
|
58
|
+
/** No space left on disk */
|
|
59
|
+
ENOSPC = 28,
|
|
60
|
+
/** Illegal seek */
|
|
61
|
+
ESPIPE = 29,
|
|
62
|
+
/** Cannot modify a read-only file system */
|
|
63
|
+
EROFS = 30,
|
|
64
|
+
/** Too many links */
|
|
65
|
+
EMLINK = 31,
|
|
66
|
+
/** Broken pipe */
|
|
67
|
+
EPIPE = 32,
|
|
68
|
+
/** Numerical argument out of domain */
|
|
69
|
+
EDOM = 33,
|
|
70
|
+
/** Numerical result out of range */
|
|
71
|
+
ERANGE = 34,
|
|
72
|
+
/** Resource deadlock would occur */
|
|
73
|
+
EDEADLK = 35,
|
|
74
|
+
/** File name too long */
|
|
75
|
+
ENAMETOOLONG = 36,
|
|
76
|
+
/** No locks available */
|
|
77
|
+
ENOLCK = 37,
|
|
78
|
+
/** Function not implemented */
|
|
79
|
+
ENOSYS = 38,
|
|
80
|
+
/** Directory is not empty */
|
|
81
|
+
ENOTEMPTY = 39,
|
|
82
|
+
/** Too many levels of symbolic links */
|
|
83
|
+
ELOOP = 40,
|
|
84
|
+
/** No message of desired type */
|
|
85
|
+
ENOMSG = 42,
|
|
86
|
+
/** Identifier removed */
|
|
87
|
+
EIDRM = 43,
|
|
88
|
+
/** Channel number out of range */
|
|
89
|
+
ECHRNG = 44,
|
|
90
|
+
/** Level 2 not synchronized */
|
|
91
|
+
EL2NSYNC = 45,
|
|
92
|
+
/** Level 3 halted */
|
|
93
|
+
EL3HLT = 46,
|
|
94
|
+
/** Level 3 reset */
|
|
95
|
+
EL3RST = 47,
|
|
96
|
+
/** Link number out of range */
|
|
97
|
+
ENRNG = 48,
|
|
98
|
+
/** Protocol driver not attached */
|
|
99
|
+
EUNATCH = 49,
|
|
100
|
+
/** No CSI structure available */
|
|
101
|
+
ECSI = 50,
|
|
102
|
+
/** Level 2 halted */
|
|
103
|
+
EL2HLT = 51,
|
|
104
|
+
/** Invalid exchange */
|
|
105
|
+
EBADE = 52,
|
|
106
|
+
/** Invalid request descriptor */
|
|
107
|
+
EBADR = 53,
|
|
108
|
+
/** Exchange full */
|
|
109
|
+
EXFULL = 54,
|
|
110
|
+
/** No anode */
|
|
111
|
+
ENOANO = 55,
|
|
112
|
+
/** Invalid request code */
|
|
113
|
+
EBADRQC = 56,
|
|
114
|
+
/** Invalid slot */
|
|
115
|
+
EBADSLT = 57,
|
|
116
|
+
/** Bad font file format */
|
|
117
|
+
EBFONT = 59,
|
|
118
|
+
/** Device not a stream */
|
|
119
|
+
ENOSTR = 60,
|
|
120
|
+
/** No data available */
|
|
121
|
+
ENODATA = 61,
|
|
122
|
+
/** Timer expired */
|
|
123
|
+
ETIME = 62,
|
|
124
|
+
/** Out of streams resources */
|
|
125
|
+
ENOSR = 63,
|
|
126
|
+
/** Machine is not on the network */
|
|
127
|
+
ENONET = 64,
|
|
128
|
+
/** Package not installed */
|
|
129
|
+
ENOPKG = 65,
|
|
130
|
+
/** Object is remote */
|
|
131
|
+
EREMOTE = 66,
|
|
132
|
+
/** Link has been severed */
|
|
133
|
+
ENOLINK = 67,
|
|
134
|
+
/** Advertise error */
|
|
135
|
+
EADV = 68,
|
|
136
|
+
/** Srmount error */
|
|
137
|
+
ESRMNT = 69,
|
|
138
|
+
/** Communication error on send */
|
|
139
|
+
ECOMM = 70,
|
|
140
|
+
/** Protocol error */
|
|
141
|
+
EPROTO = 71,
|
|
142
|
+
/** Multihop attempted */
|
|
143
|
+
EMULTIHOP = 72,
|
|
144
|
+
/** RFS specific error */
|
|
145
|
+
EDOTDOT = 73,
|
|
146
|
+
/** Bad message */
|
|
147
|
+
EBADMSG = 74,
|
|
148
|
+
/** Value too large for defined data type */
|
|
149
|
+
EOVERFLOW = 75,
|
|
150
|
+
/** Name not unique on network */
|
|
151
|
+
ENOTUNIQ = 76,
|
|
152
|
+
/** File descriptor in bad state */
|
|
153
|
+
EBADFD = 77,
|
|
154
|
+
/** Remote address changed */
|
|
155
|
+
EREMCHG = 78,
|
|
156
|
+
/** Can not access a needed shared library */
|
|
157
|
+
ELIBACC = 79,
|
|
158
|
+
/** Accessing a corrupted shared library */
|
|
159
|
+
ELIBBAD = 80,
|
|
160
|
+
/** .lib section in a.out corrupted */
|
|
161
|
+
ELIBSCN = 81,
|
|
162
|
+
/** Attempting to link in too many shared libraries */
|
|
163
|
+
ELIBMAX = 82,
|
|
164
|
+
/** Cannot exec a shared library directly */
|
|
165
|
+
ELIBEXEC = 83,
|
|
166
|
+
/** Invalid or incomplete multibyte or wide character */
|
|
167
|
+
EILSEQ = 84,
|
|
168
|
+
/** Interrupted system call should be restarted */
|
|
169
|
+
ERESTART = 85,
|
|
170
|
+
/** Streams pipe error */
|
|
171
|
+
ESTRPIPE = 86,
|
|
172
|
+
/** Too many users */
|
|
173
|
+
EUSERS = 87,
|
|
174
|
+
/** Socket operation on non-socket */
|
|
175
|
+
ENOTSOCK = 88,
|
|
176
|
+
/** Destination address required */
|
|
177
|
+
EDESTADDRREQ = 89,
|
|
178
|
+
/** Message too long */
|
|
179
|
+
EMSGSIZE = 90,
|
|
180
|
+
/** Protocol wrong type for socket */
|
|
181
|
+
EPROTOTYPE = 91,
|
|
182
|
+
/** Protocol not available */
|
|
183
|
+
ENOPROTOOPT = 92,
|
|
184
|
+
/** Protocol not supported */
|
|
185
|
+
EPROTONOSUPPORT = 93,
|
|
186
|
+
/** Socket type not supported */
|
|
187
|
+
ESOCKTNOSUPPORT = 94,
|
|
188
|
+
/** Operation is not supported */
|
|
189
|
+
ENOTSUP = 95,
|
|
190
|
+
/** Protocol family not supported */
|
|
191
|
+
EPFNOSUPPORT = 96,
|
|
192
|
+
/** Address family not supported by protocol */
|
|
193
|
+
EAFNOSUPPORT = 97,
|
|
194
|
+
/** Address already in use */
|
|
195
|
+
EADDRINUSE = 98,
|
|
196
|
+
/** Cannot assign requested address */
|
|
197
|
+
EADDRNOTAVAIL = 99,
|
|
198
|
+
/** Network is down */
|
|
199
|
+
ENETDOWN = 100,
|
|
200
|
+
/** Network is unreachable */
|
|
201
|
+
ENETUNREACH = 101,
|
|
202
|
+
/** Network dropped connection on reset */
|
|
203
|
+
ENETRESET = 102,
|
|
204
|
+
/** Software caused connection abort */
|
|
205
|
+
ECONNABORTED = 103,
|
|
206
|
+
/** Connection reset by peer */
|
|
207
|
+
ECONNRESET = 104,
|
|
208
|
+
/** No buffer space available */
|
|
209
|
+
ENOBUFS = 105,
|
|
210
|
+
/** Transport endpoint is already connected */
|
|
211
|
+
EISCONN = 106,
|
|
212
|
+
/** Transport endpoint is not connected */
|
|
213
|
+
ENOTCONN = 107,
|
|
214
|
+
/** Cannot send after transport endpoint shutdown */
|
|
215
|
+
ESHUTDOWN = 108,
|
|
216
|
+
/** Too many references: cannot splice */
|
|
217
|
+
ETOOMANYREFS = 109,
|
|
218
|
+
/** Connection timed out */
|
|
219
|
+
ETIMEDOUT = 110,
|
|
220
|
+
/** Connection refused */
|
|
221
|
+
ECONNREFUSED = 111,
|
|
222
|
+
/** Host is down */
|
|
223
|
+
EHOSTDOWN = 112,
|
|
224
|
+
/** No route to host */
|
|
225
|
+
EHOSTUNREACH = 113,
|
|
226
|
+
/** Operation already in progress */
|
|
227
|
+
EALREADY = 114,
|
|
228
|
+
/** Operation now in progress */
|
|
229
|
+
EINPROGRESS = 115,
|
|
230
|
+
/** Stale file handle */
|
|
231
|
+
ESTALE = 116,
|
|
232
|
+
/** Structure needs cleaning */
|
|
233
|
+
EEUCLEAN = 117,
|
|
234
|
+
/** Not a XENIX named type file */
|
|
235
|
+
ENOTNAM = 118,
|
|
236
|
+
/** No XENIX semaphores available */
|
|
237
|
+
ENAVAIL = 119,
|
|
238
|
+
/** Is a named type file */
|
|
239
|
+
EISNAM = 120,
|
|
240
|
+
/** Remote I/O error */
|
|
241
|
+
EREMOTEIO = 121,
|
|
242
|
+
/** Disk quota exceeded */
|
|
243
|
+
EDQUOT = 122,
|
|
244
|
+
/** No medium found */
|
|
245
|
+
ENOMEDIUM = 123,
|
|
246
|
+
/** Wrong medium type */
|
|
247
|
+
EMEDIUMTYPE = 124,
|
|
248
|
+
/** Operation canceled */
|
|
249
|
+
ECANCELED = 125,
|
|
250
|
+
/** Required key not available */
|
|
251
|
+
ENOKEY = 126,
|
|
252
|
+
/** Key has expired */
|
|
253
|
+
EKEYEXPIRED = 127,
|
|
254
|
+
/** Key has been revoked */
|
|
255
|
+
EKEYREVOKED = 128,
|
|
256
|
+
/** Key was rejected by service */
|
|
257
|
+
EKEYREJECTED = 129,
|
|
258
|
+
/** Owner died */
|
|
259
|
+
EOWNERDEAD = 130,
|
|
260
|
+
/** State not recoverable */
|
|
261
|
+
ENOTRECOVERABLE = 131,
|
|
262
|
+
/** Operation not possible due to RF-kill */
|
|
263
|
+
ERFKILL = 132,
|
|
264
|
+
/** Memory page has hardware error */
|
|
265
|
+
EHWPOISON = 133
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Strings associated with each error code.
|
|
269
|
+
* @internal
|
|
270
|
+
*/
|
|
271
|
+
declare const errnoMessages: {
|
|
272
|
+
readonly 1: "Operation not permitted";
|
|
273
|
+
readonly 2: "No such file or directory";
|
|
274
|
+
readonly 3: "No such process";
|
|
275
|
+
readonly 4: "Interrupted system call";
|
|
276
|
+
readonly 5: "Input/output error";
|
|
277
|
+
readonly 6: "No such device or address";
|
|
278
|
+
readonly 7: "Argument list too long";
|
|
279
|
+
readonly 8: "Exec format error";
|
|
280
|
+
readonly 9: "Bad file descriptor";
|
|
281
|
+
readonly 10: "No child processes";
|
|
282
|
+
readonly 11: "Resource temporarily unavailable";
|
|
283
|
+
readonly 12: "Out of memory";
|
|
284
|
+
readonly 13: "Permission denied";
|
|
285
|
+
readonly 14: "Bad address";
|
|
286
|
+
readonly 15: "Block device required";
|
|
287
|
+
readonly 16: "Resource busy or locked";
|
|
288
|
+
readonly 17: "File exists";
|
|
289
|
+
readonly 18: "Invalid cross-device link";
|
|
290
|
+
readonly 19: "No such device";
|
|
291
|
+
readonly 20: "File is not a directory";
|
|
292
|
+
readonly 21: "File is a directory";
|
|
293
|
+
readonly 22: "Invalid argument";
|
|
294
|
+
readonly 23: "Too many open files in system";
|
|
295
|
+
readonly 24: "Too many open files";
|
|
296
|
+
readonly 26: "Text file busy";
|
|
297
|
+
readonly 27: "File is too big";
|
|
298
|
+
readonly 28: "No space left on disk";
|
|
299
|
+
readonly 29: "Illegal seek";
|
|
300
|
+
readonly 30: "Cannot modify a read-only file system";
|
|
301
|
+
readonly 31: "Too many links";
|
|
302
|
+
readonly 32: "Broken pipe";
|
|
303
|
+
readonly 33: "Numerical argument out of domain";
|
|
304
|
+
readonly 34: "Numerical result out of range";
|
|
305
|
+
readonly 35: "Resource deadlock would occur";
|
|
306
|
+
readonly 36: "File name too long";
|
|
307
|
+
readonly 37: "No locks available";
|
|
308
|
+
readonly 38: "Function not implemented";
|
|
309
|
+
readonly 39: "Directory is not empty";
|
|
310
|
+
readonly 40: "Too many levels of symbolic links";
|
|
311
|
+
readonly 42: "No message of desired type";
|
|
312
|
+
readonly 43: "Identifier removed";
|
|
313
|
+
readonly 44: "Channel number out of range";
|
|
314
|
+
readonly 45: "Level 2 not synchronized";
|
|
315
|
+
readonly 46: "Level 3 halted";
|
|
316
|
+
readonly 47: "Level 3 reset";
|
|
317
|
+
readonly 48: "Link number out of range";
|
|
318
|
+
readonly 49: "Protocol driver not attached";
|
|
319
|
+
readonly 50: "No CSI structure available";
|
|
320
|
+
readonly 51: "Level 2 halted";
|
|
321
|
+
readonly 52: "Invalid exchange";
|
|
322
|
+
readonly 53: "Invalid request descriptor";
|
|
323
|
+
readonly 54: "Exchange full";
|
|
324
|
+
readonly 55: "No anode";
|
|
325
|
+
readonly 56: "Invalid request code";
|
|
326
|
+
readonly 57: "Invalid slot";
|
|
327
|
+
readonly 59: "Bad font file format";
|
|
328
|
+
readonly 60: "Device not a stream";
|
|
329
|
+
readonly 61: "No data available";
|
|
330
|
+
readonly 62: "Timer expired";
|
|
331
|
+
readonly 63: "Out of streams resources";
|
|
332
|
+
readonly 64: "Machine is not on the network";
|
|
333
|
+
readonly 65: "Package not installed";
|
|
334
|
+
readonly 66: "Object is remote";
|
|
335
|
+
readonly 67: "Link has been severed";
|
|
336
|
+
readonly 68: "Advertise error";
|
|
337
|
+
readonly 69: "Srmount error";
|
|
338
|
+
readonly 70: "Communication error on send";
|
|
339
|
+
readonly 71: "Protocol error";
|
|
340
|
+
readonly 72: "Multihop attempted";
|
|
341
|
+
readonly 73: "RFS specific error";
|
|
342
|
+
readonly 74: "Bad message";
|
|
343
|
+
readonly 75: "Value too large for defined data type";
|
|
344
|
+
readonly 76: "Name not unique on network";
|
|
345
|
+
readonly 77: "File descriptor in bad state";
|
|
346
|
+
readonly 78: "Remote address changed";
|
|
347
|
+
readonly 79: "Can not access a needed shared library";
|
|
348
|
+
readonly 80: "Accessing a corrupted shared library";
|
|
349
|
+
readonly 81: ".lib section in a.out corrupted";
|
|
350
|
+
readonly 82: "Attempting to link in too many shared libraries";
|
|
351
|
+
readonly 83: "Cannot exec a shared library directly";
|
|
352
|
+
readonly 84: "Invalid or incomplete multibyte or wide character";
|
|
353
|
+
readonly 85: "Interrupted system call should be restarted";
|
|
354
|
+
readonly 86: "Streams pipe error";
|
|
355
|
+
readonly 87: "Too many users";
|
|
356
|
+
readonly 88: "Socket operation on non-socket";
|
|
357
|
+
readonly 89: "Destination address required";
|
|
358
|
+
readonly 90: "Message too long";
|
|
359
|
+
readonly 91: "Protocol wrong type for socket";
|
|
360
|
+
readonly 92: "Protocol not available";
|
|
361
|
+
readonly 93: "Protocol not supported";
|
|
362
|
+
readonly 94: "Socket type not supported";
|
|
363
|
+
readonly 95: "Operation is not supported";
|
|
364
|
+
readonly 96: "Protocol family not supported";
|
|
365
|
+
readonly 97: "Address family not supported by protocol";
|
|
366
|
+
readonly 98: "Address already in use";
|
|
367
|
+
readonly 99: "Cannot assign requested address";
|
|
368
|
+
readonly 100: "Network is down";
|
|
369
|
+
readonly 101: "Network is unreachable";
|
|
370
|
+
readonly 102: "Network dropped connection on reset";
|
|
371
|
+
readonly 103: "Software caused connection abort";
|
|
372
|
+
readonly 104: "Connection reset by peer";
|
|
373
|
+
readonly 105: "No buffer space available";
|
|
374
|
+
readonly 106: "Transport endpoint is already connected";
|
|
375
|
+
readonly 107: "Transport endpoint is not connected";
|
|
376
|
+
readonly 108: "Cannot send after transport endpoint shutdown";
|
|
377
|
+
readonly 109: "Too many references: cannot splice";
|
|
378
|
+
readonly 110: "Connection timed out";
|
|
379
|
+
readonly 111: "Connection refused";
|
|
380
|
+
readonly 112: "Host is down";
|
|
381
|
+
readonly 113: "No route to host";
|
|
382
|
+
readonly 114: "Operation already in progress";
|
|
383
|
+
readonly 115: "Operation now in progress";
|
|
384
|
+
readonly 116: "Stale file handle";
|
|
385
|
+
readonly 117: "Structure needs cleaning";
|
|
386
|
+
readonly 118: "Not a XENIX named type file";
|
|
387
|
+
readonly 119: "No XENIX semaphores available";
|
|
388
|
+
readonly 120: "Is a named type file";
|
|
389
|
+
readonly 121: "Remote I/O error";
|
|
390
|
+
readonly 122: "Disk quota exceeded";
|
|
391
|
+
readonly 123: "No medium found";
|
|
392
|
+
readonly 124: "Wrong medium type";
|
|
393
|
+
readonly 125: "Operation canceled";
|
|
394
|
+
readonly 126: "Required key not available";
|
|
395
|
+
readonly 127: "Key has expired";
|
|
396
|
+
readonly 128: "Key has been revoked";
|
|
397
|
+
readonly 129: "Key was rejected by service";
|
|
398
|
+
readonly 130: "Owner died";
|
|
399
|
+
readonly 131: "State not recoverable";
|
|
400
|
+
readonly 132: "Operation not possible due to RF-kill";
|
|
401
|
+
readonly 133: "Memory page has hardware error";
|
|
402
|
+
};
|
|
403
|
+
type ErrnoMessage<T extends Errno | keyof typeof Errno> = (typeof errnoMessages)[T extends Errno ? T : T extends keyof typeof Errno ? (typeof Errno)[T] : ''];
|
|
404
|
+
export declare function strerror<const T extends Errno | keyof typeof Errno>(errno: T): ErrnoMessage<T>;
|
|
405
|
+
/**
|
|
406
|
+
* JSON representation of an error.
|
|
407
|
+
*/
|
|
408
|
+
export interface ErrnoExceptionJSON {
|
|
409
|
+
errno: Errno;
|
|
410
|
+
message: string;
|
|
411
|
+
path?: string;
|
|
412
|
+
code: keyof typeof Errno;
|
|
413
|
+
stack: string;
|
|
414
|
+
syscall: string;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* An error with additional information about what happened
|
|
418
|
+
*/
|
|
419
|
+
export declare class ErrnoException extends Error implements NodeJS.ErrnoException {
|
|
420
|
+
errno: Errno;
|
|
421
|
+
message: string;
|
|
422
|
+
syscall: string;
|
|
423
|
+
stack: string;
|
|
424
|
+
code: keyof typeof Errno;
|
|
425
|
+
constructor(errno: Errno, message?: string, syscall?: string);
|
|
426
|
+
toString(): string;
|
|
427
|
+
toJSON(): ErrnoExceptionJSON;
|
|
428
|
+
static fromJSON(json: ErrnoExceptionJSON): ErrnoException;
|
|
429
|
+
static With(code: keyof typeof Errno, syscall?: string): ErrnoException;
|
|
430
|
+
}
|
|
431
|
+
export {};
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard POSIX error codes.
|
|
3
|
+
* @see https://en.wikipedia.org/wiki/Errno.h
|
|
4
|
+
*/
|
|
5
|
+
export var Errno;
|
|
6
|
+
(function (Errno) {
|
|
7
|
+
/** Operation not permitted */
|
|
8
|
+
Errno[Errno["EPERM"] = 1] = "EPERM";
|
|
9
|
+
/** No such file or directory */
|
|
10
|
+
Errno[Errno["ENOENT"] = 2] = "ENOENT";
|
|
11
|
+
/** No such process */
|
|
12
|
+
Errno[Errno["ESRCH"] = 3] = "ESRCH";
|
|
13
|
+
/** Interrupted system call */
|
|
14
|
+
Errno[Errno["EINTR"] = 4] = "EINTR";
|
|
15
|
+
/** Input/output error */
|
|
16
|
+
Errno[Errno["EIO"] = 5] = "EIO";
|
|
17
|
+
/** No such device or address */
|
|
18
|
+
Errno[Errno["ENXIO"] = 6] = "ENXIO";
|
|
19
|
+
/** Argument list too long */
|
|
20
|
+
Errno[Errno["E2BIG"] = 7] = "E2BIG";
|
|
21
|
+
/** Exec format error */
|
|
22
|
+
Errno[Errno["ENOEXEC"] = 8] = "ENOEXEC";
|
|
23
|
+
/** Bad file descriptor */
|
|
24
|
+
Errno[Errno["EBADF"] = 9] = "EBADF";
|
|
25
|
+
/** No child processes */
|
|
26
|
+
Errno[Errno["ECHILD"] = 10] = "ECHILD";
|
|
27
|
+
/** Resource temporarily unavailable */
|
|
28
|
+
Errno[Errno["EAGAIN"] = 11] = "EAGAIN";
|
|
29
|
+
/** Out of memory */
|
|
30
|
+
Errno[Errno["ENOMEM"] = 12] = "ENOMEM";
|
|
31
|
+
/** Permission denied */
|
|
32
|
+
Errno[Errno["EACCES"] = 13] = "EACCES";
|
|
33
|
+
/** Bad address */
|
|
34
|
+
Errno[Errno["EFAULT"] = 14] = "EFAULT";
|
|
35
|
+
/** Block device required */
|
|
36
|
+
Errno[Errno["ENOTBLK"] = 15] = "ENOTBLK";
|
|
37
|
+
/** Resource busy or locked */
|
|
38
|
+
Errno[Errno["EBUSY"] = 16] = "EBUSY";
|
|
39
|
+
/** File exists */
|
|
40
|
+
Errno[Errno["EEXIST"] = 17] = "EEXIST";
|
|
41
|
+
/** Invalid cross-device link */
|
|
42
|
+
Errno[Errno["EXDEV"] = 18] = "EXDEV";
|
|
43
|
+
/** No such device */
|
|
44
|
+
Errno[Errno["ENODEV"] = 19] = "ENODEV";
|
|
45
|
+
/** File is not a directory */
|
|
46
|
+
Errno[Errno["ENOTDIR"] = 20] = "ENOTDIR";
|
|
47
|
+
/** File is a directory */
|
|
48
|
+
Errno[Errno["EISDIR"] = 21] = "EISDIR";
|
|
49
|
+
/** Invalid argument */
|
|
50
|
+
Errno[Errno["EINVAL"] = 22] = "EINVAL";
|
|
51
|
+
/** Too many open files in system */
|
|
52
|
+
Errno[Errno["ENFILE"] = 23] = "ENFILE";
|
|
53
|
+
/** Too many open files */
|
|
54
|
+
Errno[Errno["EMFILE"] = 24] = "EMFILE";
|
|
55
|
+
/** Text file busy */
|
|
56
|
+
Errno[Errno["ETXTBSY"] = 26] = "ETXTBSY";
|
|
57
|
+
/** File is too big */
|
|
58
|
+
Errno[Errno["EFBIG"] = 27] = "EFBIG";
|
|
59
|
+
/** No space left on disk */
|
|
60
|
+
Errno[Errno["ENOSPC"] = 28] = "ENOSPC";
|
|
61
|
+
/** Illegal seek */
|
|
62
|
+
Errno[Errno["ESPIPE"] = 29] = "ESPIPE";
|
|
63
|
+
/** Cannot modify a read-only file system */
|
|
64
|
+
Errno[Errno["EROFS"] = 30] = "EROFS";
|
|
65
|
+
/** Too many links */
|
|
66
|
+
Errno[Errno["EMLINK"] = 31] = "EMLINK";
|
|
67
|
+
/** Broken pipe */
|
|
68
|
+
Errno[Errno["EPIPE"] = 32] = "EPIPE";
|
|
69
|
+
/** Numerical argument out of domain */
|
|
70
|
+
Errno[Errno["EDOM"] = 33] = "EDOM";
|
|
71
|
+
/** Numerical result out of range */
|
|
72
|
+
Errno[Errno["ERANGE"] = 34] = "ERANGE";
|
|
73
|
+
/** Resource deadlock would occur */
|
|
74
|
+
Errno[Errno["EDEADLK"] = 35] = "EDEADLK";
|
|
75
|
+
/** File name too long */
|
|
76
|
+
Errno[Errno["ENAMETOOLONG"] = 36] = "ENAMETOOLONG";
|
|
77
|
+
/** No locks available */
|
|
78
|
+
Errno[Errno["ENOLCK"] = 37] = "ENOLCK";
|
|
79
|
+
/** Function not implemented */
|
|
80
|
+
Errno[Errno["ENOSYS"] = 38] = "ENOSYS";
|
|
81
|
+
/** Directory is not empty */
|
|
82
|
+
Errno[Errno["ENOTEMPTY"] = 39] = "ENOTEMPTY";
|
|
83
|
+
/** Too many levels of symbolic links */
|
|
84
|
+
Errno[Errno["ELOOP"] = 40] = "ELOOP";
|
|
85
|
+
/** No message of desired type */
|
|
86
|
+
Errno[Errno["ENOMSG"] = 42] = "ENOMSG";
|
|
87
|
+
/** Identifier removed */
|
|
88
|
+
Errno[Errno["EIDRM"] = 43] = "EIDRM";
|
|
89
|
+
/** Channel number out of range */
|
|
90
|
+
Errno[Errno["ECHRNG"] = 44] = "ECHRNG";
|
|
91
|
+
/** Level 2 not synchronized */
|
|
92
|
+
Errno[Errno["EL2NSYNC"] = 45] = "EL2NSYNC";
|
|
93
|
+
/** Level 3 halted */
|
|
94
|
+
Errno[Errno["EL3HLT"] = 46] = "EL3HLT";
|
|
95
|
+
/** Level 3 reset */
|
|
96
|
+
Errno[Errno["EL3RST"] = 47] = "EL3RST";
|
|
97
|
+
/** Link number out of range */
|
|
98
|
+
Errno[Errno["ENRNG"] = 48] = "ENRNG";
|
|
99
|
+
/** Protocol driver not attached */
|
|
100
|
+
Errno[Errno["EUNATCH"] = 49] = "EUNATCH";
|
|
101
|
+
/** No CSI structure available */
|
|
102
|
+
Errno[Errno["ECSI"] = 50] = "ECSI";
|
|
103
|
+
/** Level 2 halted */
|
|
104
|
+
Errno[Errno["EL2HLT"] = 51] = "EL2HLT";
|
|
105
|
+
/** Invalid exchange */
|
|
106
|
+
Errno[Errno["EBADE"] = 52] = "EBADE";
|
|
107
|
+
/** Invalid request descriptor */
|
|
108
|
+
Errno[Errno["EBADR"] = 53] = "EBADR";
|
|
109
|
+
/** Exchange full */
|
|
110
|
+
Errno[Errno["EXFULL"] = 54] = "EXFULL";
|
|
111
|
+
/** No anode */
|
|
112
|
+
Errno[Errno["ENOANO"] = 55] = "ENOANO";
|
|
113
|
+
/** Invalid request code */
|
|
114
|
+
Errno[Errno["EBADRQC"] = 56] = "EBADRQC";
|
|
115
|
+
/** Invalid slot */
|
|
116
|
+
Errno[Errno["EBADSLT"] = 57] = "EBADSLT";
|
|
117
|
+
/** Bad font file format */
|
|
118
|
+
Errno[Errno["EBFONT"] = 59] = "EBFONT";
|
|
119
|
+
/** Device not a stream */
|
|
120
|
+
Errno[Errno["ENOSTR"] = 60] = "ENOSTR";
|
|
121
|
+
/** No data available */
|
|
122
|
+
Errno[Errno["ENODATA"] = 61] = "ENODATA";
|
|
123
|
+
/** Timer expired */
|
|
124
|
+
Errno[Errno["ETIME"] = 62] = "ETIME";
|
|
125
|
+
/** Out of streams resources */
|
|
126
|
+
Errno[Errno["ENOSR"] = 63] = "ENOSR";
|
|
127
|
+
/** Machine is not on the network */
|
|
128
|
+
Errno[Errno["ENONET"] = 64] = "ENONET";
|
|
129
|
+
/** Package not installed */
|
|
130
|
+
Errno[Errno["ENOPKG"] = 65] = "ENOPKG";
|
|
131
|
+
/** Object is remote */
|
|
132
|
+
Errno[Errno["EREMOTE"] = 66] = "EREMOTE";
|
|
133
|
+
/** Link has been severed */
|
|
134
|
+
Errno[Errno["ENOLINK"] = 67] = "ENOLINK";
|
|
135
|
+
/** Advertise error */
|
|
136
|
+
Errno[Errno["EADV"] = 68] = "EADV";
|
|
137
|
+
/** Srmount error */
|
|
138
|
+
Errno[Errno["ESRMNT"] = 69] = "ESRMNT";
|
|
139
|
+
/** Communication error on send */
|
|
140
|
+
Errno[Errno["ECOMM"] = 70] = "ECOMM";
|
|
141
|
+
/** Protocol error */
|
|
142
|
+
Errno[Errno["EPROTO"] = 71] = "EPROTO";
|
|
143
|
+
/** Multihop attempted */
|
|
144
|
+
Errno[Errno["EMULTIHOP"] = 72] = "EMULTIHOP";
|
|
145
|
+
/** RFS specific error */
|
|
146
|
+
Errno[Errno["EDOTDOT"] = 73] = "EDOTDOT";
|
|
147
|
+
/** Bad message */
|
|
148
|
+
Errno[Errno["EBADMSG"] = 74] = "EBADMSG";
|
|
149
|
+
/** Value too large for defined data type */
|
|
150
|
+
Errno[Errno["EOVERFLOW"] = 75] = "EOVERFLOW";
|
|
151
|
+
/** Name not unique on network */
|
|
152
|
+
Errno[Errno["ENOTUNIQ"] = 76] = "ENOTUNIQ";
|
|
153
|
+
/** File descriptor in bad state */
|
|
154
|
+
Errno[Errno["EBADFD"] = 77] = "EBADFD";
|
|
155
|
+
/** Remote address changed */
|
|
156
|
+
Errno[Errno["EREMCHG"] = 78] = "EREMCHG";
|
|
157
|
+
/** Can not access a needed shared library */
|
|
158
|
+
Errno[Errno["ELIBACC"] = 79] = "ELIBACC";
|
|
159
|
+
/** Accessing a corrupted shared library */
|
|
160
|
+
Errno[Errno["ELIBBAD"] = 80] = "ELIBBAD";
|
|
161
|
+
/** .lib section in a.out corrupted */
|
|
162
|
+
Errno[Errno["ELIBSCN"] = 81] = "ELIBSCN";
|
|
163
|
+
/** Attempting to link in too many shared libraries */
|
|
164
|
+
Errno[Errno["ELIBMAX"] = 82] = "ELIBMAX";
|
|
165
|
+
/** Cannot exec a shared library directly */
|
|
166
|
+
Errno[Errno["ELIBEXEC"] = 83] = "ELIBEXEC";
|
|
167
|
+
/** Invalid or incomplete multibyte or wide character */
|
|
168
|
+
Errno[Errno["EILSEQ"] = 84] = "EILSEQ";
|
|
169
|
+
/** Interrupted system call should be restarted */
|
|
170
|
+
Errno[Errno["ERESTART"] = 85] = "ERESTART";
|
|
171
|
+
/** Streams pipe error */
|
|
172
|
+
Errno[Errno["ESTRPIPE"] = 86] = "ESTRPIPE";
|
|
173
|
+
/** Too many users */
|
|
174
|
+
Errno[Errno["EUSERS"] = 87] = "EUSERS";
|
|
175
|
+
/** Socket operation on non-socket */
|
|
176
|
+
Errno[Errno["ENOTSOCK"] = 88] = "ENOTSOCK";
|
|
177
|
+
/** Destination address required */
|
|
178
|
+
Errno[Errno["EDESTADDRREQ"] = 89] = "EDESTADDRREQ";
|
|
179
|
+
/** Message too long */
|
|
180
|
+
Errno[Errno["EMSGSIZE"] = 90] = "EMSGSIZE";
|
|
181
|
+
/** Protocol wrong type for socket */
|
|
182
|
+
Errno[Errno["EPROTOTYPE"] = 91] = "EPROTOTYPE";
|
|
183
|
+
/** Protocol not available */
|
|
184
|
+
Errno[Errno["ENOPROTOOPT"] = 92] = "ENOPROTOOPT";
|
|
185
|
+
/** Protocol not supported */
|
|
186
|
+
Errno[Errno["EPROTONOSUPPORT"] = 93] = "EPROTONOSUPPORT";
|
|
187
|
+
/** Socket type not supported */
|
|
188
|
+
Errno[Errno["ESOCKTNOSUPPORT"] = 94] = "ESOCKTNOSUPPORT";
|
|
189
|
+
/** Operation is not supported */
|
|
190
|
+
Errno[Errno["ENOTSUP"] = 95] = "ENOTSUP";
|
|
191
|
+
/** Protocol family not supported */
|
|
192
|
+
Errno[Errno["EPFNOSUPPORT"] = 96] = "EPFNOSUPPORT";
|
|
193
|
+
/** Address family not supported by protocol */
|
|
194
|
+
Errno[Errno["EAFNOSUPPORT"] = 97] = "EAFNOSUPPORT";
|
|
195
|
+
/** Address already in use */
|
|
196
|
+
Errno[Errno["EADDRINUSE"] = 98] = "EADDRINUSE";
|
|
197
|
+
/** Cannot assign requested address */
|
|
198
|
+
Errno[Errno["EADDRNOTAVAIL"] = 99] = "EADDRNOTAVAIL";
|
|
199
|
+
/** Network is down */
|
|
200
|
+
Errno[Errno["ENETDOWN"] = 100] = "ENETDOWN";
|
|
201
|
+
/** Network is unreachable */
|
|
202
|
+
Errno[Errno["ENETUNREACH"] = 101] = "ENETUNREACH";
|
|
203
|
+
/** Network dropped connection on reset */
|
|
204
|
+
Errno[Errno["ENETRESET"] = 102] = "ENETRESET";
|
|
205
|
+
/** Software caused connection abort */
|
|
206
|
+
Errno[Errno["ECONNABORTED"] = 103] = "ECONNABORTED";
|
|
207
|
+
/** Connection reset by peer */
|
|
208
|
+
Errno[Errno["ECONNRESET"] = 104] = "ECONNRESET";
|
|
209
|
+
/** No buffer space available */
|
|
210
|
+
Errno[Errno["ENOBUFS"] = 105] = "ENOBUFS";
|
|
211
|
+
/** Transport endpoint is already connected */
|
|
212
|
+
Errno[Errno["EISCONN"] = 106] = "EISCONN";
|
|
213
|
+
/** Transport endpoint is not connected */
|
|
214
|
+
Errno[Errno["ENOTCONN"] = 107] = "ENOTCONN";
|
|
215
|
+
/** Cannot send after transport endpoint shutdown */
|
|
216
|
+
Errno[Errno["ESHUTDOWN"] = 108] = "ESHUTDOWN";
|
|
217
|
+
/** Too many references: cannot splice */
|
|
218
|
+
Errno[Errno["ETOOMANYREFS"] = 109] = "ETOOMANYREFS";
|
|
219
|
+
/** Connection timed out */
|
|
220
|
+
Errno[Errno["ETIMEDOUT"] = 110] = "ETIMEDOUT";
|
|
221
|
+
/** Connection refused */
|
|
222
|
+
Errno[Errno["ECONNREFUSED"] = 111] = "ECONNREFUSED";
|
|
223
|
+
/** Host is down */
|
|
224
|
+
Errno[Errno["EHOSTDOWN"] = 112] = "EHOSTDOWN";
|
|
225
|
+
/** No route to host */
|
|
226
|
+
Errno[Errno["EHOSTUNREACH"] = 113] = "EHOSTUNREACH";
|
|
227
|
+
/** Operation already in progress */
|
|
228
|
+
Errno[Errno["EALREADY"] = 114] = "EALREADY";
|
|
229
|
+
/** Operation now in progress */
|
|
230
|
+
Errno[Errno["EINPROGRESS"] = 115] = "EINPROGRESS";
|
|
231
|
+
/** Stale file handle */
|
|
232
|
+
Errno[Errno["ESTALE"] = 116] = "ESTALE";
|
|
233
|
+
/** Structure needs cleaning */
|
|
234
|
+
Errno[Errno["EEUCLEAN"] = 117] = "EEUCLEAN";
|
|
235
|
+
/** Not a XENIX named type file */
|
|
236
|
+
Errno[Errno["ENOTNAM"] = 118] = "ENOTNAM";
|
|
237
|
+
/** No XENIX semaphores available */
|
|
238
|
+
Errno[Errno["ENAVAIL"] = 119] = "ENAVAIL";
|
|
239
|
+
/** Is a named type file */
|
|
240
|
+
Errno[Errno["EISNAM"] = 120] = "EISNAM";
|
|
241
|
+
/** Remote I/O error */
|
|
242
|
+
Errno[Errno["EREMOTEIO"] = 121] = "EREMOTEIO";
|
|
243
|
+
/** Disk quota exceeded */
|
|
244
|
+
Errno[Errno["EDQUOT"] = 122] = "EDQUOT";
|
|
245
|
+
/** No medium found */
|
|
246
|
+
Errno[Errno["ENOMEDIUM"] = 123] = "ENOMEDIUM";
|
|
247
|
+
/** Wrong medium type */
|
|
248
|
+
Errno[Errno["EMEDIUMTYPE"] = 124] = "EMEDIUMTYPE";
|
|
249
|
+
/** Operation canceled */
|
|
250
|
+
Errno[Errno["ECANCELED"] = 125] = "ECANCELED";
|
|
251
|
+
/** Required key not available */
|
|
252
|
+
Errno[Errno["ENOKEY"] = 126] = "ENOKEY";
|
|
253
|
+
/** Key has expired */
|
|
254
|
+
Errno[Errno["EKEYEXPIRED"] = 127] = "EKEYEXPIRED";
|
|
255
|
+
/** Key has been revoked */
|
|
256
|
+
Errno[Errno["EKEYREVOKED"] = 128] = "EKEYREVOKED";
|
|
257
|
+
/** Key was rejected by service */
|
|
258
|
+
Errno[Errno["EKEYREJECTED"] = 129] = "EKEYREJECTED";
|
|
259
|
+
/** Owner died */
|
|
260
|
+
Errno[Errno["EOWNERDEAD"] = 130] = "EOWNERDEAD";
|
|
261
|
+
/** State not recoverable */
|
|
262
|
+
Errno[Errno["ENOTRECOVERABLE"] = 131] = "ENOTRECOVERABLE";
|
|
263
|
+
/** Operation not possible due to RF-kill */
|
|
264
|
+
Errno[Errno["ERFKILL"] = 132] = "ERFKILL";
|
|
265
|
+
/** Memory page has hardware error */
|
|
266
|
+
Errno[Errno["EHWPOISON"] = 133] = "EHWPOISON";
|
|
267
|
+
})(Errno || (Errno = {}));
|
|
268
|
+
/**
|
|
269
|
+
* Strings associated with each error code.
|
|
270
|
+
* @internal
|
|
271
|
+
*/
|
|
272
|
+
const errnoMessages = {
|
|
273
|
+
[Errno.EPERM]: 'Operation not permitted',
|
|
274
|
+
[Errno.ENOENT]: 'No such file or directory',
|
|
275
|
+
[Errno.ESRCH]: 'No such process',
|
|
276
|
+
[Errno.EINTR]: 'Interrupted system call',
|
|
277
|
+
[Errno.EIO]: 'Input/output error',
|
|
278
|
+
[Errno.ENXIO]: 'No such device or address',
|
|
279
|
+
[Errno.E2BIG]: 'Argument list too long',
|
|
280
|
+
[Errno.ENOEXEC]: 'Exec format error',
|
|
281
|
+
[Errno.EBADF]: 'Bad file descriptor',
|
|
282
|
+
[Errno.ECHILD]: 'No child processes',
|
|
283
|
+
[Errno.EAGAIN]: 'Resource temporarily unavailable',
|
|
284
|
+
[Errno.ENOMEM]: 'Out of memory',
|
|
285
|
+
[Errno.EACCES]: 'Permission denied',
|
|
286
|
+
[Errno.EFAULT]: 'Bad address',
|
|
287
|
+
[Errno.ENOTBLK]: 'Block device required',
|
|
288
|
+
[Errno.EBUSY]: 'Resource busy or locked',
|
|
289
|
+
[Errno.EEXIST]: 'File exists',
|
|
290
|
+
[Errno.EXDEV]: 'Invalid cross-device link',
|
|
291
|
+
[Errno.ENODEV]: 'No such device',
|
|
292
|
+
[Errno.ENOTDIR]: 'File is not a directory',
|
|
293
|
+
[Errno.EISDIR]: 'File is a directory',
|
|
294
|
+
[Errno.EINVAL]: 'Invalid argument',
|
|
295
|
+
[Errno.ENFILE]: 'Too many open files in system',
|
|
296
|
+
[Errno.EMFILE]: 'Too many open files',
|
|
297
|
+
[Errno.ETXTBSY]: 'Text file busy',
|
|
298
|
+
[Errno.EFBIG]: 'File is too big',
|
|
299
|
+
[Errno.ENOSPC]: 'No space left on disk',
|
|
300
|
+
[Errno.ESPIPE]: 'Illegal seek',
|
|
301
|
+
[Errno.EROFS]: 'Cannot modify a read-only file system',
|
|
302
|
+
[Errno.EMLINK]: 'Too many links',
|
|
303
|
+
[Errno.EPIPE]: 'Broken pipe',
|
|
304
|
+
[Errno.EDOM]: 'Numerical argument out of domain',
|
|
305
|
+
[Errno.ERANGE]: 'Numerical result out of range',
|
|
306
|
+
[Errno.EDEADLK]: 'Resource deadlock would occur',
|
|
307
|
+
[Errno.ENAMETOOLONG]: 'File name too long',
|
|
308
|
+
[Errno.ENOLCK]: 'No locks available',
|
|
309
|
+
[Errno.ENOSYS]: 'Function not implemented',
|
|
310
|
+
[Errno.ENOTEMPTY]: 'Directory is not empty',
|
|
311
|
+
[Errno.ELOOP]: 'Too many levels of symbolic links',
|
|
312
|
+
[Errno.ENOMSG]: 'No message of desired type',
|
|
313
|
+
[Errno.EIDRM]: 'Identifier removed',
|
|
314
|
+
[Errno.ECHRNG]: 'Channel number out of range',
|
|
315
|
+
[Errno.EL2NSYNC]: 'Level 2 not synchronized',
|
|
316
|
+
[Errno.EL3HLT]: 'Level 3 halted',
|
|
317
|
+
[Errno.EL3RST]: 'Level 3 reset',
|
|
318
|
+
[Errno.ENRNG]: 'Link number out of range',
|
|
319
|
+
[Errno.EUNATCH]: 'Protocol driver not attached',
|
|
320
|
+
[Errno.ECSI]: 'No CSI structure available',
|
|
321
|
+
[Errno.EL2HLT]: 'Level 2 halted',
|
|
322
|
+
[Errno.EBADE]: 'Invalid exchange',
|
|
323
|
+
[Errno.EBADR]: 'Invalid request descriptor',
|
|
324
|
+
[Errno.EXFULL]: 'Exchange full',
|
|
325
|
+
[Errno.ENOANO]: 'No anode',
|
|
326
|
+
[Errno.EBADRQC]: 'Invalid request code',
|
|
327
|
+
[Errno.EBADSLT]: 'Invalid slot',
|
|
328
|
+
[Errno.EBFONT]: 'Bad font file format',
|
|
329
|
+
[Errno.ENOSTR]: 'Device not a stream',
|
|
330
|
+
[Errno.ENODATA]: 'No data available',
|
|
331
|
+
[Errno.ETIME]: 'Timer expired',
|
|
332
|
+
[Errno.ENOSR]: 'Out of streams resources',
|
|
333
|
+
[Errno.ENONET]: 'Machine is not on the network',
|
|
334
|
+
[Errno.ENOPKG]: 'Package not installed',
|
|
335
|
+
[Errno.EREMOTE]: 'Object is remote',
|
|
336
|
+
[Errno.ENOLINK]: 'Link has been severed',
|
|
337
|
+
[Errno.EADV]: 'Advertise error',
|
|
338
|
+
[Errno.ESRMNT]: 'Srmount error',
|
|
339
|
+
[Errno.ECOMM]: 'Communication error on send',
|
|
340
|
+
[Errno.EPROTO]: 'Protocol error',
|
|
341
|
+
[Errno.EMULTIHOP]: 'Multihop attempted',
|
|
342
|
+
[Errno.EDOTDOT]: 'RFS specific error',
|
|
343
|
+
[Errno.EBADMSG]: 'Bad message',
|
|
344
|
+
[Errno.EOVERFLOW]: 'Value too large for defined data type',
|
|
345
|
+
[Errno.ENOTUNIQ]: 'Name not unique on network',
|
|
346
|
+
[Errno.EBADFD]: 'File descriptor in bad state',
|
|
347
|
+
[Errno.EREMCHG]: 'Remote address changed',
|
|
348
|
+
[Errno.ELIBACC]: 'Can not access a needed shared library',
|
|
349
|
+
[Errno.ELIBBAD]: 'Accessing a corrupted shared library',
|
|
350
|
+
[Errno.ELIBSCN]: '.lib section in a.out corrupted',
|
|
351
|
+
[Errno.ELIBMAX]: 'Attempting to link in too many shared libraries',
|
|
352
|
+
[Errno.ELIBEXEC]: 'Cannot exec a shared library directly',
|
|
353
|
+
[Errno.EILSEQ]: 'Invalid or incomplete multibyte or wide character',
|
|
354
|
+
[Errno.ERESTART]: 'Interrupted system call should be restarted',
|
|
355
|
+
[Errno.ESTRPIPE]: 'Streams pipe error',
|
|
356
|
+
[Errno.EUSERS]: 'Too many users',
|
|
357
|
+
[Errno.ENOTSOCK]: 'Socket operation on non-socket',
|
|
358
|
+
[Errno.EDESTADDRREQ]: 'Destination address required',
|
|
359
|
+
[Errno.EMSGSIZE]: 'Message too long',
|
|
360
|
+
[Errno.EPROTOTYPE]: 'Protocol wrong type for socket',
|
|
361
|
+
[Errno.ENOPROTOOPT]: 'Protocol not available',
|
|
362
|
+
[Errno.EPROTONOSUPPORT]: 'Protocol not supported',
|
|
363
|
+
[Errno.ESOCKTNOSUPPORT]: 'Socket type not supported',
|
|
364
|
+
[Errno.ENOTSUP]: 'Operation is not supported',
|
|
365
|
+
[Errno.EPFNOSUPPORT]: 'Protocol family not supported',
|
|
366
|
+
[Errno.EAFNOSUPPORT]: 'Address family not supported by protocol',
|
|
367
|
+
[Errno.EADDRINUSE]: 'Address already in use',
|
|
368
|
+
[Errno.EADDRNOTAVAIL]: 'Cannot assign requested address',
|
|
369
|
+
[Errno.ENETDOWN]: 'Network is down',
|
|
370
|
+
[Errno.ENETUNREACH]: 'Network is unreachable',
|
|
371
|
+
[Errno.ENETRESET]: 'Network dropped connection on reset',
|
|
372
|
+
[Errno.ECONNABORTED]: 'Software caused connection abort',
|
|
373
|
+
[Errno.ECONNRESET]: 'Connection reset by peer',
|
|
374
|
+
[Errno.ENOBUFS]: 'No buffer space available',
|
|
375
|
+
[Errno.EISCONN]: 'Transport endpoint is already connected',
|
|
376
|
+
[Errno.ENOTCONN]: 'Transport endpoint is not connected',
|
|
377
|
+
[Errno.ESHUTDOWN]: 'Cannot send after transport endpoint shutdown',
|
|
378
|
+
[Errno.ETOOMANYREFS]: 'Too many references: cannot splice',
|
|
379
|
+
[Errno.ETIMEDOUT]: 'Connection timed out',
|
|
380
|
+
[Errno.ECONNREFUSED]: 'Connection refused',
|
|
381
|
+
[Errno.EHOSTDOWN]: 'Host is down',
|
|
382
|
+
[Errno.EHOSTUNREACH]: 'No route to host',
|
|
383
|
+
[Errno.EALREADY]: 'Operation already in progress',
|
|
384
|
+
[Errno.EINPROGRESS]: 'Operation now in progress',
|
|
385
|
+
[Errno.ESTALE]: 'Stale file handle',
|
|
386
|
+
[Errno.EEUCLEAN]: 'Structure needs cleaning',
|
|
387
|
+
[Errno.ENOTNAM]: 'Not a XENIX named type file',
|
|
388
|
+
[Errno.ENAVAIL]: 'No XENIX semaphores available',
|
|
389
|
+
[Errno.EISNAM]: 'Is a named type file',
|
|
390
|
+
[Errno.EREMOTEIO]: 'Remote I/O error',
|
|
391
|
+
[Errno.EDQUOT]: 'Disk quota exceeded',
|
|
392
|
+
[Errno.ENOMEDIUM]: 'No medium found',
|
|
393
|
+
[Errno.EMEDIUMTYPE]: 'Wrong medium type',
|
|
394
|
+
[Errno.ECANCELED]: 'Operation canceled',
|
|
395
|
+
[Errno.ENOKEY]: 'Required key not available',
|
|
396
|
+
[Errno.EKEYEXPIRED]: 'Key has expired',
|
|
397
|
+
[Errno.EKEYREVOKED]: 'Key has been revoked',
|
|
398
|
+
[Errno.EKEYREJECTED]: 'Key was rejected by service',
|
|
399
|
+
[Errno.EOWNERDEAD]: 'Owner died',
|
|
400
|
+
[Errno.ENOTRECOVERABLE]: 'State not recoverable',
|
|
401
|
+
[Errno.ERFKILL]: 'Operation not possible due to RF-kill',
|
|
402
|
+
[Errno.EHWPOISON]: 'Memory page has hardware error',
|
|
403
|
+
};
|
|
404
|
+
export function strerror(errno) {
|
|
405
|
+
const _errno = typeof errno == 'string' ? Errno[errno] : errno;
|
|
406
|
+
return (_errno in errnoMessages ? errnoMessages[_errno] : '');
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* An error with additional information about what happened
|
|
410
|
+
*/
|
|
411
|
+
export class ErrnoException extends Error {
|
|
412
|
+
errno;
|
|
413
|
+
message;
|
|
414
|
+
syscall;
|
|
415
|
+
code;
|
|
416
|
+
constructor(errno, message = errnoMessages[errno], syscall = '') {
|
|
417
|
+
super(message);
|
|
418
|
+
this.errno = errno;
|
|
419
|
+
this.message = message;
|
|
420
|
+
this.syscall = syscall;
|
|
421
|
+
this.code = Errno[errno];
|
|
422
|
+
}
|
|
423
|
+
toString() {
|
|
424
|
+
return this.code + ': ' + this.message;
|
|
425
|
+
}
|
|
426
|
+
toJSON() {
|
|
427
|
+
return {
|
|
428
|
+
errno: this.errno,
|
|
429
|
+
code: this.code,
|
|
430
|
+
stack: this.stack,
|
|
431
|
+
message: this.message,
|
|
432
|
+
syscall: this.syscall,
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
static fromJSON(json) {
|
|
436
|
+
const err = new ErrnoException(json.errno, json.message, json.syscall);
|
|
437
|
+
err.code = json.code;
|
|
438
|
+
err.stack = json.stack;
|
|
439
|
+
return err;
|
|
440
|
+
}
|
|
441
|
+
static With(code, syscall) {
|
|
442
|
+
return new ErrnoException(Errno[code], errnoMessages[Errno[code]], syscall);
|
|
443
|
+
}
|
|
444
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/log.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { List } from 'utilium';
|
|
2
|
+
/**
|
|
3
|
+
* The log levels
|
|
4
|
+
*/
|
|
5
|
+
export declare const enum Level {
|
|
6
|
+
/** Emergency */
|
|
7
|
+
EMERG = 0,
|
|
8
|
+
/** Alert */
|
|
9
|
+
ALERT = 1,
|
|
10
|
+
/** Critical */
|
|
11
|
+
CRIT = 2,
|
|
12
|
+
/** Error */
|
|
13
|
+
ERR = 3,
|
|
14
|
+
/** Warning */
|
|
15
|
+
WARN = 4,
|
|
16
|
+
/** Notice */
|
|
17
|
+
NOTICE = 5,
|
|
18
|
+
/** Informational */
|
|
19
|
+
INFO = 6,
|
|
20
|
+
/** Debug */
|
|
21
|
+
DEBUG = 7
|
|
22
|
+
}
|
|
23
|
+
/** An object mapping log levels to a textual representation of them */
|
|
24
|
+
export declare const levels: readonly ["emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"];
|
|
25
|
+
export declare function levelOf(value: (typeof levels)[Level]): Level;
|
|
26
|
+
/** A log entry */
|
|
27
|
+
export interface Entry {
|
|
28
|
+
level: Level;
|
|
29
|
+
timestamp: Date;
|
|
30
|
+
elapsedMs: number;
|
|
31
|
+
message: string;
|
|
32
|
+
}
|
|
33
|
+
/** The list of log entries */
|
|
34
|
+
export declare const entries: List<Entry>;
|
|
35
|
+
/**
|
|
36
|
+
* Log a message
|
|
37
|
+
*/
|
|
38
|
+
export declare function log(level: Level, message: string): void;
|
|
39
|
+
/** Shortcut for logging emergencies */
|
|
40
|
+
export declare const emerg: <T extends {
|
|
41
|
+
toString(): string;
|
|
42
|
+
} | Error>(message: T) => T;
|
|
43
|
+
/** Shortcut for logging alerts */
|
|
44
|
+
export declare const alert: <T extends {
|
|
45
|
+
toString(): string;
|
|
46
|
+
} | Error>(message: T) => T;
|
|
47
|
+
/** Shortcut for logging critical errors */
|
|
48
|
+
export declare const crit: <T extends {
|
|
49
|
+
toString(): string;
|
|
50
|
+
} | Error>(message: T) => T;
|
|
51
|
+
/** Shortcut for logging non-critical errors */
|
|
52
|
+
export declare const err: <T extends {
|
|
53
|
+
toString(): string;
|
|
54
|
+
} | Error>(message: T) => T;
|
|
55
|
+
/** Shortcut for logging warnings */
|
|
56
|
+
export declare const warn: <T extends {
|
|
57
|
+
toString(): string;
|
|
58
|
+
} | Error>(message: T) => T;
|
|
59
|
+
/** Shortcut for logging notices */
|
|
60
|
+
export declare const notice: <T extends {
|
|
61
|
+
toString(): string;
|
|
62
|
+
} | Error>(message: T) => T;
|
|
63
|
+
/** Shortcut for logging informational messages */
|
|
64
|
+
export declare const info: <T extends {
|
|
65
|
+
toString(): string;
|
|
66
|
+
} | Error>(message: T) => T;
|
|
67
|
+
/** Shortcut for logging debug messages */
|
|
68
|
+
export declare const debug: <T extends {
|
|
69
|
+
toString(): string;
|
|
70
|
+
} | Error>(message: T) => T;
|
|
71
|
+
/**
|
|
72
|
+
* Shortcut for logging usage of deprecated functions at runtime
|
|
73
|
+
* @param symbol The thing that is deprecated
|
|
74
|
+
*/
|
|
75
|
+
export declare function deprecated(symbol: string): void;
|
|
76
|
+
export interface FormatOptions {
|
|
77
|
+
/**
|
|
78
|
+
* Whether to use ANSI escape codes (e.g. for Xterm) or CSS (for browsers) to colorize the log
|
|
79
|
+
*/
|
|
80
|
+
style: 'ansi' | 'css';
|
|
81
|
+
/**
|
|
82
|
+
* How to colorize the message:
|
|
83
|
+
* - `level`: Colorize the level.
|
|
84
|
+
* - `message`: Colorize the message. For EMERG and ALERT, the level is also included.
|
|
85
|
+
*/
|
|
86
|
+
colorize: 'level' | 'message';
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Various format functions included to make using the logger easier.
|
|
90
|
+
* These are not the only formats you can use.
|
|
91
|
+
*/
|
|
92
|
+
export declare function fancy({ style, colorize }: FormatOptions): (entry: Entry) => Generator<string, void, unknown>;
|
|
93
|
+
export declare function format(entry: Entry): string[];
|
|
94
|
+
/** Whether log entries are being recorded */
|
|
95
|
+
export declare let isEnabled: boolean;
|
|
96
|
+
export interface Configuration {
|
|
97
|
+
/**
|
|
98
|
+
* If false, log messages will not be recorded or outputted
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
enabled?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* The minimum level needed to output a message
|
|
104
|
+
* @default Level.ALERT
|
|
105
|
+
*/
|
|
106
|
+
level?: Level | (typeof levels)[Level];
|
|
107
|
+
/**
|
|
108
|
+
* Whether to include stack traces.
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
stack?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Formats a log entry into a string
|
|
114
|
+
* @default `[${ms / 1000}] ${message}`
|
|
115
|
+
*/
|
|
116
|
+
format?(this: void, entry: Entry): string | Iterable<string>;
|
|
117
|
+
/**
|
|
118
|
+
* Outputs a log message
|
|
119
|
+
* @default console.error()
|
|
120
|
+
*/
|
|
121
|
+
output?(this: void, ...message: string[]): unknown;
|
|
122
|
+
/**
|
|
123
|
+
* If set, output() all current entries after `configure` is done
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
dumpBacklog?: boolean;
|
|
127
|
+
}
|
|
128
|
+
/** Configure logging behavior */
|
|
129
|
+
export declare function configure(options: Configuration): void;
|
package/dist/log.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/* Logging utilities. The things in this file are named to work nicely when you import as a namespace. */
|
|
2
|
+
import { List } from 'utilium';
|
|
3
|
+
/** An object mapping log levels to a textual representation of them */
|
|
4
|
+
export const levels = [
|
|
5
|
+
'emergency',
|
|
6
|
+
'alert',
|
|
7
|
+
'critical',
|
|
8
|
+
'error',
|
|
9
|
+
'warning',
|
|
10
|
+
'notice',
|
|
11
|
+
'info',
|
|
12
|
+
'debug',
|
|
13
|
+
];
|
|
14
|
+
export function levelOf(value) {
|
|
15
|
+
return levels.indexOf(value);
|
|
16
|
+
}
|
|
17
|
+
/** The list of log entries */
|
|
18
|
+
export const entries = new List();
|
|
19
|
+
/**
|
|
20
|
+
* Log a message
|
|
21
|
+
*/
|
|
22
|
+
export function log(level, message) {
|
|
23
|
+
if (!isEnabled)
|
|
24
|
+
return;
|
|
25
|
+
const entry = {
|
|
26
|
+
level,
|
|
27
|
+
message,
|
|
28
|
+
timestamp: new Date(),
|
|
29
|
+
elapsedMs: performance.now(),
|
|
30
|
+
};
|
|
31
|
+
entries.add(entry);
|
|
32
|
+
output(entry);
|
|
33
|
+
}
|
|
34
|
+
function _shortcut(level) {
|
|
35
|
+
return function (message) {
|
|
36
|
+
log(level, message.toString());
|
|
37
|
+
return message;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Shortcuts
|
|
41
|
+
/** Shortcut for logging emergencies */
|
|
42
|
+
export const emerg = _shortcut(0 /* Level.EMERG */);
|
|
43
|
+
/** Shortcut for logging alerts */
|
|
44
|
+
export const alert = _shortcut(1 /* Level.ALERT */);
|
|
45
|
+
/** Shortcut for logging critical errors */
|
|
46
|
+
export const crit = _shortcut(2 /* Level.CRIT */);
|
|
47
|
+
/** Shortcut for logging non-critical errors */
|
|
48
|
+
export const err = _shortcut(3 /* Level.ERR */);
|
|
49
|
+
/** Shortcut for logging warnings */
|
|
50
|
+
export const warn = _shortcut(4 /* Level.WARN */);
|
|
51
|
+
/** Shortcut for logging notices */
|
|
52
|
+
export const notice = _shortcut(5 /* Level.NOTICE */);
|
|
53
|
+
/** Shortcut for logging informational messages */
|
|
54
|
+
export const info = _shortcut(6 /* Level.INFO */);
|
|
55
|
+
/** Shortcut for logging debug messages */
|
|
56
|
+
export const debug = _shortcut(7 /* Level.DEBUG */);
|
|
57
|
+
/**
|
|
58
|
+
* Shortcut for logging usage of deprecated functions at runtime
|
|
59
|
+
* @param symbol The thing that is deprecated
|
|
60
|
+
*/
|
|
61
|
+
export function deprecated(symbol) {
|
|
62
|
+
log(4 /* Level.WARN */, symbol + ' is deprecated and should not be used.');
|
|
63
|
+
}
|
|
64
|
+
// Formatting and output
|
|
65
|
+
function ansi(text, format) {
|
|
66
|
+
return `\x1b[${format}m${text}\x1b[0m`;
|
|
67
|
+
}
|
|
68
|
+
function _prettyMs(entry, style) {
|
|
69
|
+
const text = '[' + (entry.elapsedMs / 1000).toFixed(3).padStart(10) + '] ';
|
|
70
|
+
switch (style) {
|
|
71
|
+
case 'ansi':
|
|
72
|
+
return [ansi(text, '2;37')];
|
|
73
|
+
case 'css':
|
|
74
|
+
return ['%c' + text, 'opacity: 0.8; color: white;'];
|
|
75
|
+
default:
|
|
76
|
+
return [text];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const levelColor = {
|
|
80
|
+
ansi: {
|
|
81
|
+
[0 /* Level.EMERG */]: '1;4;37;41',
|
|
82
|
+
[1 /* Level.ALERT */]: '1;37;41',
|
|
83
|
+
[2 /* Level.CRIT */]: '1;35',
|
|
84
|
+
[3 /* Level.ERR */]: '1;31',
|
|
85
|
+
[4 /* Level.WARN */]: '1;33',
|
|
86
|
+
[5 /* Level.NOTICE */]: '1;36',
|
|
87
|
+
[6 /* Level.INFO */]: '1;37',
|
|
88
|
+
[7 /* Level.DEBUG */]: '0;2;37',
|
|
89
|
+
},
|
|
90
|
+
css: {
|
|
91
|
+
[0 /* Level.EMERG */]: 'font-weight: bold; text-decoration: underline; color: white; background-color: red;',
|
|
92
|
+
[1 /* Level.ALERT */]: 'font-weight: bold; color: white; background-color: red;',
|
|
93
|
+
[2 /* Level.CRIT */]: 'font-weight: bold; color: magenta;',
|
|
94
|
+
[3 /* Level.ERR */]: 'font-weight: bold; color: red;',
|
|
95
|
+
[4 /* Level.WARN */]: 'font-weight: bold; color: yellow;',
|
|
96
|
+
[5 /* Level.NOTICE */]: 'font-weight: bold; color: cyan;',
|
|
97
|
+
[6 /* Level.INFO */]: 'font-weight: bold; color: white;',
|
|
98
|
+
[7 /* Level.DEBUG */]: 'opacity: 0.8; color: white;',
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
const messageColor = {
|
|
102
|
+
ansi: {
|
|
103
|
+
[0 /* Level.EMERG */]: '1;31',
|
|
104
|
+
[1 /* Level.ALERT */]: '1;31',
|
|
105
|
+
[2 /* Level.CRIT */]: '1;31',
|
|
106
|
+
[3 /* Level.ERR */]: '31',
|
|
107
|
+
[4 /* Level.WARN */]: '33',
|
|
108
|
+
[5 /* Level.NOTICE */]: '1;37',
|
|
109
|
+
[6 /* Level.INFO */]: '37',
|
|
110
|
+
[7 /* Level.DEBUG */]: '2;37',
|
|
111
|
+
},
|
|
112
|
+
css: {
|
|
113
|
+
[0 /* Level.EMERG */]: 'font-weight: bold; color: red;',
|
|
114
|
+
[1 /* Level.ALERT */]: 'font-weight: bold; color: red;',
|
|
115
|
+
[2 /* Level.CRIT */]: 'font-weight: bold; color: red;',
|
|
116
|
+
[3 /* Level.ERR */]: 'color: red;',
|
|
117
|
+
[4 /* Level.WARN */]: 'color: yellow;',
|
|
118
|
+
[5 /* Level.NOTICE */]: 'font-weight: bold; color: white;',
|
|
119
|
+
[6 /* Level.INFO */]: 'color: white;',
|
|
120
|
+
[7 /* Level.DEBUG */]: 'opacity: 0.8; color: white;',
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Various format functions included to make using the logger easier.
|
|
125
|
+
* These are not the only formats you can use.
|
|
126
|
+
*/
|
|
127
|
+
export function fancy({ style, colorize }) {
|
|
128
|
+
return function* (entry) {
|
|
129
|
+
yield* _prettyMs(entry, style);
|
|
130
|
+
const levelText = style == 'ansi'
|
|
131
|
+
? [ansi(levels[entry.level].toUpperCase(), levelColor.ansi[entry.level])]
|
|
132
|
+
: ['%c' + levels[entry.level].toUpperCase(), levelColor.css[entry.level]];
|
|
133
|
+
if (colorize == 'level') {
|
|
134
|
+
yield* levelText;
|
|
135
|
+
yield entry.message;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (entry.level < 2 /* Level.CRIT */) {
|
|
139
|
+
yield* levelText;
|
|
140
|
+
yield ': ';
|
|
141
|
+
}
|
|
142
|
+
if (colorize == 'message')
|
|
143
|
+
yield ansi(entry.message, messageColor.ansi[entry.level]);
|
|
144
|
+
else
|
|
145
|
+
yield* ['%c' + entry.message, messageColor.css[entry.level]];
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
let _format = (entry) => [..._prettyMs(entry), entry.message];
|
|
149
|
+
export function format(entry) {
|
|
150
|
+
const formatted = _format(entry);
|
|
151
|
+
return typeof formatted == 'string' ? [formatted] : Array.from(formatted);
|
|
152
|
+
}
|
|
153
|
+
let _output = console.error;
|
|
154
|
+
function output(entry) {
|
|
155
|
+
if (entry.level > minLevel)
|
|
156
|
+
return;
|
|
157
|
+
_output(...format(entry));
|
|
158
|
+
}
|
|
159
|
+
let minLevel = 1 /* Level.ALERT */;
|
|
160
|
+
let includeStack = false;
|
|
161
|
+
// Configuration
|
|
162
|
+
/** Whether log entries are being recorded */
|
|
163
|
+
export let isEnabled = true;
|
|
164
|
+
/** Configure logging behavior */
|
|
165
|
+
export function configure(options) {
|
|
166
|
+
_format = options.format ?? _format;
|
|
167
|
+
_output = options.output ?? _output;
|
|
168
|
+
minLevel = typeof options.level == 'string' ? levelOf(options.level) : (options.level ?? minLevel);
|
|
169
|
+
isEnabled = options.enabled ?? isEnabled;
|
|
170
|
+
includeStack = options.stack ?? includeStack;
|
|
171
|
+
if (!options.dumpBacklog)
|
|
172
|
+
return;
|
|
173
|
+
for (const entry of entries) {
|
|
174
|
+
output(entry);
|
|
175
|
+
}
|
|
176
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kerium",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "POSIX-style errors, logging, and more",
|
|
5
|
+
"author": "James Prevett <jp@jamespre.dev> (https://jamespre.dev)",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/james-pre/kerium.git"
|
|
9
|
+
},
|
|
10
|
+
"funding": {
|
|
11
|
+
"type": "individual",
|
|
12
|
+
"url": "https://github.com/sponsors/james-pre"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/james-pre/kerium#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/james-pre/kerium/issues"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"format:check": "prettier --check .",
|
|
27
|
+
"format": "prettier --write .",
|
|
28
|
+
"lint": "tsc --noEmit && eslint src",
|
|
29
|
+
"test": "tsx --test",
|
|
30
|
+
"prepublishOnly": "npx tsc"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@eslint/js": "^9.12.0",
|
|
34
|
+
"@types/node": "^20.12.7",
|
|
35
|
+
"eslint": "^9.12.0",
|
|
36
|
+
"prettier": "^3.2.5",
|
|
37
|
+
"tsx": "^4.19.1",
|
|
38
|
+
"typedoc": "^0.27.6",
|
|
39
|
+
"typescript": "^5.7.2",
|
|
40
|
+
"typescript-eslint": "^8.8.0"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"utilium": "^2.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|