text: # Unless explicitly stated otherwise all files in this repository are licensed
  # under the Apache License Version 2.0.
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
  # Copyright 2018 Datadog, Inc.
  
  import logging
  
  log_level_map = {
      'CRIT': logging.CRITICAL,
      'CRITICAL': logging.CRITICAL,
      'ERR':  logging.ERROR,
      'ERROR':  logging.ERROR,
      'WARN': logging.WARNING,
      'WARNING': logging.WARNING,
      'INFO': logging.INFO,
      'DEBUG': logging.DEBUG,
      'TRACE': logging.DEBUG,
  }
  
  
  def _is_affirmative(s):
      if s is None:
          return False
      # int or real bool
      if isinstance(s, int):
          return bool(s)
      # try string cast
      return s.lower() in ('yes', 'true', '1')
  
  
  def _get_py_loglevel(l):
      if not l:
          l = 'INFO'
      return log_level_map.get(l.upper(), logging.DEBUG)
  