File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33
44let nopLogger = {
5+ debug ( ) { } ,
56 info ( ) { } ,
67 warn ( ) { } ,
78 error ( ) { }
@@ -11,6 +12,7 @@ const NONE = 0;
1112const ERROR = 1 ;
1213const WARN = 2 ;
1314const INFO = 3 ;
15+ const DEBUG = 4 ;
1416
1517let logger ;
1618let level ;
@@ -20,6 +22,7 @@ export default class Log {
2022 static get ERROR ( ) { return ERROR } ;
2123 static get WARN ( ) { return WARN } ;
2224 static get INFO ( ) { return INFO } ;
25+ static get DEBUG ( ) { return DEBUG } ;
2326
2427 static reset ( ) {
2528 level = INFO ;
@@ -30,7 +33,7 @@ export default class Log {
3033 return level ;
3134 }
3235 static set level ( value ) {
33- if ( NONE <= value && value <= INFO ) {
36+ if ( NONE <= value && value <= DEBUG ) {
3437 level = value ;
3538 }
3639 else {
@@ -42,14 +45,24 @@ export default class Log {
4245 return logger ;
4346 }
4447 static set logger ( value ) {
45- if ( value . info && value . warn && value . error ) {
48+ if ( ! value . debug && value . info ) {
49+ // just to stay backwards compat. can remove in 2.0
50+ value . debug = value . info ;
51+ }
52+
53+ if ( value . debug && value . info && value . warn && value . error ) {
4654 logger = value ;
4755 }
4856 else {
4957 throw new Error ( "Invalid logger" ) ;
5058 }
5159 }
5260
61+ static debug ( ...args ) {
62+ if ( level >= DEBUG ) {
63+ logger . debug . apply ( logger , Array . from ( args ) ) ;
64+ }
65+ }
5366 static info ( ...args ) {
5467 if ( level >= INFO ) {
5568 logger . info . apply ( logger , Array . from ( args ) ) ;
You can’t perform that action at this time.
0 commit comments