seen.add(value)
}
+ if (value instanceof Set) {
+ return Array.from(value)
+ }
+
+ if (value instanceof Map) {
+ return Array.from(value.entries())
+ }
+
if (value instanceof Error) {
const error = {}
}
const consoleLoggerFormat = winston.format.printf(info => {
- const toOmit = [ 'label', 'timestamp', 'level', 'message' ]
- if (CONFIG.LOG.PRETTIFY_SQL) toOmit.push('sql')
+ const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql', 'tags' ]
const obj = omit(info, ...toOmit)
if (additionalInfos === undefined || additionalInfos === '{}') additionalInfos = ''
else additionalInfos = ' ' + additionalInfos
- if (CONFIG.LOG.PRETTIFY_SQL && info.sql) {
- additionalInfos += '\n' + sqlFormat(info.sql, {
- language: 'sql',
- ident: ' '
- })
+ if (info.sql) {
+ if (CONFIG.LOG.PRETTIFY_SQL) {
+ additionalInfos += '\n' + sqlFormat(info.sql, {
+ language: 'sql',
+ indent: ' '
+ })
+ } else {
+ additionalInfos += ' - ' + info.sql
+ }
}
return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}`
error: bunyanLogFactory('error'),
fatal: bunyanLogFactory('error')
}
+
+function loggerTagsFactory (...defaultTags: string[]) {
+ return (...tags: string[]) => {
+ return { tags: defaultTags.concat(tags) }
+ }
+}
+
// ---------------------------------------------------------------------------
export {
consoleLoggerFormat,
jsonLoggerFormat,
logger,
+ loggerTagsFactory,
bunyanLogger
}