Commits

Brodie Rao committed d8135d5

Add DOGSLOW_LOG_LEVEL setting

  • Participants
  • Parent commits 0dfbe00

Comments (0)

Files changed (2)

 
     # Also log to this logger (defaults to none):
     DOGSLOW_LOGGER = 'syslog_logger'
+    DOGSLOW_LOG_LEVEL = 'WARNING'
 
     # Tuple of url pattern names that should not be monitored:
     # (defaults to none -- everything monitored)

File dogslow/__init__.py

 
             # and a custom logger:
             logger_name = getattr(settings, 'DOGSLOW_LOGGER', None)
+            log_level = getattr(settings, 'DOGSLOW_LOG_LEVEL', 'WARNING')
             if logger_name is not None:
+                log_level = logging.getLevelName(log_level)
                 logger = logging.getLogger(logger_name)
-                logger.warn('Slow Request Watchdog: %s, %%s - %%s' %
-                            resolve(request.META.get('PATH_INFO')).url_name,
-                            req_string.encode('utf-8'), output)
+                logger.log(log_level, 'Slow Request Watchdog: %s, %%s - %%s' %
+                           resolve(request.META.get('PATH_INFO')).url_name,
+                           req_string.encode('utf-8'), output)
 
         except Exception:
             logging.exception('Request watchdog failed')