Skip to content

Commit 2cd1bbe

Browse files
committed
Integrate Pino library
1 parent dc3f9c9 commit 2cd1bbe

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

bufflog.ts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
11

22
export class BuffLog {
3-
name: string;
3+
pinoLogger: any;
4+
defaultLevel = 'notice';
45

56
constructor() {
6-
this.name = "toto";
7+
this.pinoLogger = require('pino')({
8+
'level': this.defaultLevel,
9+
// notice doesn't exist in pino, let's add it
10+
customLevels: {
11+
notice: 35
12+
}
13+
});
714
}
15+
16+
debug(message: string) {
17+
this.pinoLogger.debug(message);
18+
}
19+
20+
info(message: string) {
21+
this.pinoLogger.info(message);
22+
}
23+
24+
notice(message: string) {
25+
this.pinoLogger.notice(message);
26+
}
27+
28+
warning(message: string) {
29+
this.pinoLogger.warn(message);
30+
}
31+
32+
error(message: string) {
33+
this.pinoLogger.error(message);
34+
}
35+
36+
// for consistency with php-bufflog, critical == fatal
37+
critical(message: string) {
38+
this.pinoLogger.fatal(message);
39+
}
40+
841
}

index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import {BuffLog} from './bufflog';
22

3-
let log = new BuffLog();
4-
console.log(log);
3+
let logger = new BuffLog();
4+
5+
logger.info('hello info');
6+
logger.debug('hello debug');
7+
logger.notice('hello notice');
8+
logger.warning('hello warning');
9+
logger.error('hello error');
10+
logger.critical('hello critical');

0 commit comments

Comments
 (0)