Exemple #1
0
def log(msg, level=LOGDEBUG, component=None):
    req_level = level
    # override message level to force logging when addon logging turned on
    debug_enabled = control.setting('addon_debug')
    debug_log = control.setting('debug.location')

    print DEBUGPREFIX + ' Debug Enabled?: ' + str(debug_enabled)
    print DEBUGPREFIX + ' Debug Log?: ' + str(debug_log)

    if kodi.get_setting('addon_debug') == 'true' and level == LOGDEBUG:
        level = LOGNOTICE

    try:
        if isinstance(msg, unicode):
            msg = '%s (ENCODED)' % (msg.encode('utf-8'))
        if not control.setting('debug.location') == '0':
            log_file = os.path.join(LOGPATH, 'dsrd.log')
            if not os.path.exists(log_file):
                f = open(log_file, 'w')
                f.close()
            with open(log_file, 'a') as f:
                line = '[%s %s] %s: %s' % (datetime.now().date(),
                                           str(datetime.now().time())[:8],
                                           DEBUGPREFIX, msg)
                f.write(line.rstrip('\r\n') + '\n')

        if req_level != LOGDEBUG or (enabled_comp is None
                                     or component in enabled_comp):
            kodi._log('%s: %s' % (name, msg), level)

    except Exception as e:
        try:
            kodi._log('Logging Failure: %s' % (e), level)
        except:
            pass  # just give up
def log(msg, level=LOGDEBUG, component=None):
    req_level = level
    # override message level to force logging when addon logging turned on
    if kodi.get_setting('addon_debug') == 'true' and level == LOGDEBUG:
        level = LOGNOTICE
    
    try:
        if isinstance(msg, unicode):
            msg = '%s (ENCODED)' % (msg.encode('utf-8'))

        if req_level != LOGDEBUG or (enabled_comp is None or component in enabled_comp):
            kodi._log('%s: %s' % (name, msg), level)
            
    except Exception as e:
        try: kodi._log('Logging Failure: %s' % (e), level)
        except: pass  # just give up
def log(msg, level=LOGDEBUG, component=None):
    req_level = level
    # override message level to force logging when addon logging turned on
    if kodi.get_setting('addon_debug') == 'true' and level == LOGDEBUG:
        level = LOGNOTICE
    
    try:
        if isinstance(msg, unicode):
            msg = '%s (ENCODED)' % (msg.encode('utf-8'))

        if req_level != LOGDEBUG or (enabled_comp is None or component in enabled_comp):
            kodi._log('%s: %s' % (name, msg), level)
            
    except Exception as e:
        try: kodi._log('Logging Failure: %s' % (e), level)
        except: pass  # just give up
 def log(self, msg, level=LOGDEBUG):
     # if debug isn't on, skip disabled loggers unless addon_debug is on
     if not self.__debug_on:
         if self in self.__disabled:
             return
         elif level == LOGDEBUG:
             if self.__addon_debug:
                 level = LOGNOTICE
             else:
                 return
     
     try:
         if isinstance(msg, unicode):
             msg = '%s (ENCODED)' % (msg.encode('utf-8'))
 
         kodi._log('%s: %s' % (self.__name, msg), level)
             
     except Exception as e:
         try: kodi._log('Logging Failure: %s' % (e), level)
         except: pass  # just give up
 def log(self, msg, level=LOGDEBUG):
     # if debug isn't on, skip disabled loggers unless addon_debug is on
     if not self.__debug_on:
         if self in self.__disabled:
             return
         elif level == LOGDEBUG:
             if self.__addon_debug:
                 level = LOGNOTICE
             else:
                 return
     
     try:
         if isinstance(msg, unicode):
             msg = '%s (ENCODED)' % (msg.encode('utf-8'))
 
         kodi._log('%s: %s' % (self.__name, msg), level)
             
     except Exception as e:
         try: kodi._log('Logging Failure: %s' % (e), level)
         except: pass  # just give up