-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
57 lines (47 loc) · 1.46 KB
/
index.ts
File metadata and controls
57 lines (47 loc) · 1.46 KB
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
56
57
import tracer from "dd-trace";
import express from 'express';
// CommonJS style
// const BuffLog = require('./bufflog');
// 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', {"test":"toto"});
BuffLog.warning('hello warning');
BuffLog.error('hello error');
BuffLog.critical('hello critical');
BuffLog.critical('hello critical', {"some":"stuff"});
BuffLog.critical<{type: string}>('hello critical', {"type":"with type enforced context"});
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');
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!'
});
});