Skip to content

Commit 716b50a

Browse files
committed
Make bufflog instance importable
1 parent 9737cbc commit 716b50a

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

bufflog.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ export class BuffLog {
5454

5555
error(message: string, context?: object) {
5656
this.pinoLogger.error({context: context}, message);
57-
5857
}
5958

6059
// for consistency with php-bufflog, critical == fatal
6160
critical(message: string, context?: object) {
6261
this.pinoLogger.fatal({context: context}, message);
6362
}
6463

65-
}
64+
}
65+
66+
var bufflog = new BuffLog();
67+
export default bufflog;

index.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
import tracer from "dd-trace";
22
import express from 'express';
3-
import {BuffLog} from './bufflog';
3+
import bufflog from './bufflog';
44

55
tracer.init({
66
hostname: "dd-agent-hostname",
77
logInjection: false
88
});
99

10-
let logger = new BuffLog();
11-
12-
logger.info('hello info');
13-
logger.notice('hello notice');
14-
logger.notice('hello notice with context', {"test":"toto"});
15-
logger.warning('hello warning');
16-
logger.error('hello error');
17-
logger.critical('hello critical');
18-
logger.critical('hello critical', {"some":"stuff"});
10+
bufflog.info('hello info');
11+
bufflog.notice('hello notice');
12+
bufflog.notice('hello notice with context', {"test":"toto"});
13+
bufflog.warning('hello warning');
14+
bufflog.error('hello error');
15+
bufflog.critical('hello critical');
16+
bufflog.critical('hello critical', {"some":"stuff"});
1917

2018
const app = express();
2119

@@ -24,12 +22,11 @@ app.listen(4000, () => {
2422
});
2523

2624
app.get('/', (req, res) => {
27-
var logger = new BuffLog();
28-
logger.notice("Notice log via endpoint");
29-
logger.info('hello info');
30-
logger.debug('hello debug');
31-
logger.notice('hello notice');
32-
logger.warning('hello warning');
33-
logger.error('hello error');
34-
logger.critical('hello critical');
25+
bufflog.notice("Notice log via endpoint");
26+
bufflog.info('hello info');
27+
bufflog.debug('hello debug');
28+
bufflog.notice('hello notice');
29+
bufflog.warning('hello warning');
30+
bufflog.error('hello error');
31+
bufflog.critical('hello critical');
3532
});

0 commit comments

Comments
 (0)