Browse Source

add --verbose mode

master
jcao219 13 years ago
parent
commit
cd6dd83485
  1. 3
      botconfig.py.example
  2. 2
      oyoyo/parse.py
  3. 13
      wolfbot.py

3
botconfig.py.example

@ -23,12 +23,15 @@ DENY = {} @@ -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"

2
oyoyo/parse.py

@ -54,7 +54,7 @@ def parse_raw_irc_command(element): @@ -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")

13
wolfbot.py

@ -26,15 +26,24 @@ import botconfig @@ -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)

Loading…
Cancel
Save