forked from Wizcorp/node-graylog2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
55 lines (48 loc) · 2.15 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var graylog = require('./graylog'),
fs = require('fs'),
file,
data,
servers = [
{ 'host': '127.0.0.1', 'port': 12201 }
];
var client = new graylog.graylog({
servers: servers,
facility: 'Test logger / Node.JS Test Script'
});
console.log('---------------------------------------------');
console.log('Sending three test as info, warning and error');
console.log('---------------------------------------------');
client.log('test1', 'i get this1', {cool: 'beans'});
client.warn('test2', 'i get this2', {cool: 'beans'});
client.error('test3', 'i get this3', {cool: 'beans'});
client.error('customTime', 'i get this3', {cool: 'beans'}, new Date('2012-10-10 13:20:31.619Z'));
console.log('');
console.log('---------------------------------------------');
console.log('Sending Sean Connery\' picture (as critical)');
console.log('---------------------------------------------');
file = './data/sean.jpg';
data = fs.readFileSync(file);
client.critical('My Nice Sean Connery Picture', data.toString(), {name: 'James Bond'});
console.log('');
console.log('---------------------------------------------');
console.log('Sending data of different sizes (as critical)');
console.log('---------------------------------------------');
for (var i = 4; i <= 128; i *= 2) {
file = './data/' + i + '.dat';
data = fs.readFileSync(file);
console.log('sending', file);
client.critical('Test 4 ' + file, data.toString(), {datafile: i + '.dat'});
}
console.log('');
console.log('---------------------------------------------');
console.log('Sending different parameters');
console.log('---------------------------------------------');
client.log('ParametersTest - Only short message');
client.log('ParametersTest - Short message and json', {cool: 'beans'});
client.log('ParametersTest - Short message and full message', 'Full message');
client.log('ParametersTest - Short Message with full message and json', 'Full message', {cool: 'beans'});
console.log('');
client.close(function () {
console.log('Insertion complete. Please check', 'http://' + servers[0].host + ':3000', 'and verify that insertion was successfull');
console.log('');
});