This package is just a wrapper arround winston plugin in order to make a Logger
object available within a Hapi application.
This plugin decorates the request
object with a logger property making the winston logger accessible within a handler.
So basically you can just go like:
function myHandler(request, reply) {
// Your code.
request.logger.debug('This is my debug info');
// ...
.catch(err => {
request.logger.error('This is an error');
});
}
You can read in detail what does the winston API offer on the github page.
Here is a small preview of the methods you can use in order to log:
log({ level: 'info', message: 'message' })
debug('my debug message')
info('my info message')
warn('my warning message')
error('my error message')
{
level: 'debug' // 'silly', 'debug', 'verbose', 'info', 'warn', 'error',
fileLogger: {
filename: 'my-log-file.log',
logDirectory: 'logs/',
datePattern: 'yyyy-MM-dd.',
prepend: 'true',
zippedArchive: true,
maxDays: 7,
},
}
The level
option is used to filter the logs you want to print. If you want, for example to put your in production but limit the logs to warn level, you can modify this config instead of removing your logs.
You can choose to activate an API on your application to query the logs with a standard HTTP GET request. The response is in JSON.
Coming soon