Skip to content

Commit 0a799e7

Browse files
committed
refactor: remove @secjs/logger
1 parent 05c39c4 commit 0a799e7

File tree

4 files changed

+35
-19
lines changed

4 files changed

+35
-19
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@secjs/config",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"description": "",
55
"license": "MIT",
66
"author": "João Lenon",
@@ -22,7 +22,6 @@
2222
"@secjs/contracts": "1.1.7",
2323
"@secjs/env": "1.2.5",
2424
"@secjs/exceptions": "1.0.4",
25-
"@secjs/logger": "1.2.2",
2625
"@secjs/utils": "1.4.3",
2726
"@types/debug": "4.1.5",
2827
"@types/jest": "27.0.1",

src/Config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import logger from './utils/logger'
1+
import { debugFn } from './utils/debug'
22

33
import { parse } from 'path'
44
import { Env } from '@secjs/env'
@@ -12,7 +12,7 @@ export class Config {
1212
const isInitialized = Config.configs.size >= 1
1313

1414
if (isInitialized) {
15-
logger.debug(
15+
debugFn(
1616
'Reloading the Config class has no effect on the configuration files, only for environment variables, as the files have already been loaded as Singletons',
1717
)
1818
}
@@ -112,7 +112,7 @@ export class Config {
112112
}
113113
}
114114

115-
logger.debug(`Loading ${name} configuration file`)
115+
debugFn(`Loading ${name} configuration file`)
116116
this.configs.set(name, require(`${dir}/${name}`).default)
117117
}
118118
}

src/utils/debug.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import debug from 'debug'
2+
3+
import Chalk from 'chalk'
4+
5+
function format(message: any) {
6+
const pid = Chalk.hex('#7059C1')(`[SecJS Debugger] - PID: ${process.pid}`)
7+
const timestamp = getTimestamp()
8+
const messageCtx = Chalk.hex('#ffe600')(`[Config] `)
9+
10+
return `${pid} - ${timestamp} ${messageCtx}${Chalk.hex('#7059C1')(message)}`
11+
}
12+
13+
function getTimestamp(): string {
14+
const localeStringOptions = {
15+
year: 'numeric',
16+
hour: 'numeric',
17+
minute: 'numeric',
18+
second: 'numeric',
19+
day: '2-digit',
20+
month: '2-digit',
21+
}
22+
23+
return new Date(Date.now()).toLocaleString(
24+
undefined,
25+
localeStringOptions as Intl.DateTimeFormatOptions,
26+
)
27+
}
28+
29+
export function debugFn(message: string) {
30+
debug('api:configurations')(format(message))
31+
}

src/utils/logger.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)