filesafe/logger.js
Bobby Wibowo 02e2e402c3
!!! MASSIVE OVERHAUL !!!
As the title says, this commit is a massive overhaul.
I've rewritten/restrucuted almost everything in the controller scripts.
Because of that, there's a considerable possibility that I've broken
something somewhere.

Notable changes:

Added temporary uploads.

Removed file name length changer from dashboard,
in favor of an equivalent in homepage config tab.
This allows non-registered users to also set file name length.

A bunch of other undocmented stuff.
I don't know, I'm too tired to remember them all.
2019-09-08 08:56:29 +07:00

27 lines
593 B
JavaScript

const { inspect } = require('util')
const self = {}
const clean = item => {
if (typeof item === 'string') return item
const cleaned = inspect(item, { depth: 0 })
return cleaned
}
const write = (content, options = {}) => {
const date = new Date().toISOString()
.replace(/T/, ' ')
.replace(/\..*/, '')
const stream = options.error ? process.stderr : process.stdout
stream.write(`[${date}]: ${options.prefix || ''}${clean(content)}\n`)
}
self.log = write
self.error = (content, options = {}) => {
options.error = true
write(content, options)
}
module.exports = self