-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.ts
54 lines (45 loc) · 1.47 KB
/
index.ts
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
import tracer from 'dd-trace';
import express from 'express';
// ES6 style
import BuffLog from "./bufflog";
tracer.init({
hostname: "dd-agent-hostname",
// will automatically append the traces to BuffLog
logInjection: true
});
BuffLog.debug('hello debug');
BuffLog.info('hello info');
BuffLog.notice('hello notice');
BuffLog.notice('hello notice with context to redact', {"test":"toto", "password":"must-redact", req: {headers: {cookie: "must-redact"}}});
BuffLog.warning('hello warning');
BuffLog.error('hello error');
BuffLog.critical('hello critical');
BuffLog.critical('hello critical', {"some":"stuff"});
const app = express();
app.use(BuffLog.middleware())
app.listen(4000, () => {
console.log(`Server is listening on port 4000`);
});
app.get('/', (req, res) => {
BuffLog.notice("Notice log via endpoint");
BuffLog.info('hello info');
BuffLog.debug('hello debug');
BuffLog.notice('hello notice');
BuffLog.warning('hello warning');
BuffLog.error('hello error');
BuffLog.critical('hello critical');
BuffLog.notice("Notice log via endpoint with req and res in context", {req ,res});
res.send({'hello': 'world'})
});
app.get('/error500', (req, res) => {
BuffLog.critical('hello critical');
return res.status(500).send({
message: 'This is an error 500!'
});
});
app.get('/error404', (req, res) => {
BuffLog.critical('hello critical');
return res.status(404).send({
message: 'This is a 404!'
});
});