mirror of
https://github.com/pockethost/pockethost.git
synced 2025-05-29 18:26:39 +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",
|
||||
"gobot",
|
||||
"goja",
|
||||
"immer",
|
||||
"IPCIDR",
|
||||
"ipcountry",
|
||||
"jsonifiable",
|
||||
|
@ -53,6 +53,12 @@ export const LogLevels = {
|
||||
[LogLevelName.Abort]: 6,
|
||||
} as const
|
||||
|
||||
export const namespace = (...names: string[]) =>
|
||||
names
|
||||
.filter((v) => !!v)
|
||||
.map((p) => `[${p}]`)
|
||||
.join(' ')
|
||||
|
||||
export const createLogger = (config: Partial<LoggerConfig>) => {
|
||||
const _config = mergeConfig<LoggerConfig>(
|
||||
{
|
||||
@ -67,11 +73,7 @@ export const createLogger = (config: Partial<LoggerConfig>) => {
|
||||
_config.level = level
|
||||
}
|
||||
|
||||
const _pfx = (s: string) =>
|
||||
[s, ...pfx]
|
||||
.filter((v) => !!v)
|
||||
.map((p) => `[${p}]`)
|
||||
.join(' ')
|
||||
const _pfx = (s: string) => namespace(s, ...pfx)
|
||||
|
||||
const _log = (levelIn: LogLevelName, ...args: any[]) => {
|
||||
doLogAction({
|
||||
|
Loading…
x
Reference in New Issue
Block a user