Node.js library for logging to LogDNA
===
$ npm install logdna
var Logger = require('logdna');
var options = {
hostname: myHostname,
ip: ipAddress,
mac: macAddress,
app: appName
};
var logger = Logger.createLogger(apikey, options);
Required - (String) - max length 32 chars
Optional
- Hostname
- MAC Address
- IP Address
After initial setup, logging is as easy as:
// Simplest use case
logger.log('My Sample Log Line');
// Add a custom level
logger.log('My Sample Log Line', 'MyCustomLevel');
// Include an App name with this specific log
logger.log('My Sample Log Line', { level: 'Warn', app: 'myAppName'});
For more options, this module also offers:
// We support the following six levels
logger.info('My Sample Log Line');
logger.warn('My Sample Log Line');
logger.debug('My Sample Log Line');
logger.error('My Sample Log Line');
logger.fatal('My Sample Log Line');
// Functions above also accept additional options
logger.trace('My Sample Log Line', { app: 'myAppName'});
Required
Type: String
Values: YourAPIKey
Max Length: 32
The LogDNA API Key associated with your account.
Optional
Type: String
Default: ''
Values: YourCustomHostname
Max Length: 32
The default hostname passed along with every log sent through this instance.
Optional
Type: String
Default: ''
Values: C0:FF:EE:C0:FF:EE
The default MAC Address passed along with every log sent through this instance.
Optional
Type: String
Default: ''
Values: 10.0.0.1
The default IP Address passed along with every log sent through this instance.
Optional
Type: Integer
Default: 30000
Max Value: 100000
The length of the timeout on the POST request that is sent to LogDNA.
Optional
Type: String
Default: ''
Values: Debug
, Trace
, Info
, Warn
, Error
, Fatal
, YourCustomLevel
Max Length: 32
The default level passed along with every log sent through this instance.
Optional
Type: String
Default: ''
Values: YourCustomApp
Max Length: 32
The default app passed along with every log sent through this instance.
Required
Type: String
Default: ''
Max Length: 32000
The line which will be sent to the LogDNA system.
Optional
Type: String
Default: ''
Values: Debug
, Trace
, Info
, Warn
, Error
, Fatal
, YourCustomLevel
Max Length: 32
The level passed along with this log line.
Optional
Type: String
Default: ''
Values: YourCustomApp
Max Length: 32
The app passed along with this log line.
This module also provides a transport object, which can be added to winston using:
var winston = require('winston');
var options = {
key: apikey,
hostname: myHostname,
ip: ipAddress,
mac: macAddress,
app: appName
};
winston.add(winston.transports.Logdna, options);
MIT © LogDNA