Commits

Jason R. Coombs  committed a8a0dfb

Allow log level to be configurable.

  • Participants
  • Parent commits d229dbb
  • Tags 1104.4

Comments (0)

Files changed (2)

File pmxbot/__init__.py

 # vim:ts=4:sw=4:noexpandtab
 
 import socket
+import logging
 
 from .dictlib import ConfigDict
 
 	librarypaste = 'http://paste.jaraco.com',
 )
 config['logs URL'] = 'http://' + socket.getfqdn()
+config['log level'] = logging.INFO
 
 "The config object"

File pmxbot/core.py

 	_bot = initialize(get_args().config)
 	_bot.start()
 
+def _setup_logging():
+	log_level = pmxbot.config['log level']
+	if isinstance(log_level, basestring):
+		log_level = getattr(logging, log_level.upper())
+	logging.basicConfig(level=log_level, format="%(message)s")
+
 def initialize(config):
 	"""
 	Initialize the bot with a dictionary of config items
 	pmxbot.config.update(config)
 	config = pmxbot.config
 
-	logging.basicConfig(level=logging.INFO, format="%(message)s")
+	_setup_logging()
 	_load_library_extensions()
 	if not _handler_registry:
 		raise RuntimeError("No handlers registered")