code: def log_level(level):
      
      from six import string_types
  
      if isinstance(level, int):
          return level
  
      if isinstance(level, string_types):
          try: return int(level)
          except ValueError: pass
  
          try: return getattr(logging, level.upper())
          except AttributeError: pass
  
      raise ValueError("cannot convert '{}' into a log level".format(level))
docs: Attempt to convert the given argument into a log level.
  
      Log levels are represented as integers, where higher values are more 
      severe.  If the given level is already an integer, it is simply returned.  
      If the given level is a string that can be converted into an integer, it is 
      converted and that value is returned.  Finally, if the given level is a 
      string naming one of the levels defined in the logging module, return that 
      level.  If none of those conditions are met, raise a ValueError.