Skip to content

Commit

Permalink
Merge pull request #365 from 4lessandrodev/feat/update-deps
Browse files Browse the repository at this point in the history
chore: deps update
  • Loading branch information
4lessandrodev committed Mar 25, 2024
2 parents 9665041 + 1274fed commit fb0eafe
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ All notable changes to this project will be documented in this file.

---

### [3.8.1] - 2024-03-18

### Update

- Update core
- Fix logger messages

---

### [3.8.0] - 2024-03-18

### Update
Expand Down
15 changes: 8 additions & 7 deletions lib/utils/logger.util.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import pino from 'pino';
import pino, { BaseLogger } from 'pino';
import { LoggerOptions } from 'pino';

class DefaultLogger {
protected static pino: any;
protected static pino: BaseLogger = null as unknown as BaseLogger;
protected static config: LoggerOptions = {
transport: {
target: 'pino-pretty',
options: {
translateTime: 'HH:MM:ss',
messageFormat: '{levelLabel} {pid} {msg}',
ignore: 'pid,hostname',
prettyPrint: {
colorize: true,
Expand All @@ -18,7 +17,7 @@ class DefaultLogger {
},
};

public static init() {
public static instance() {
if (!DefaultLogger.pino) {
this.pino = pino(DefaultLogger.config);
}
Expand All @@ -38,17 +37,19 @@ export const checkEnv = (callback: Function, type?: LogsType): void => {
}
};

const loggerInstance = DefaultLogger.instance();

const Logger = {
info: (message: string) => {
const callback = () => DefaultLogger.init().info({}, message);
const callback = () => loggerInstance.info(message);
checkEnv(callback, 'info');
},
error: (message: string) => {
const callback = () => DefaultLogger.init().error({}, message);
const callback = () => loggerInstance.error(message);
checkEnv(callback, 'error');
},
warn: (message: string) => {
const callback = () => DefaultLogger.init().warn({}, message);
const callback = () => loggerInstance.warn(message);
checkEnv(callback, 'warn');
},
};
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "types-ddd",
"version": "3.8.0",
"version": "3.8.1",
"description": "This package provide utils file and interfaces to assistant build a complex application with domain driving design",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -60,8 +60,8 @@
"dependencies": {
"bcrypt": "^5.0.1",
"pino": "^8.17.1",
"pino-pretty": "^11.0.0",
"rich-domain": "^1.20.0"
"rich-domain": "^1.20.3",
"pino-pretty": "^11.0.0"
},
"devDependencies": {
"@microsoft/tsdoc": "^0.14.1",
Expand Down
8 changes: 7 additions & 1 deletion tests/utils/logger.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { checkEnv } from '@types-ddd';
import { Logger, checkEnv } from '@types-ddd';

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

expect(callback).not.toHaveBeenCalled();
});

it('logger must print message', () => {
process.env.NODE_ENV = undefined;
process.env.TYPES_DDD_LOGS = undefined;
Logger.info('some success message');
});
});
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3611,10 +3611,10 @@ rfdc@^1.3.0:
resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b"
integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==

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

rimraf@^3.0.0, rimraf@^3.0.2:
version "3.0.2"
Expand Down

0 comments on commit fb0eafe

Please sign in to comment.