File tree Expand file tree Collapse file tree 2 files changed +43
-4
lines changed Expand file tree Collapse file tree 2 files changed +43
-4
lines changed Original file line number Diff line number Diff line change 1
1
2
2
export class BuffLog {
3
- name : string ;
3
+ pinoLogger : any ;
4
+ defaultLevel = 'notice' ;
4
5
5
6
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
+ } ) ;
7
14
}
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
+
8
41
}
Original file line number Diff line number Diff line change 1
1
import { BuffLog } from './bufflog' ;
2
2
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' ) ;
You can’t perform that action at this time.
0 commit comments