add --verbose mode
This commit is contained in:
parent
e0299ace20
commit
d4a3499680
@ -23,12 +23,15 @@ DENY = {}
|
|||||||
# Stop editing here
|
# Stop editing here
|
||||||
|
|
||||||
# Argument --debug means start in debug mode
|
# Argument --debug means start in debug mode
|
||||||
|
# --verbose means to print a lot of stuff (when not in debug mode)
|
||||||
import argparse
|
import argparse
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--debug', action='store_true')
|
parser.add_argument('--debug', action='store_true')
|
||||||
parser.add_argument('--sabotage', action='store_true')
|
parser.add_argument('--sabotage', action='store_true')
|
||||||
|
parser.add_argument('--verbose', action='store_true')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
DEBUG_MODE = args.debug if not DISABLE_DEBUG_MODE else False
|
DEBUG_MODE = args.debug if not DISABLE_DEBUG_MODE else False
|
||||||
|
VERBOSE_MODE = args.verbose
|
||||||
|
|
||||||
DEFAULT_MODULE = "sabotage" if args.sabotage else "wolfgame"
|
DEFAULT_MODULE = "sabotage" if args.sabotage else "wolfgame"
|
||||||
|
@ -54,7 +54,7 @@ def parse_raw_irc_command(element):
|
|||||||
try:
|
try:
|
||||||
command = numeric_events[command]
|
command = numeric_events[command]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logging.warn('unknown numeric event {0}'.format(command))
|
logging.debug('unknown numeric event {0}'.format(command))
|
||||||
command = command.lower()
|
command = command.lower()
|
||||||
if isinstance(command, bytes): command = command.decode("utf_8")
|
if isinstance(command, bytes): command = command.decode("utf_8")
|
||||||
|
|
||||||
|
13
wolfbot.py
13
wolfbot.py
@ -26,15 +26,24 @@ import botconfig
|
|||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import modules.common
|
import modules.common
|
||||||
|
import sys
|
||||||
|
|
||||||
class UTCFormatter(logging.Formatter):
|
class UTCFormatter(logging.Formatter):
|
||||||
converter = time.gmtime
|
converter = time.gmtime
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if not botconfig.DEBUG_MODE:
|
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')
|
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)
|
handler.setFormatter(formatter)
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user