zeddemore-logger 2.1.2 → 2.2.2
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 +1 -1
- package/lib/ZeddemoreBase.js +4 -4
- package/lib/ZeddemoreLogger.js +120 -117
- package/lib/ZeddemoreLoggerController.js +27 -17
- package/lib/defaults.js +5 -14
- package/lib/enums.js +40 -40
- package/lib/logging.js +37 -25
- package/lib/mappings/color_mappings.js +8 -10
- package/lib/mappings/log_mappings.js +16 -9
- package/lib/zeddemore-logger.js +5 -4
- package/package.json +1 -2
- package/lib/ZeddemoreProgressMultibar.js +0 -776
package/lib/enums.js
CHANGED
|
@@ -22,28 +22,6 @@ const ansiColors = {
|
|
|
22
22
|
LOG_LEVEL_WARNING: 33, // yellow
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const apiLogLevelCaptions = {
|
|
26
|
-
DEFAULT: 'Default',
|
|
27
|
-
ERROR: 'Error',
|
|
28
|
-
WARNING: 'Warning',
|
|
29
|
-
INFO: 'Info',
|
|
30
|
-
HTTP: 'HTTP',
|
|
31
|
-
VERBOSE: 'Verbose',
|
|
32
|
-
DEBUG: 'Debug',
|
|
33
|
-
SILLY: 'Silly',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const apiLogLevels = {
|
|
37
|
-
DEFAULT: -1,
|
|
38
|
-
ERROR: 0,
|
|
39
|
-
WARNING: 1,
|
|
40
|
-
INFO: 2,
|
|
41
|
-
HTTP: 3,
|
|
42
|
-
VERBOSE: 4,
|
|
43
|
-
DEBUG: 5,
|
|
44
|
-
SILLY: 6,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
25
|
const chalkFormats = {
|
|
48
26
|
ANSI: 'ansi',
|
|
49
27
|
HEX: 'hex',
|
|
@@ -55,14 +33,6 @@ const chalkLayers = {
|
|
|
55
33
|
FOREGROUND: 'fg',
|
|
56
34
|
};
|
|
57
35
|
|
|
58
|
-
const databaseOperations = {
|
|
59
|
-
DELETE: 'DELETE',
|
|
60
|
-
INSERT: 'INSERT',
|
|
61
|
-
SELECT: 'SELECT',
|
|
62
|
-
TRUNCATE: 'TRUNCATE',
|
|
63
|
-
UPDATE: 'UPDATE',
|
|
64
|
-
};
|
|
65
|
-
|
|
66
36
|
const hexColors = {
|
|
67
37
|
BEARDON_RED: '#951A1D',
|
|
68
38
|
BLACK: '#000000',
|
|
@@ -81,11 +51,18 @@ const hexColors = {
|
|
|
81
51
|
HTTP_POST: '#F4DA7A',
|
|
82
52
|
HTTP_PUT: '#74AEF6',
|
|
83
53
|
HTTP_TRACE: '#FFFFFF',
|
|
54
|
+
PACKAGE_ANGULARJS: '#C04737',
|
|
55
|
+
PACKAGE_AXIOS: '#6200e1',
|
|
84
56
|
PACKAGE_EXPRESS: '#F7DF1E',
|
|
57
|
+
PACKAGE_HANDLEBARS: '#F0772B',
|
|
58
|
+
PACKAGE_JIMP: '#FF0000',
|
|
85
59
|
PACKAGE_MYSQL: '#00618A',
|
|
86
60
|
PACKAGE_NODE_JS: '#689F63',
|
|
61
|
+
PACKAGE_PASSPORT: '#51E492',
|
|
87
62
|
PACKAGE_POSTGRESQL: '#336791',
|
|
63
|
+
PACKAGE_REDIS: '#C23936',
|
|
88
64
|
PACKAGE_SEQUELIZE: '#00AFEF',
|
|
65
|
+
PACKAGE_ZEDDEMORE: '#E2B68F',
|
|
89
66
|
};
|
|
90
67
|
|
|
91
68
|
const httpStatusCodeGroups = {
|
|
@@ -122,6 +99,11 @@ const httpResponseHeaders = {
|
|
|
122
99
|
CONTENT_LENGTH: 'Content-Length',
|
|
123
100
|
};
|
|
124
101
|
|
|
102
|
+
const logLevelTypes = {
|
|
103
|
+
CONSOLE: 'console',
|
|
104
|
+
EMAIL: 'email',
|
|
105
|
+
};
|
|
106
|
+
|
|
125
107
|
const morganFormats = {
|
|
126
108
|
COMBINED: 'combined',
|
|
127
109
|
COMMON: 'common',
|
|
@@ -151,10 +133,18 @@ const morganFormatTokens = {
|
|
|
151
133
|
USER_AGENT: 'user-agent',
|
|
152
134
|
};
|
|
153
135
|
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
136
|
+
const winstonFormats = {
|
|
137
|
+
COLORIZE: 'colorize',
|
|
138
|
+
JSON: 'json',
|
|
139
|
+
METADATA: 'metadata',
|
|
140
|
+
PRETTY_PRINT: 'pretty_print',
|
|
141
|
+
SIMPLE: 'simple',
|
|
142
|
+
SPLAT: 'splat',
|
|
143
|
+
TIMESTAMP: 'timestamp',
|
|
144
|
+
ZEDDEMORE_INFO_MUTATION: 'zeddemore_info_mutation',
|
|
145
|
+
ZEDDEMORE_LABEL: 'zeddemore_label',
|
|
146
|
+
ZEDDEMORE_PRINTF: 'zeddemore_printf',
|
|
147
|
+
ZEDDEMORE_TIMESTAMP: 'zeddemore_timestamp',
|
|
158
148
|
};
|
|
159
149
|
|
|
160
150
|
const winstonLogLevelNames = {
|
|
@@ -178,28 +168,38 @@ const winstonLogLevels = {
|
|
|
178
168
|
SILLY: 6,
|
|
179
169
|
};
|
|
180
170
|
|
|
181
|
-
const
|
|
171
|
+
const winstonTransports = {
|
|
182
172
|
CONSOLE: 'console',
|
|
183
173
|
EMAIL: 'email',
|
|
184
174
|
};
|
|
185
175
|
|
|
176
|
+
const zeddemoreLogLevelCaptions = {
|
|
177
|
+
DEFAULT: 'Default',
|
|
178
|
+
ERROR: 'Error',
|
|
179
|
+
WARNING: 'Warning',
|
|
180
|
+
INFO: 'Info',
|
|
181
|
+
HTTP: 'HTTP',
|
|
182
|
+
VERBOSE: 'Verbose',
|
|
183
|
+
DEBUG: 'Debug',
|
|
184
|
+
SILLY: 'Silly',
|
|
185
|
+
};
|
|
186
|
+
|
|
186
187
|
module.exports = {
|
|
187
188
|
doesEnumInclude,
|
|
188
189
|
ansiColors,
|
|
189
|
-
apiLogLevelCaptions,
|
|
190
|
-
apiLogLevels,
|
|
191
190
|
chalkFormats,
|
|
192
191
|
chalkLayers,
|
|
193
|
-
databaseOperations,
|
|
194
192
|
hexColors,
|
|
195
193
|
httpStatusCodeGroups,
|
|
196
194
|
httpMethods,
|
|
197
195
|
httpRequestHeaders,
|
|
198
196
|
httpResponseHeaders,
|
|
197
|
+
logLevelTypes,
|
|
199
198
|
morganFormats,
|
|
200
199
|
morganFormatTokens,
|
|
201
|
-
|
|
200
|
+
winstonFormats,
|
|
202
201
|
winstonLogLevelNames,
|
|
203
202
|
winstonLogLevels,
|
|
204
|
-
|
|
203
|
+
winstonTransports,
|
|
204
|
+
zeddemoreLogLevelCaptions,
|
|
205
205
|
};
|
package/lib/logging.js
CHANGED
|
@@ -4,7 +4,7 @@ const _ = require('lodash');
|
|
|
4
4
|
|
|
5
5
|
const defaults = require('./defaults');
|
|
6
6
|
const enums = require('./enums');
|
|
7
|
-
const { logLevelMap } = require('./mappings/log_mappings');
|
|
7
|
+
const { logLevelMap, transportMap } = require('./mappings/log_mappings');
|
|
8
8
|
|
|
9
9
|
const { doesEnumInclude } = enums;
|
|
10
10
|
|
|
@@ -12,47 +12,57 @@ function isMorganFormat(format) {
|
|
|
12
12
|
return doesEnumInclude(enums.morganFormats, format);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
function isWinstonFormat(format) {
|
|
16
|
+
return doesEnumInclude(enums.winstonFormats, format);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function isWinstonLogLevel(level) {
|
|
20
|
+
if (!_.isInteger(level) && (!_.isString(level) || !level.length)) return false;
|
|
21
|
+
if (_.isInteger(level)) return isWinstonLogLevelId(level);
|
|
22
|
+
if (_.isString(level)) return isWinstonLogLevelName(level);
|
|
19
23
|
return false;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
function
|
|
23
|
-
if (!_.isInteger(
|
|
24
|
-
return !!(_.find(logLevelMap, { winstonLevel:
|
|
26
|
+
function isWinstonLogLevelId(id) {
|
|
27
|
+
if (!_.isInteger(id)) return false;
|
|
28
|
+
return !!(_.find(logLevelMap, { winstonLevel: id }))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isWinstonLogLevelName(name) {
|
|
32
|
+
if (!_.isString(name)) return false;
|
|
33
|
+
return !!(_.find(logLevelMap, { winstonName: name }))
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
return !!(_.find(logLevelMap, { winstonName: logLevelName }))
|
|
36
|
+
function isWinstonTransport(winstonTransport) {
|
|
37
|
+
return doesEnumInclude(enums.winstonTransports, winstonTransport);
|
|
30
38
|
}
|
|
31
39
|
|
|
32
|
-
function
|
|
33
|
-
return
|
|
40
|
+
function transportLogLevelType(transport) {
|
|
41
|
+
if (!isWinstonTransport(transport)) return defaults.logLevelType;
|
|
42
|
+
const transportEntry = _.find(transportMap, { transport });
|
|
43
|
+
return (transportEntry ? transportEntry.type : null) || defaults.logLevelType;
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
/**
|
|
37
|
-
* Convert a log level ID to a
|
|
47
|
+
* Convert a Winston log level ID to a name
|
|
38
48
|
* @param levelId {number}
|
|
39
49
|
* @returns {string}
|
|
40
50
|
*/
|
|
41
|
-
function
|
|
42
|
-
if (!
|
|
51
|
+
function winstonLogLevelIdName(levelId) {
|
|
52
|
+
if (!isWinstonLogLevelId(levelId)) return defaults.winstonLogLevelName;
|
|
43
53
|
const logLevelEntry = _.find(logLevelMap, { winstonLevel: levelId });
|
|
44
54
|
return (logLevelEntry ? logLevelEntry.winstonName : null) || defaults.winstonLogLevelName;
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
/**
|
|
48
|
-
* Convert a log level to a
|
|
58
|
+
* Convert a Winston log level to a name
|
|
49
59
|
* @param logLevel {number|string}
|
|
50
60
|
* @returns {string}
|
|
51
61
|
*/
|
|
52
|
-
function
|
|
53
|
-
if (!
|
|
62
|
+
function winstonLogLevelName(logLevel) {
|
|
63
|
+
if (!isWinstonLogLevel(logLevel)) return defaults.winstonLogLevelName;
|
|
54
64
|
if (_.isString(logLevel)) return logLevel;
|
|
55
|
-
return
|
|
65
|
+
return winstonLogLevelIdName(logLevel);
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
/**
|
|
@@ -73,10 +83,12 @@ function monkeyPatchConsole(methodNames = [ defaults.consoleDirExtensionMethodNa
|
|
|
73
83
|
|
|
74
84
|
module.exports = {
|
|
75
85
|
isMorganFormat,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
logLevelToWinstonLogLevelName,
|
|
86
|
+
isWinstonFormat,
|
|
87
|
+
isWinstonLogLevel,
|
|
88
|
+
isWinstonLogLevelId,
|
|
89
|
+
isWinstonTransport,
|
|
81
90
|
monkeyPatchConsole,
|
|
91
|
+
transportLogLevelType,
|
|
92
|
+
winstonLogLevelIdName,
|
|
93
|
+
winstonLogLevelName,
|
|
82
94
|
};
|
|
@@ -3,15 +3,7 @@
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
const enums = require('../enums');
|
|
5
5
|
|
|
6
|
-
const { ansiColors: ac,
|
|
7
|
-
|
|
8
|
-
const databaseOperationColors = [
|
|
9
|
-
{ match: dbo.DELETE, style: { format: cf.HEX, fore: hc.DB_DELETE, back: null } },
|
|
10
|
-
{ match: dbo.INSERT, style: { format: cf.HEX, fore: hc.DB_INSERT, back: null } },
|
|
11
|
-
{ match: dbo.SELECT, style: { format: cf.HEX, fore: hc.DB_SELECT, back: null } },
|
|
12
|
-
{ match: dbo.TRUNCATE, style: { format: cf.HEX, fore: hc.DB_TRUNCATE, back: null } },
|
|
13
|
-
{ match: dbo.UPDATE, style: { format: cf.HEX, fore: hc.DB_UPDATE, back: null } },
|
|
14
|
-
];
|
|
6
|
+
const { ansiColors: ac, chalkFormats: cf, hexColors: hc, httpMethods: http, winstonLogLevelNames: wlln } = enums;
|
|
15
7
|
|
|
16
8
|
const httpStatusColors = [
|
|
17
9
|
{ range: _.range(500, 600), style: { format: cf.ANSI, fore: ac.HTTP_SERVER_ERROR, back: null } },
|
|
@@ -44,15 +36,21 @@ const logLevelColors = [
|
|
|
44
36
|
];
|
|
45
37
|
|
|
46
38
|
const packageColors = [
|
|
39
|
+
{ match: 'AngularJS', style: { format: cf.HEX, fore: hc.PACKAGE_ANGULARJS, back: null } },
|
|
40
|
+
{ match: 'Axios', style: { format: cf.HEX, fore: hc.PACKAGE_AXIOS, back: null } },
|
|
47
41
|
{ match: 'express', style: { format: cf.HEX, fore: hc.PACKAGE_EXPRESS, back: null } },
|
|
42
|
+
{ match: 'Handlebars', style: { format: cf.HEX, fore: hc.PACKAGE_HANDLEBARS, back: null } },
|
|
43
|
+
{ match: 'Jimp', style: { format: cf.HEX, fore: hc.PACKAGE_JIMP, back: null } },
|
|
48
44
|
{ match: 'MySQL', style: { format: cf.HEX, fore: hc.PACKAGE_MYSQL, back: null } },
|
|
49
45
|
{ match: 'Node.js', style: { format: cf.HEX, fore: hc.PACKAGE_NODE_JS, back: null } },
|
|
46
|
+
{ match: 'passport', style: { format: cf.HEX, fore: hc.PACKAGE_PASSPORT, back: null } },
|
|
50
47
|
{ match: 'PostgreSQL', style: { format: cf.HEX, fore: hc.PACKAGE_POSTGRESQL, back: null } },
|
|
48
|
+
{ match: 'Redis', style: { format: cf.HEX, fore: hc.PACKAGE_REDIS, back: null } },
|
|
51
49
|
{ match: 'sequelize', style: { format: cf.HEX, fore: hc.PACKAGE_SEQUELIZE, back: null } },
|
|
50
|
+
{ match: 'Zeddemore', style: { format: cf.HEX, fore: hc.PACKAGE_ZEDDEMORE, back: null } },
|
|
52
51
|
];
|
|
53
52
|
|
|
54
53
|
module.exports = {
|
|
55
|
-
databaseOperationColors,
|
|
56
54
|
httpStatusColors,
|
|
57
55
|
httpVerbColors,
|
|
58
56
|
logLevelColors,
|
|
@@ -2,19 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
const enums = require('../enums');
|
|
4
4
|
|
|
5
|
-
const {
|
|
5
|
+
const { logLevelTypes: llt, winstonLogLevelNames: wlln, winstonLogLevels: wll, winstonTransports: wt,
|
|
6
|
+
zeddemoreLogLevelCaptions: zllc } = enums;
|
|
6
7
|
|
|
7
8
|
const logLevelMap = [
|
|
8
|
-
{
|
|
9
|
-
{
|
|
10
|
-
{
|
|
11
|
-
{
|
|
12
|
-
{
|
|
13
|
-
{
|
|
14
|
-
{
|
|
15
|
-
{
|
|
9
|
+
{ winstonLevel: null, winstonName: null, caption: zllc.DEFAULT },
|
|
10
|
+
{ winstonLevel: wll.ERROR, winstonName: wlln.ERROR, caption: zllc.ERROR },
|
|
11
|
+
{ winstonLevel: wll.WARNING, winstonName: wlln.WARNING, caption: zllc.WARNING },
|
|
12
|
+
{ winstonLevel: wll.INFO, winstonName: wlln.INFO, caption: zllc.INFO },
|
|
13
|
+
{ winstonLevel: wll.HTTP, winstonName: wlln.HTTP, caption: zllc.HTTP },
|
|
14
|
+
{ winstonLevel: wll.VERBOSE, winstonName: wlln.VERBOSE, caption: zllc.VERBOSE },
|
|
15
|
+
{ winstonLevel: wll.DEBUG, winstonName: wlln.DEBUG, caption: zllc.DEBUG },
|
|
16
|
+
{ winstonLevel: wll.SILLY, winstonName: wlln.SILLY, caption: zllc.SILLY },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const transportMap = [
|
|
20
|
+
{ transport: wt.CONSOLE, type: llt.CONSOLE },
|
|
21
|
+
{ transport: wt.EMAIL, type: llt.EMAIL },
|
|
16
22
|
];
|
|
17
23
|
|
|
18
24
|
module.exports = {
|
|
19
25
|
logLevelMap,
|
|
26
|
+
transportMap,
|
|
20
27
|
};
|
package/lib/zeddemore-logger.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
// Copyright (c) 2025 by Beardon Services, Inc.
|
|
1
|
+
// Copyright (c) 2025-2026 by Beardon Services, Inc.
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { winstonLogLevelIdName } = require('./logging');
|
|
4
4
|
const ZeddemoreLogger = require('./ZeddemoreLogger');
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
enums: require('./enums'),
|
|
8
8
|
log: ZeddemoreLogger.getLogger,
|
|
9
|
-
logLevelIdToWinstonLogLevelName,
|
|
10
|
-
|
|
9
|
+
logLevelIdToWinstonLogLevelName: winstonLogLevelIdName, // deprecated naming
|
|
10
|
+
winstonLogLevelIdName,
|
|
11
|
+
winstonLogLevelIdToName: winstonLogLevelIdName, // deprecated naming
|
|
11
12
|
writeAxiosErrorLog: ZeddemoreLogger.writeAxiosErrorLog,
|
|
12
13
|
writeAxiosLog: ZeddemoreLogger.writeAxiosResponseLog, // deprecated
|
|
13
14
|
writeAxiosResponseLog: ZeddemoreLogger.writeAxiosResponseLog,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zeddemore-logger",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "Node.js Express logger using Morgan and Winston for thread and caller info tracking",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"ansi-html": "^0.0.9",
|
|
24
24
|
"chalk": "^4.1.2",
|
|
25
|
-
"cli-progress": "^3.12.0",
|
|
26
25
|
"lodash": "^4.18.1",
|
|
27
26
|
"luxon": "^3.7.1",
|
|
28
27
|
"morgan": "^1.10.1",
|