Skip to content

Commit fb0eafe

Browse files
Merge pull request #365 from 4lessandrodev/feat/update-deps
chore: deps update
2 parents 9665041 + 1274fed commit fb0eafe

File tree

5 files changed

+31
-15
lines changed

5 files changed

+31
-15
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ All notable changes to this project will be documented in this file.
66

77
---
88

9+
### [3.8.1] - 2024-03-18
10+
11+
### Update
12+
13+
- Update core
14+
- Fix logger messages
15+
16+
---
17+
918
### [3.8.0] - 2024-03-18
1019

1120
### Update

lib/utils/logger.util.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import pino from 'pino';
1+
import pino, { BaseLogger } from 'pino';
22
import { LoggerOptions } from 'pino';
33

44
class DefaultLogger {
5-
protected static pino: any;
5+
protected static pino: BaseLogger = null as unknown as BaseLogger;
66
protected static config: LoggerOptions = {
77
transport: {
88
target: 'pino-pretty',
99
options: {
1010
translateTime: 'HH:MM:ss',
11-
messageFormat: '{levelLabel} {pid} {msg}',
1211
ignore: 'pid,hostname',
1312
prettyPrint: {
1413
colorize: true,
@@ -18,7 +17,7 @@ class DefaultLogger {
1817
},
1918
};
2019

21-
public static init() {
20+
public static instance() {
2221
if (!DefaultLogger.pino) {
2322
this.pino = pino(DefaultLogger.config);
2423
}
@@ -38,17 +37,19 @@ export const checkEnv = (callback: Function, type?: LogsType): void => {
3837
}
3938
};
4039

40+
const loggerInstance = DefaultLogger.instance();
41+
4142
const Logger = {
4243
info: (message: string) => {
43-
const callback = () => DefaultLogger.init().info({}, message);
44+
const callback = () => loggerInstance.info(message);
4445
checkEnv(callback, 'info');
4546
},
4647
error: (message: string) => {
47-
const callback = () => DefaultLogger.init().error({}, message);
48+
const callback = () => loggerInstance.error(message);
4849
checkEnv(callback, 'error');
4950
},
5051
warn: (message: string) => {
51-
const callback = () => DefaultLogger.init().warn({}, message);
52+
const callback = () => loggerInstance.warn(message);
5253
checkEnv(callback, 'warn');
5354
},
5455
};

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "types-ddd",
3-
"version": "3.8.0",
3+
"version": "3.8.1",
44
"description": "This package provide utils file and interfaces to assistant build a complex application with domain driving design",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -60,8 +60,8 @@
6060
"dependencies": {
6161
"bcrypt": "^5.0.1",
6262
"pino": "^8.17.1",
63-
"pino-pretty": "^11.0.0",
64-
"rich-domain": "^1.20.0"
63+
"rich-domain": "^1.20.3",
64+
"pino-pretty": "^11.0.0"
6565
},
6666
"devDependencies": {
6767
"@microsoft/tsdoc": "^0.14.1",

tests/utils/logger.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { checkEnv } from '@types-ddd';
1+
import { Logger, checkEnv } from '@types-ddd';
22

33
describe('Logger', () => {
44
it('should log if is not production and log is not off', () => {
@@ -88,4 +88,10 @@ describe('Logger', () => {
8888

8989
expect(callback).not.toHaveBeenCalled();
9090
});
91+
92+
it('logger must print message', () => {
93+
process.env.NODE_ENV = undefined;
94+
process.env.TYPES_DDD_LOGS = undefined;
95+
Logger.info('some success message');
96+
});
9197
});

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3611,10 +3611,10 @@ rfdc@^1.3.0:
36113611
resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b"
36123612
integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==
36133613

3614-
rich-domain@^1.20.0:
3615-
version "1.20.1"
3616-
resolved "https://registry.yarnpkg.com/rich-domain/-/rich-domain-1.20.1.tgz#6f456d70f01fc97c409b4f10335c1d4c7011d725"
3617-
integrity sha512-IT/KM/1MetI0jzQAcvodEaajUs0Mz2Le5iFKB2CqC2OQ3GW1cMLKGxC/VqWGLWJWPyw3ieB/5jJbdBCqT7nJVQ==
3614+
rich-domain@^1.20.3:
3615+
version "1.20.3"
3616+
resolved "https://registry.yarnpkg.com/rich-domain/-/rich-domain-1.20.3.tgz#3939787379d73e00ddc284e180136a3e1261c8a2"
3617+
integrity sha512-n+N/+hm/BrrWPpMJfavIEL2nHQkJ6hM6LL51CAEnJiJMaG7C6ujl9UpqiYsfutJmFhvtULD83CH4sFtYp+MArA==
36183618

36193619
rimraf@^3.0.0, rimraf@^3.0.2:
36203620
version "3.0.2"

0 commit comments

Comments
 (0)