diff --git a/botconfig.py.example b/botconfig.py.example index 9a0c323..8522e6c 100644 --- a/botconfig.py.example +++ b/botconfig.py.example @@ -23,12 +23,15 @@ DENY = {} # Stop editing here # Argument --debug means start in debug mode +# --verbose means to print a lot of stuff (when not in debug mode) import argparse parser = argparse.ArgumentParser() parser.add_argument('--debug', action='store_true') parser.add_argument('--sabotage', action='store_true') +parser.add_argument('--verbose', action='store_true') args = parser.parse_args() DEBUG_MODE = args.debug if not DISABLE_DEBUG_MODE else False +VERBOSE_MODE = args.verbose DEFAULT_MODULE = "sabotage" if args.sabotage else "wolfgame" diff --git a/oyoyo/parse.py b/oyoyo/parse.py index 8737ac8..f2bc1ec 100644 --- a/oyoyo/parse.py +++ b/oyoyo/parse.py @@ -54,7 +54,7 @@ def parse_raw_irc_command(element): try: command = numeric_events[command] except KeyError: - logging.warn('unknown numeric event {0}'.format(command)) + logging.debug('unknown numeric event {0}'.format(command)) command = command.lower() if isinstance(command, bytes): command = command.decode("utf_8") diff --git a/wolfbot.py b/wolfbot.py index f2fc54c..2626742 100755 --- a/wolfbot.py +++ b/wolfbot.py @@ -26,15 +26,24 @@ import botconfig import time import traceback import modules.common +import sys class UTCFormatter(logging.Formatter): converter = time.gmtime def main(): if not botconfig.DEBUG_MODE: - logging.basicConfig(filename='errors.log', filemode='a', level=logging.WARNING) + logger = logging.getLogger() + logger.setLevel(logging.DEBUG) + fh = logging.FileHandler("errors.log") + fh.setLevel(logging.WARNING) + logger.addHandler(fh) + if botconfig.VERBOSE_MODE: + hdlr = logging.StreamHandler(sys.stdout) + hdlr.setLevel(logging.DEBUG) + logger.addHandler(hdlr) formatter = UTCFormatter('[%(asctime)s] %(message)s', '%d/%b/%Y %H:%M:%S') - for handler in logging.getLogger().handlers: + for handler in logger.handlers: handler.setFormatter(formatter) else: logging.basicConfig(level=logging.DEBUG)