From 9e3f412f0b878a1103eefce8d5198cc93b9d269b Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 2 Mar 2018 19:55:17 -0800 Subject: [PATCH] log: rename methods to snake case (#523) --- coremods/control.py | 8 ++++---- log.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/coremods/control.py b/coremods/control.py index 76325ec..380ca34 100644 --- a/coremods/control.py +++ b/coremods/control.py @@ -8,7 +8,7 @@ import sys import atexit from pylinkirc import world, utils, conf # Do not import classes, it'll import loop -from pylinkirc.log import log, makeFileLogger, stopFileLoggers, getConsoleLogLevel +from pylinkirc.log import log, _make_file_logger, _stop_file_loggers, _get_console_log_level from . import permissions def remove_network(ircobj): @@ -96,14 +96,14 @@ def rehash(): conf.conf = new_conf # Reset any file logger options. - stopFileLoggers() + _stop_file_loggers() files = new_conf['logging'].get('files') if files: for filename, config in files.items(): - makeFileLogger(filename, config.get('loglevel')) + _make_file_logger(filename, config.get('loglevel')) log.debug('rehash: updating console log level') - world.console_handler.setLevel(getConsoleLogLevel()) + world.console_handler.setLevel(_get_console_log_level()) for network, ircobj in world.networkobjects.copy().items(): # Server was removed from the config file, disconnect them. diff --git a/log.py b/log.py index f5057ea..347d592 100644 --- a/log.py +++ b/log.py @@ -22,7 +22,7 @@ os.makedirs(logdir, exist_ok=True) _format = '%(asctime)s [%(levelname)s] %(message)s' logformatter = logging.Formatter(_format) -def getConsoleLogLevel(): +def _get_console_log_level(): """ Returns the configured console log level. """ @@ -32,7 +32,7 @@ def getConsoleLogLevel(): # Set up logging to STDERR world.console_handler = logging.StreamHandler() world.console_handler.setFormatter(logformatter) -world.console_handler.setLevel(getConsoleLogLevel()) +world.console_handler.setLevel(_get_console_log_level()) # Get the main logger object; plugins can import this variable for convenience. log = logging.getLogger() @@ -43,7 +43,7 @@ log.addHandler(world.console_handler) # the root logger. https://stackoverflow.com/questions/16624695 log.setLevel(1) -def makeFileLogger(filename, level=None): +def _make_file_logger(filename, level=None): """ Initializes a file logging target with the given filename and level. """ @@ -64,7 +64,7 @@ def makeFileLogger(filename, level=None): filelogger.setFormatter(logformatter) # If no log level is specified, use the same one as the console logger. - level = level or getConsoleLogLevel() + level = level or _get_console_log_level() filelogger.setLevel(level) log.addHandler(filelogger) @@ -73,7 +73,7 @@ def makeFileLogger(filename, level=None): return filelogger -def stopFileLoggers(): +def _stop_file_loggers(): """ De-initializes all file loggers. """ @@ -88,7 +88,7 @@ files = conf.conf['logging'].get('files') if files: for filename, config in files.items(): if isinstance(config, dict): - makeFileLogger(filename, config.get('loglevel')) + _make_file_logger(filename, config.get('loglevel')) else: log.warning('Got invalid file logging pair %r: %r; are your indentation and block ' 'commenting consistent?', filename, config)