@teikei/api
Version:
Teikei API server. Teikei is the software that powers ernte-teilen.org, a website that maps out Community-supported Agriculture in Germany.
24 lines (17 loc) • 526 B
JavaScript
import pino from 'pino'
import logger from 'feathers-logger'
export const appLogger = pino()
export default app => {
appLogger.level = process.env.NODE_ENV !== 'PRODUCTION' ? 'debug' : 'warn'
app.configure(logger(appLogger))
}
export const loggerHook = context => {
const { app, type, path, method, toJSON, error } = context
app.info(`${type} app.service('${path}').${method}()`)
if (typeof toJSON === 'function') {
app.debug(context, 'context')
}
if (error) {
app.error(context.error.stack)
}
}