mirror of
https://github.com/pockethost/pockethost.git
synced 2025-11-28 16:13:29 +00:00
chore(pockethost): add namespace() to logger
This commit is contained in:
parent
04dc1295b5
commit
114b1d2513
5
.changeset/wise-bikes-fry.md
Normal file
5
.changeset/wise-bikes-fry.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'pockethost': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add namespace() export to core Logger service
|
||||||
@ -19,6 +19,7 @@
|
|||||||
"getenv",
|
"getenv",
|
||||||
"gobot",
|
"gobot",
|
||||||
"goja",
|
"goja",
|
||||||
|
"immer",
|
||||||
"IPCIDR",
|
"IPCIDR",
|
||||||
"ipcountry",
|
"ipcountry",
|
||||||
"jsonifiable",
|
"jsonifiable",
|
||||||
|
|||||||
@ -53,6 +53,12 @@ export const LogLevels = {
|
|||||||
[LogLevelName.Abort]: 6,
|
[LogLevelName.Abort]: 6,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
|
export const namespace = (...names: string[]) =>
|
||||||
|
names
|
||||||
|
.filter((v) => !!v)
|
||||||
|
.map((p) => `[${p}]`)
|
||||||
|
.join(' ')
|
||||||
|
|
||||||
export const createLogger = (config: Partial<LoggerConfig>) => {
|
export const createLogger = (config: Partial<LoggerConfig>) => {
|
||||||
const _config = mergeConfig<LoggerConfig>(
|
const _config = mergeConfig<LoggerConfig>(
|
||||||
{
|
{
|
||||||
@ -67,11 +73,7 @@ export const createLogger = (config: Partial<LoggerConfig>) => {
|
|||||||
_config.level = level
|
_config.level = level
|
||||||
}
|
}
|
||||||
|
|
||||||
const _pfx = (s: string) =>
|
const _pfx = (s: string) => namespace(s, ...pfx)
|
||||||
[s, ...pfx]
|
|
||||||
.filter((v) => !!v)
|
|
||||||
.map((p) => `[${p}]`)
|
|
||||||
.join(' ')
|
|
||||||
|
|
||||||
const _log = (levelIn: LogLevelName, ...args: any[]) => {
|
const _log = (levelIn: LogLevelName, ...args: any[]) => {
|
||||||
doLogAction({
|
doLogAction({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user