File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package log
22
33import  (
44	"bytes" 
5+ 	"strings" 
56)
67
78// AllLevels is an array of all log levels, for easier registering of all levels to a handler 
@@ -54,8 +55,9 @@ func (l Level) String() string {
5455	}
5556}
5657
57- func  level (s  string ) Level  {
58- 	switch  s  {
58+ // ParseLevel parses the provided strings log level or if not supported return 255 
59+ func  ParseLevel (s  string ) Level  {
60+ 	switch  strings .ToUpper (s ) {
5961	case  "DEBUG" :
6062		return  DebugLevel 
6163	case  "INFO" :
@@ -84,6 +86,6 @@ func (l Level) MarshalJSON() ([]byte, error) {
8486
8587// UnmarshalJSON implementation. 
8688func  (l  * Level ) UnmarshalJSON (b  []byte ) error  {
87- 	* l  =  level (string (bytes .Trim (b , `"` )))
89+ 	* l  =  ParseLevel (string (bytes .Trim (b , `"` )))
8890	return  nil 
8991}
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments