qiot-io-logger v1.0.3
qiot-io-logger is a simple library based on bunyan
It aims to provide a default configuration to satisfy qiot.io logging needs.
Usage
const qiotLogger = require('qiot-io-logger');
const logger = qiotLogger.createLogger({ name: 'myapp' });
This will create a new logger only with STDOUT output. name
option is required
Streams configurations
STDOUT, GELF and ROTATING_FILE are default outputs for logging. It means, that the library will ask for its configuration, but not fail. Anyway, it's going to log a warning message saying that wasn't able to load the configuration and will skip the output.
If you want to specify STREAMS to avoid this warning, you can:
const logger = qiotLogger.createLogger({
name: 'myapp'
}, ['stdout']);
STDOUT
This is the default stream to log. It uses info
as default level.
If you want to provide a different level you can overwrite this doing:
const logger = qiotLogger.createLogger({
name: 'myapp',
stdout: {
level: 'debug',
},
});
GELF
const logger = qiotLogger.createLogger({
name: 'myapp',
gelf: {
level: 'debug',
url: 'localhost',
port: 12201,
},
});
level
(info
is used by default) and port
can be omitted but url
configuration is required.
ROTATING FILE
const logger = qiotLogger.createLogger({
name: 'myapp',
'rotating-file': {
level: 'debug',
path: 'folder/file',
},
});
path
configuration is required.
It uses these configurations by default (all of them can be overwritten):
{
level: 'info',
period: '1d', # daily rotation
count: 7, # keep 7 back copies
}
Other Configurations
Please refer to bunyan documentation, to check out more options.