@trayio/winston 3.8.1-beta → 3.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,6 +9,7 @@ const json_colorizer_1 = __importDefault(require("json-colorizer"));
|
|
|
9
9
|
const winston_1 = require("winston");
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
11
|
class WinstonCliLogging {
|
|
12
|
+
logger;
|
|
12
13
|
constructor() {
|
|
13
14
|
const logFormatter = (info) => {
|
|
14
15
|
if (typeof info.message === 'object') {
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getLogger = void 0;
|
|
4
4
|
const winston_1 = require("winston");
|
|
5
5
|
class WinstonLogging {
|
|
6
|
+
winstonLogger;
|
|
7
|
+
context;
|
|
6
8
|
constructor(context = {}) {
|
|
7
9
|
this.winstonLogger = (0, winston_1.createLogger)({
|
|
8
10
|
format: winston_1.format.json(),
|
|
@@ -12,16 +14,16 @@ class WinstonLogging {
|
|
|
12
14
|
this.context = this.getDefaultContext(context);
|
|
13
15
|
}
|
|
14
16
|
info(message, context) {
|
|
15
|
-
this.winstonLogger.info(message,
|
|
17
|
+
this.winstonLogger.info(message, { ...this.context, ...context });
|
|
16
18
|
}
|
|
17
19
|
debug(message, context) {
|
|
18
|
-
this.winstonLogger.debug(message,
|
|
20
|
+
this.winstonLogger.debug(message, { ...this.context, ...context });
|
|
19
21
|
}
|
|
20
22
|
error(message, context) {
|
|
21
|
-
this.winstonLogger.error(message,
|
|
23
|
+
this.winstonLogger.error(message, { ...this.context, ...context });
|
|
22
24
|
}
|
|
23
25
|
warning(message, context) {
|
|
24
|
-
this.winstonLogger.warn(message,
|
|
26
|
+
this.winstonLogger.warn(message, { ...this.context, ...context });
|
|
25
27
|
}
|
|
26
28
|
getDefaultContext(context) {
|
|
27
29
|
context.service = process.env.npm_package_name;
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const winston_1 = require("winston");
|
|
4
4
|
const WinstonLogging_1 = require("./WinstonLogging");
|
|
5
|
-
jest.mock('winston', () => (
|
|
5
|
+
jest.mock('winston', () => ({
|
|
6
|
+
...jest.requireActual('winston'),
|
|
7
|
+
createLogger: jest.fn(),
|
|
8
|
+
Logger: jest.fn(),
|
|
9
|
+
}));
|
|
6
10
|
describe('Logger', () => {
|
|
7
11
|
const mockedCreateLogger = winston_1.createLogger;
|
|
8
12
|
beforeEach(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/winston",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.1",
|
|
4
4
|
"description": "Tray implementation of Winston logger",
|
|
5
5
|
"author": "Tray.io",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@trayio/commons": "3.
|
|
11
|
+
"@trayio/commons": "3.9.1",
|
|
12
12
|
"chalk": "4.1.2",
|
|
13
13
|
"json-colorizer": "2.2.2",
|
|
14
14
|
"winston": "3.8.2"
|