1
- function warn ( message : string ) {
2
- if ( __DEV__ ) {
3
- console . warn ( message ) ;
4
- }
1
+ interface BILogger {
2
+ log : ( event : any ) => void ;
5
3
}
4
+ class LogService {
5
+ private biLogger : BILogger | undefined ;
6
+
7
+ injectBILogger = ( biLogger : BILogger ) => {
8
+ this . biLogger = biLogger ;
9
+ } ;
6
10
7
- function error ( message : string ) {
8
- if ( __DEV__ ) {
9
- console . error ( message ) ;
11
+ logBI = ( event : any ) => {
12
+ this . biLogger ?. log ( event ) ;
10
13
}
14
+
15
+ warn = ( message : string ) => {
16
+ if ( __DEV__ ) {
17
+ console . warn ( message ) ;
18
+ }
19
+ } ;
20
+
21
+ error = ( message : string ) => {
22
+ if ( __DEV__ ) {
23
+ console . error ( message ) ;
24
+ }
25
+ } ;
26
+
27
+ deprecationWarn = ( { component, oldProp, newProp} : { component : string ; oldProp : string ; newProp ?: string } ) => {
28
+ this . warn ( getDeprecationMessage ( { component, oldProp, newProp} ) ) ;
29
+ } ;
30
+
31
+ componentDeprecationWarn = ( { oldComponent, newComponent} : { oldComponent : string ; newComponent : string } ) => {
32
+ this . warn ( getComponentDeprecationMessage ( { oldComponent, newComponent} ) ) ;
33
+ } ;
34
+
35
+ deprecationError = ( { component, oldProp, newProp} : { component : string ; oldProp : string ; newProp ?: string } ) => {
36
+ this . error ( getDeprecationMessage ( { component, oldProp, newProp} ) ) ;
37
+ } ;
38
+
39
+ componentDeprecationError = ( { oldComponent, newComponent} : { oldComponent : string ; newComponent : string } ) => {
40
+ this . error ( getComponentDeprecationMessage ( { oldComponent, newComponent} ) ) ;
41
+ } ;
11
42
}
12
43
13
44
function getDeprecationMessage ( { component, oldProp, newProp} : { component : string ; oldProp : string ; newProp ?: string } ) {
@@ -23,27 +54,4 @@ function getComponentDeprecationMessage({oldComponent, newComponent}: {oldCompon
23
54
return message ;
24
55
}
25
56
26
- function deprecationWarn ( { component, oldProp, newProp} : { component : string ; oldProp : string ; newProp ?: string } ) {
27
- warn ( getDeprecationMessage ( { component, oldProp, newProp} ) ) ;
28
- }
29
-
30
- function componentDeprecationWarn ( { oldComponent, newComponent} : { oldComponent : string ; newComponent : string } ) {
31
- warn ( getComponentDeprecationMessage ( { oldComponent, newComponent} ) ) ;
32
- }
33
-
34
- function deprecationError ( { component, oldProp, newProp} : { component : string ; oldProp : string ; newProp ?: string } ) {
35
- error ( getDeprecationMessage ( { component, oldProp, newProp} ) ) ;
36
- }
37
-
38
- function componentDeprecationError ( { oldComponent, newComponent} : { oldComponent : string ; newComponent : string } ) {
39
- error ( getComponentDeprecationMessage ( { oldComponent, newComponent} ) ) ;
40
- }
41
-
42
- export default {
43
- warn,
44
- error,
45
- deprecationWarn,
46
- componentDeprecationWarn,
47
- deprecationError,
48
- componentDeprecationError
49
- } ;
57
+ export default new LogService ( ) ;
0 commit comments