+mkdirpSync(CONFIG.STORAGE.LOG_DIR)
+
+function loggerReplacer (key: string, value: any) {
+ if (value instanceof Error) {
+ const error = {}
+
+ Object.getOwnPropertyNames(value).forEach(key => error[ key ] = value[ key ])
+
+ return error
+ }
+
+ return value
+}
+
+const consoleLoggerFormat = winston.format.printf(info => {
+ const obj = {
+ meta: info.meta,
+ err: info.err,
+ sql: info.sql
+ }
+
+ let additionalInfos = JSON.stringify(obj, loggerReplacer, 2)
+ if (additionalInfos === undefined || additionalInfos === '{}') additionalInfos = ''
+ else additionalInfos = ' ' + additionalInfos
+
+ return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}`
+})
+
+const jsonLoggerFormat = winston.format.printf(info => {
+ return JSON.stringify(info, loggerReplacer)
+})
+
+const timestampFormatter = winston.format.timestamp({
+ format: 'YYYY-MM-DD HH:mm:ss.SSS'
+})
+const labelFormatter = winston.format.label({
+ label
+})