mirror of
https://github.com/pockethost/pockethost.git
synced 2025-07-08 13:52:31 +00:00
fix: deallocate syslog file transport at shutdown
This commit is contained in:
parent
2aaab9768b
commit
cc11b976f4
@ -4,18 +4,18 @@ import * as winston from 'winston'
|
|||||||
import 'winston-syslog'
|
import 'winston-syslog'
|
||||||
|
|
||||||
export function SyslogLogger(instanceId: string, target: string) {
|
export function SyslogLogger(instanceId: string, target: string) {
|
||||||
|
// @ts-ignore
|
||||||
|
const syslogTransport = new winston.transports.Syslog({
|
||||||
|
host: `localhost`,
|
||||||
|
port: SYSLOGD_PORT(),
|
||||||
|
app_name: instanceId,
|
||||||
|
}) as winston.transport
|
||||||
|
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
format: winston.format.printf((info) => {
|
format: winston.format.printf((info) => {
|
||||||
return info.message
|
return info.message
|
||||||
}),
|
}),
|
||||||
transports: [
|
transports: [syslogTransport],
|
||||||
// @ts-ignore
|
|
||||||
new winston.transports.Syslog({
|
|
||||||
host: `localhost`,
|
|
||||||
port: SYSLOGD_PORT(),
|
|
||||||
app_name: instanceId,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const { error, warn } = LoggerService()
|
const { error, warn } = LoggerService()
|
||||||
@ -31,6 +31,7 @@ export function SyslogLogger(instanceId: string, target: string) {
|
|||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
},
|
},
|
||||||
shutdown: () => {
|
shutdown: () => {
|
||||||
|
syslogTransport.close?.()
|
||||||
logger.close()
|
logger.close()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user