1.0.3 • Published 4 years ago

jrf-graylog v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

jrf-graylog

Description

A package that implements the udp logging client for Graylog

Example

const Graylog = require('jrf-graylog');

const graylog = new Graylog({
  address: 'graylog.server.address',
  host: 'my-web-project.com',
  node: 'dev.log.test',
  compress: false
});

graylog.log('String line log');
graylog.log({code: 1245, label: 'label'});
graylog.log({code: 1245, label: 'label'}, graylog.level.DEBUG);
graylog.log({code: 1245, label: 'label', level: 6});
graylog.log({code: 1245, label: 'label', level: graylog.level.ALERT});
graylog.log({code: 1245, label: 'label', level: 'error'});

graylog.log({
  data: ['sss', 'sfdsf', 'sfddsf', {odd: {a: 'a', b: {b: [{a: 'a', b: {a: 'a'}}, 'ss']}}}],
  message: 'array data'
});

let error;
try {
  throw new Error('test error');
} catch (e) {
  error = e;
}
graylog.error(error);
graylog.error({message: 'exec test error', error});

graylog.info('info');
graylog.debug('debug');
graylog.emergency('emergency');
graylog.alert('alert');
graylog.critical('critical');
graylog.notice('notice');

Levels

graylog.level[levelNameUppercase]

codenamedescription
0emergencysystem is unusable
1alertaction must be taken immediately
2criticalcritical conditions
3errorerror conditions
4warningwarning conditions
5noticenormal, but significant, condition
6infoinformational message
7debugdebug level message

Constructor

nametypedefaultdescription
portnumber12201port on server
addressstringlocalhostAddress Graylog server
hoststringclient hostname
nodestringnodeclient node name
defaultLevelstring/number/ObjectINFOdefault log level
compressbooleantruelog data compression