def load_logfile_filename():
 throw_error = False
 if ('DIGITS_MODE_TEST' in os.environ):
  filename = None
 elif ('DIGITS_LOGFILE_FILENAME' in os.environ):
  filename = os.environ['DIGITS_LOGFILE_FILENAME']
  throw_error = True
 else:
  filename = os.path.join(os.path.dirname(digits.__file__), 'digits.log')
 if (filename is not None):
  try:
   filename = os.path.abspath(filename)
   dirname = os.path.dirname(filename)
   if (not os.path.exists(dirname)):
    os.makedirs(os.path.dirname(filename))
   with open(filename, 'a'):
    pass
  except:
   if throw_error:
    print ('"%s" is not a valid value for logfile_filename.' % filename)
    print 'Set the envvar DIGITS_LOGFILE_FILENAME to fix your configuration.'
    raise
   else:
    filename = None
 return filename

def load_logfile_filename ( ) : throw_error = False if ( 'DIGITS_MODE_TEST' in os . environ ) : filename = None elif ( 'DIGITS_LOGFILE_FILENAME' in os . environ ) : filename = os . environ [ 'DIGITS_LOGFILE_FILENAME' ] throw_error = True else : filename = os . path . join ( os . path . dirname ( digits . __file__ ) , 'digits.log' ) if ( filename is not None ) : try : filename = os . path . abspath ( filename ) dirname = os . path . dirname ( filename ) if ( not os . path . exists ( dirname ) ) : os . makedirs ( os . path . dirname ( filename ) ) with open ( filename , 'a' ) : pass except : if throw_error : print ( '"%s" is not a valid value for logfile_filename.' % filename ) print 'Set the envvar DIGITS_LOGFILE_FILENAME to fix your configuration.' raise else : filename = None return filename
return the configured log file or none throws an exception only if a manually specified log file is invalid .