I'm using winston as a logger and in it you have a format
namespace and function at the same time, so i can both call format()
and access other functions via the namespace format.someFunction()
as illustrated in the code below. Now i'm wondering how i can create an object like this myself?
const isRequest = format((info, _opts) => {
if (info.isRequest) {
return info
}
return false
})
export const logger = createLogger({
level: 'info',
format: format.combine(
format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss'
}),
format.printf((info) => {
return `${info.timestamp} ${info.level}: ${info.message}`
})
),
transports: [
new transports.File({
filename: errorLog,
level: 'error'
}),
new transports.File({
filename: requestLog,
format: format.combine(isRequest())
}),
new transports.File({
filename: combinedLog
})
],
exceptionHandlers: [
new transports.File({
filename: exceptionsLog
})
]
})