You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
848 B
36 lines
848 B
import pino from 'pino'
|
|
import pretty from 'pino-pretty'
|
|
import dayjs from 'dayjs'
|
|
import { mkdirSync } from "node:fs"
|
|
|
|
/**
|
|
* Wrapper for logger
|
|
*
|
|
* @author Björn Hase <me@herr-hase.wtf>
|
|
* @license hhttps://www.gnu.org/licenses/gpl-3.0.en.html GPL-3
|
|
* @link https://git.node001.net/HerrHase/signpost.git
|
|
*
|
|
*/
|
|
function logger(uuid) {
|
|
|
|
let destination = process.env.APP_BASE_DIR + '/storage/logs/'
|
|
|
|
// if name is set, adding name as directory
|
|
if (uuid) {
|
|
destination += uuid + '/'
|
|
mkdirSync(destination, { recursive: true })
|
|
}
|
|
|
|
destination += dayjs().format('DD-MM-YYYY') + '.log'
|
|
|
|
return pino({
|
|
timestamp: () => {
|
|
return `, "time":"${new Date(Date.now()).toISOString()}"`
|
|
},
|
|
},
|
|
pino.destination(destination)
|
|
)
|
|
}
|
|
|
|
export default logger
|