forked from uber/sentry-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manual.js
50 lines (40 loc) · 1.24 KB
/
manual.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
var zlib = require('zlib');
var format = require('util').format;
/* script to test sending messages to sentry
should only be used to test artifacts in the sentry GUI
*/
var SentryLogger = require('../index.js');
// ssh -L 8080:sentry.my.company:80 my-server
var DSN = 'http://{projectId}:' +
'{password}@' +
'localhost:8080/68';
var logger = SentryLogger({
dsn: DSN,
tags: { regionName: 'my_region' },
onRavenError: onRavenError
});
function sendError() {
// var error = new Error('some message13');
logger.log('{level}', 'test message20', {
'oh': 'hi'
}, function () {
console.log('flushed', arguments);
});
}
sendError();
function onRavenError(e) {
var message = new Buffer(String(e.sendMessage || ''), 'base64');
zlib.inflate(message, function (err, buff) {
var sendMessage = String(buff || '');
console.warn('Raven failed to upload to Sentry: ', {
message: e.message,
stack: e.stack,
reason: e.reason,
statusCode: e.statusCode,
sendMessage: sendMessage,
headers: e.response && e.response.headers
});
console.info(
format('could not log "%s" to raven', sendMessage));
});
}