@commercetools-backend/loggers 21.23.10 → 21.24.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.
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
-
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
7
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
8
|
-
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
9
5
|
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
10
6
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
11
7
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
@@ -14,13 +10,15 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
|
|
|
14
10
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
15
11
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
16
12
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
17
|
-
var
|
|
13
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
+
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
18
15
|
var expressWinston = require('express-winston');
|
|
19
|
-
var
|
|
16
|
+
var winston = require('winston');
|
|
20
17
|
var cloneDeep = require('lodash/cloneDeep');
|
|
21
18
|
var getIn = require('lodash/get');
|
|
22
19
|
var setIn = require('lodash/set');
|
|
23
20
|
var unsetIn = require('lodash/unset');
|
|
21
|
+
var logform = require('logform');
|
|
24
22
|
|
|
25
23
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
26
24
|
|
|
@@ -42,8 +40,6 @@ function _interopNamespace(e) {
|
|
|
42
40
|
return Object.freeze(n);
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
46
|
-
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
47
43
|
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
48
44
|
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
49
45
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
@@ -52,8 +48,9 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
52
48
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
53
49
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
54
50
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
55
|
-
var
|
|
51
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
56
52
|
var expressWinston__default = /*#__PURE__*/_interopDefault(expressWinston);
|
|
53
|
+
var winston__namespace = /*#__PURE__*/_interopNamespace(winston);
|
|
57
54
|
var cloneDeep__default = /*#__PURE__*/_interopDefault(cloneDeep);
|
|
58
55
|
var getIn__default = /*#__PURE__*/_interopDefault(getIn);
|
|
59
56
|
var setIn__default = /*#__PURE__*/_interopDefault(setIn);
|
|
@@ -61,16 +58,14 @@ var unsetIn__default = /*#__PURE__*/_interopDefault(unsetIn);
|
|
|
61
58
|
|
|
62
59
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
63
60
|
|
|
64
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
61
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
65
62
|
|
|
66
|
-
|
|
67
|
-
var _options$ignoreUrls,
|
|
68
|
-
|
|
69
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
70
|
-
var ignoreUrls = (_options$ignoreUrls = options.ignoreUrls) !== null && _options$ignoreUrls !== void 0 ? _options$ignoreUrls : [];
|
|
71
|
-
|
|
72
|
-
var formatters = (_winston$format = winston__namespace["default"].format).combine.apply(_winston$format, _concatInstanceProperty__default["default"](_context = [winston__namespace["default"].format.timestamp()]).call(_context, _toConsumableArray((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), [options.json ? winston__namespace["default"].format.json() : winston__namespace["default"].format.cli()]));
|
|
63
|
+
const createAccessLoggerMiddleware = function () {
|
|
64
|
+
var _options$ignoreUrls, _options$formatters, _options$level;
|
|
73
65
|
|
|
66
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
67
|
+
const ignoreUrls = (_options$ignoreUrls = options.ignoreUrls) !== null && _options$ignoreUrls !== void 0 ? _options$ignoreUrls : [];
|
|
68
|
+
const formatters = winston__namespace["default"].format.combine(winston__namespace["default"].format.timestamp(), ...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston__namespace["default"].format.json() : winston__namespace["default"].format.cli());
|
|
74
69
|
return expressWinston__default["default"].logger({
|
|
75
70
|
level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
|
|
76
71
|
transports: [new winston__namespace["default"].transports.Console()],
|
|
@@ -79,28 +74,22 @@ var createAccessLoggerMiddleware = function createAccessLoggerMiddleware() {
|
|
|
79
74
|
expressFormat: true,
|
|
80
75
|
// Use default morgan access log formatting
|
|
81
76
|
colorize: !options.json,
|
|
82
|
-
skip:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}, req.connection.remoteAddress ? {
|
|
91
|
-
remoteAddress: req.connection.remoteAddress
|
|
92
|
-
} : {});
|
|
93
|
-
}
|
|
77
|
+
skip: req => Boolean(options.silent) || _includesInstanceProperty__default["default"](ignoreUrls).call(ignoreUrls, req.originalUrl),
|
|
78
|
+
dynamicMeta: req => _objectSpread({
|
|
79
|
+
ip: req.ip,
|
|
80
|
+
ips: req.ips,
|
|
81
|
+
hostname: req.hostname
|
|
82
|
+
}, req.connection.remoteAddress ? {
|
|
83
|
+
remoteAddress: req.connection.remoteAddress
|
|
84
|
+
} : {})
|
|
94
85
|
});
|
|
95
86
|
};
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
101
|
-
|
|
102
|
-
var formatters = (_winston$format = winston__namespace.format).combine.apply(_winston$format, _concatInstanceProperty__default["default"](_context = _toConsumableArray((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : [])).call(_context, [options.json ? winston__namespace.format.json() : winston__namespace.format.combine(winston__namespace.format.cli(), winston__namespace.format.simple())]));
|
|
88
|
+
const createApplicationLogger = function () {
|
|
89
|
+
var _options$formatters, _options$level;
|
|
103
90
|
|
|
91
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
92
|
+
const formatters = winston__namespace.format.combine(...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston__namespace.format.json() : winston__namespace.format.combine(winston__namespace.format.cli(), winston__namespace.format.simple()));
|
|
104
93
|
return winston__namespace.createLogger({
|
|
105
94
|
level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
|
|
106
95
|
format: formatters,
|
|
@@ -111,7 +100,7 @@ var createApplicationLogger = function createApplicationLogger() {
|
|
|
111
100
|
};
|
|
112
101
|
|
|
113
102
|
function rewriteField(info, field) {
|
|
114
|
-
|
|
103
|
+
const val = getIn__default["default"](info, field.from);
|
|
115
104
|
|
|
116
105
|
if (val) {
|
|
117
106
|
unsetIn__default["default"](info, field.from);
|
|
@@ -120,12 +109,12 @@ function rewriteField(info, field) {
|
|
|
120
109
|
}
|
|
121
110
|
|
|
122
111
|
function rewriteFieldsFormatter(options) {
|
|
123
|
-
return logform.format(
|
|
112
|
+
return logform.format(info => {
|
|
124
113
|
var _context;
|
|
125
114
|
|
|
126
|
-
|
|
115
|
+
const clone = cloneDeep__default["default"](info);
|
|
127
116
|
|
|
128
|
-
_forEachInstanceProperty__default["default"](_context = options.fields).call(_context,
|
|
117
|
+
_forEachInstanceProperty__default["default"](_context = options.fields).call(_context, field => {
|
|
129
118
|
rewriteField(clone, field);
|
|
130
119
|
});
|
|
131
120
|
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
-
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
7
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
8
|
-
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
9
5
|
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
10
6
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
11
7
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
@@ -14,13 +10,15 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
|
|
|
14
10
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
15
11
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
16
12
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
17
|
-
var
|
|
13
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
+
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
18
15
|
var expressWinston = require('express-winston');
|
|
19
|
-
var
|
|
16
|
+
var winston = require('winston');
|
|
20
17
|
var cloneDeep = require('lodash/cloneDeep');
|
|
21
18
|
var getIn = require('lodash/get');
|
|
22
19
|
var setIn = require('lodash/set');
|
|
23
20
|
var unsetIn = require('lodash/unset');
|
|
21
|
+
var logform = require('logform');
|
|
24
22
|
|
|
25
23
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
26
24
|
|
|
@@ -42,8 +40,6 @@ function _interopNamespace(e) {
|
|
|
42
40
|
return Object.freeze(n);
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
46
|
-
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
47
43
|
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
48
44
|
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
49
45
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
@@ -52,8 +48,9 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
52
48
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
53
49
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
54
50
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
55
|
-
var
|
|
51
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
56
52
|
var expressWinston__default = /*#__PURE__*/_interopDefault(expressWinston);
|
|
53
|
+
var winston__namespace = /*#__PURE__*/_interopNamespace(winston);
|
|
57
54
|
var cloneDeep__default = /*#__PURE__*/_interopDefault(cloneDeep);
|
|
58
55
|
var getIn__default = /*#__PURE__*/_interopDefault(getIn);
|
|
59
56
|
var setIn__default = /*#__PURE__*/_interopDefault(setIn);
|
|
@@ -61,16 +58,14 @@ var unsetIn__default = /*#__PURE__*/_interopDefault(unsetIn);
|
|
|
61
58
|
|
|
62
59
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
63
60
|
|
|
64
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
61
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
65
62
|
|
|
66
|
-
|
|
67
|
-
var _options$ignoreUrls,
|
|
68
|
-
|
|
69
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
70
|
-
var ignoreUrls = (_options$ignoreUrls = options.ignoreUrls) !== null && _options$ignoreUrls !== void 0 ? _options$ignoreUrls : [];
|
|
71
|
-
|
|
72
|
-
var formatters = (_winston$format = winston__namespace["default"].format).combine.apply(_winston$format, _concatInstanceProperty__default["default"](_context = [winston__namespace["default"].format.timestamp()]).call(_context, _toConsumableArray((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), [options.json ? winston__namespace["default"].format.json() : winston__namespace["default"].format.cli()]));
|
|
63
|
+
const createAccessLoggerMiddleware = function () {
|
|
64
|
+
var _options$ignoreUrls, _options$formatters, _options$level;
|
|
73
65
|
|
|
66
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
67
|
+
const ignoreUrls = (_options$ignoreUrls = options.ignoreUrls) !== null && _options$ignoreUrls !== void 0 ? _options$ignoreUrls : [];
|
|
68
|
+
const formatters = winston__namespace["default"].format.combine(winston__namespace["default"].format.timestamp(), ...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston__namespace["default"].format.json() : winston__namespace["default"].format.cli());
|
|
74
69
|
return expressWinston__default["default"].logger({
|
|
75
70
|
level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
|
|
76
71
|
transports: [new winston__namespace["default"].transports.Console()],
|
|
@@ -79,28 +74,22 @@ var createAccessLoggerMiddleware = function createAccessLoggerMiddleware() {
|
|
|
79
74
|
expressFormat: true,
|
|
80
75
|
// Use default morgan access log formatting
|
|
81
76
|
colorize: !options.json,
|
|
82
|
-
skip:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}, req.connection.remoteAddress ? {
|
|
91
|
-
remoteAddress: req.connection.remoteAddress
|
|
92
|
-
} : {});
|
|
93
|
-
}
|
|
77
|
+
skip: req => Boolean(options.silent) || _includesInstanceProperty__default["default"](ignoreUrls).call(ignoreUrls, req.originalUrl),
|
|
78
|
+
dynamicMeta: req => _objectSpread({
|
|
79
|
+
ip: req.ip,
|
|
80
|
+
ips: req.ips,
|
|
81
|
+
hostname: req.hostname
|
|
82
|
+
}, req.connection.remoteAddress ? {
|
|
83
|
+
remoteAddress: req.connection.remoteAddress
|
|
84
|
+
} : {})
|
|
94
85
|
});
|
|
95
86
|
};
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
101
|
-
|
|
102
|
-
var formatters = (_winston$format = winston__namespace.format).combine.apply(_winston$format, _concatInstanceProperty__default["default"](_context = _toConsumableArray((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : [])).call(_context, [options.json ? winston__namespace.format.json() : winston__namespace.format.combine(winston__namespace.format.cli(), winston__namespace.format.simple())]));
|
|
88
|
+
const createApplicationLogger = function () {
|
|
89
|
+
var _options$formatters, _options$level;
|
|
103
90
|
|
|
91
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
92
|
+
const formatters = winston__namespace.format.combine(...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston__namespace.format.json() : winston__namespace.format.combine(winston__namespace.format.cli(), winston__namespace.format.simple()));
|
|
104
93
|
return winston__namespace.createLogger({
|
|
105
94
|
level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
|
|
106
95
|
format: formatters,
|
|
@@ -111,7 +100,7 @@ var createApplicationLogger = function createApplicationLogger() {
|
|
|
111
100
|
};
|
|
112
101
|
|
|
113
102
|
function rewriteField(info, field) {
|
|
114
|
-
|
|
103
|
+
const val = getIn__default["default"](info, field.from);
|
|
115
104
|
|
|
116
105
|
if (val) {
|
|
117
106
|
unsetIn__default["default"](info, field.from);
|
|
@@ -120,12 +109,12 @@ function rewriteField(info, field) {
|
|
|
120
109
|
}
|
|
121
110
|
|
|
122
111
|
function rewriteFieldsFormatter(options) {
|
|
123
|
-
return logform.format(
|
|
112
|
+
return logform.format(info => {
|
|
124
113
|
var _context;
|
|
125
114
|
|
|
126
|
-
|
|
115
|
+
const clone = cloneDeep__default["default"](info);
|
|
127
116
|
|
|
128
|
-
_forEachInstanceProperty__default["default"](_context = options.fields).call(_context,
|
|
117
|
+
_forEachInstanceProperty__default["default"](_context = options.fields).call(_context, field => {
|
|
129
118
|
rewriteField(clone, field);
|
|
130
119
|
});
|
|
131
120
|
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
2
|
-
import _toConsumableArray from '@babel/runtime-corejs3/helpers/esm/toConsumableArray';
|
|
3
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
4
|
-
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
5
1
|
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
6
2
|
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
7
3
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
@@ -10,27 +6,27 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/inst
|
|
|
10
6
|
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
11
7
|
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
12
8
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
10
|
+
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
11
|
+
import expressWinston from 'express-winston';
|
|
13
12
|
import * as winston from 'winston';
|
|
14
13
|
import winston__default from 'winston';
|
|
15
|
-
import expressWinston from 'express-winston';
|
|
16
|
-
import { format } from 'logform';
|
|
17
14
|
import cloneDeep from 'lodash/cloneDeep';
|
|
18
15
|
import getIn from 'lodash/get';
|
|
19
16
|
import setIn from 'lodash/set';
|
|
20
17
|
import unsetIn from 'lodash/unset';
|
|
18
|
+
import { format } from 'logform';
|
|
21
19
|
|
|
22
20
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
21
|
|
|
24
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
25
|
-
|
|
26
|
-
var createAccessLoggerMiddleware = function createAccessLoggerMiddleware() {
|
|
27
|
-
var _options$ignoreUrls, _winston$format, _context, _options$formatters, _options$level;
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
var formatters = (_winston$format = winston__default.format).combine.apply(_winston$format, _concatInstanceProperty(_context = [winston__default.format.timestamp()]).call(_context, _toConsumableArray((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), [options.json ? winston__default.format.json() : winston__default.format.cli()]));
|
|
24
|
+
const createAccessLoggerMiddleware = function () {
|
|
25
|
+
var _options$ignoreUrls, _options$formatters, _options$level;
|
|
33
26
|
|
|
27
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
28
|
+
const ignoreUrls = (_options$ignoreUrls = options.ignoreUrls) !== null && _options$ignoreUrls !== void 0 ? _options$ignoreUrls : [];
|
|
29
|
+
const formatters = winston__default.format.combine(winston__default.format.timestamp(), ...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston__default.format.json() : winston__default.format.cli());
|
|
34
30
|
return expressWinston.logger({
|
|
35
31
|
level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
|
|
36
32
|
transports: [new winston__default.transports.Console()],
|
|
@@ -39,28 +35,22 @@ var createAccessLoggerMiddleware = function createAccessLoggerMiddleware() {
|
|
|
39
35
|
expressFormat: true,
|
|
40
36
|
// Use default morgan access log formatting
|
|
41
37
|
colorize: !options.json,
|
|
42
|
-
skip:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}, req.connection.remoteAddress ? {
|
|
51
|
-
remoteAddress: req.connection.remoteAddress
|
|
52
|
-
} : {});
|
|
53
|
-
}
|
|
38
|
+
skip: req => Boolean(options.silent) || _includesInstanceProperty(ignoreUrls).call(ignoreUrls, req.originalUrl),
|
|
39
|
+
dynamicMeta: req => _objectSpread({
|
|
40
|
+
ip: req.ip,
|
|
41
|
+
ips: req.ips,
|
|
42
|
+
hostname: req.hostname
|
|
43
|
+
}, req.connection.remoteAddress ? {
|
|
44
|
+
remoteAddress: req.connection.remoteAddress
|
|
45
|
+
} : {})
|
|
54
46
|
});
|
|
55
47
|
};
|
|
56
48
|
|
|
57
|
-
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
61
|
-
|
|
62
|
-
var formatters = (_winston$format = winston.format).combine.apply(_winston$format, _concatInstanceProperty(_context = _toConsumableArray((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : [])).call(_context, [options.json ? winston.format.json() : winston.format.combine(winston.format.cli(), winston.format.simple())]));
|
|
49
|
+
const createApplicationLogger = function () {
|
|
50
|
+
var _options$formatters, _options$level;
|
|
63
51
|
|
|
52
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
53
|
+
const formatters = winston.format.combine(...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston.format.json() : winston.format.combine(winston.format.cli(), winston.format.simple()));
|
|
64
54
|
return winston.createLogger({
|
|
65
55
|
level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
|
|
66
56
|
format: formatters,
|
|
@@ -71,7 +61,7 @@ var createApplicationLogger = function createApplicationLogger() {
|
|
|
71
61
|
};
|
|
72
62
|
|
|
73
63
|
function rewriteField(info, field) {
|
|
74
|
-
|
|
64
|
+
const val = getIn(info, field.from);
|
|
75
65
|
|
|
76
66
|
if (val) {
|
|
77
67
|
unsetIn(info, field.from);
|
|
@@ -80,12 +70,12 @@ function rewriteField(info, field) {
|
|
|
80
70
|
}
|
|
81
71
|
|
|
82
72
|
function rewriteFieldsFormatter(options) {
|
|
83
|
-
return format(
|
|
73
|
+
return format(info => {
|
|
84
74
|
var _context;
|
|
85
75
|
|
|
86
|
-
|
|
76
|
+
const clone = cloneDeep(info);
|
|
87
77
|
|
|
88
|
-
_forEachInstanceProperty(_context = options.fields).call(_context,
|
|
78
|
+
_forEachInstanceProperty(_context = options.fields).call(_context, field => {
|
|
89
79
|
rewriteField(clone, field);
|
|
90
80
|
});
|
|
91
81
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-backend/loggers",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.24.0",
|
|
4
4
|
"description": "Opinionated JSON loggers for HTTP server applications",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/runtime": "^7.20.13",
|
|
29
29
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
30
|
-
"@sentry/node": "7.
|
|
30
|
+
"@sentry/node": "7.43.0",
|
|
31
31
|
"@types/triple-beam": "1.3.2",
|
|
32
32
|
"express-winston": "4.2.0",
|
|
33
33
|
"fast-safe-stringify": "2.1.1",
|