Merge pull request #377 from selwin/logging-fix

Only add logging handler if nothing is configured
main
Selwin Ong 11 years ago
commit 2ab7276230

@ -11,32 +11,15 @@ try:
except ImportError: except ImportError:
from rq.compat.dictconfig import dictConfig # noqa from rq.compat.dictconfig import dictConfig # noqa
from rq.utils import ColorizingStreamHandler
def setup_loghandlers(level=None):
if not logging._handlers:
dictConfig({
'version': 1,
'disable_existing_loggers': False,
'formatters': { def setup_loghandlers(level='INFO'):
'console': { logger = logging.getLogger('rq.worker')
'format': '%(asctime)s %(message)s', if not logger.handlers:
'datefmt': '%H:%M:%S', logger.setLevel(level)
}, formatter = logging.Formatter(fmt='%(asctime)s %(message)s',
}, datefmt='%H:%M:%S')
handler = ColorizingStreamHandler()
'handlers': { handler.setFormatter(formatter)
'console': { logger.addHandler(handler)
'level': 'DEBUG',
# 'class': 'logging.StreamHandler',
'class': 'rq.utils.ColorizingStreamHandler',
'formatter': 'console',
'exclude': ['%(asctime)s'],
},
},
'root': {
'handlers': ['console'],
'level': level or 'INFO',
}
})

@ -17,8 +17,6 @@ from rq.scripts import (add_standard_arguments, read_config_file,
setup_default_arguments, setup_redis) setup_default_arguments, setup_redis)
from rq.utils import import_attribute from rq.utils import import_attribute
logger = logging.getLogger(__name__)
def parse_args(): def parse_args():
parser = argparse.ArgumentParser(description='Starts an RQ worker.') parser = argparse.ArgumentParser(description='Starts an RQ worker.')

Loading…
Cancel
Save