#
Logging
The backend logging system is built on bunyan and is designed for categorised, hierarchical logging with log thresholds.
Each log treshold has a corresponding method with the same name available on a logger instance. The possible log thresholds are:
trace
- for very low-level messages that you normally don't need to see.debug
- for messages that can help with debugging issues.info
- for general messages that you want to see in the logs in production.warn
- for minor issues that don't cause problems but may need investigating.error
- for problems and errors that need to be investigated and/or fixed.
For example, to create a logger which logs to console:
import { createLog } from '@/backend/logging'
const log = createLog({
name: 'root',
logLevel: 'debug'
})
// will output nothing since minimum log level is "debug"
log.trace('test')
// will output: 19:36:13.090Z DEBUG root: test
log.debug('test')
Now a child logger can be created from the root
logger:
const child = log.create('sub')
// will output: 19:36:14.090Z DEBUG root/sub: test2
child.debug('test2')
There is always an instantiated log
property in the bootstrapped object.
#
Datadog cloud
Log messages will be sent to Datadog if the following environment variables are set:
DATADOG_API_KEY
DATADOG_APPLICATION_KEY
See https://github.com/DataDog/datadog-api-client-typescript for information on these parameters.