mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-23 18:54:05 +01:00
parent
caade5a308
commit
60a0bcdc7a
5
conf.py
5
conf.py
@ -101,6 +101,11 @@ def validateConf(conf, logger=None):
|
|||||||
if newlogins and not old_login_valid:
|
if newlogins and not old_login_valid:
|
||||||
validate(conf.get('permissions'), "New-style accounts enabled but no permissions block was found. You will not be able to administrate your PyLink instance!")
|
validate(conf.get('permissions'), "New-style accounts enabled but no permissions block was found. You will not be able to administrate your PyLink instance!")
|
||||||
|
|
||||||
|
if conf['logging'].get('stdout'):
|
||||||
|
_log(logging.WARNING, 'The log:stdout option is deprecated since PyLink 1.2 in favour of '
|
||||||
|
'(a more correctly named) log:console. Please update your '
|
||||||
|
'configuration accordingly!', logger=logger)
|
||||||
|
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import sys
|
|||||||
import atexit
|
import atexit
|
||||||
|
|
||||||
from pylinkirc import world, utils, conf, classes
|
from pylinkirc import world, utils, conf, classes
|
||||||
from pylinkirc.log import log, makeFileLogger, stopFileLoggers, stdoutLogLevel
|
from pylinkirc.log import log, makeFileLogger, stopFileLoggers, getConsoleLogLevel
|
||||||
from . import permissions
|
from . import permissions
|
||||||
|
|
||||||
tried_shutdown = False
|
tried_shutdown = False
|
||||||
@ -96,8 +96,8 @@ def _rehash():
|
|||||||
for filename, config in files.items():
|
for filename, config in files.items():
|
||||||
makeFileLogger(filename, config.get('loglevel'))
|
makeFileLogger(filename, config.get('loglevel'))
|
||||||
|
|
||||||
log.debug('rehash: updating STDOUT log level')
|
log.debug('rehash: updating console log level')
|
||||||
world.stdout_handler.setLevel(stdoutLogLevel())
|
world.console_handler.setLevel(getConsoleLogLevel())
|
||||||
|
|
||||||
# Reset permissions.
|
# Reset permissions.
|
||||||
log.debug('rehash: resetting permissions')
|
log.debug('rehash: resetting permissions')
|
||||||
|
@ -463,10 +463,12 @@ logging:
|
|||||||
# This configuration block defines targets that PyLink should log commands,
|
# This configuration block defines targets that PyLink should log commands,
|
||||||
# errors, etc., to.
|
# errors, etc., to.
|
||||||
|
|
||||||
# This sets the level for STDOUT logging, which is always enabled. Valid
|
# This sets the level for console logging, which is always enabled. Valid
|
||||||
# settings include DEBUG, INFO, WARNING, ERROR, and CRITICAL: see
|
# settings include DEBUG, INFO, WARNING, ERROR, and CRITICAL: see
|
||||||
# https://docs.python.org/3/library/logging.html#logging-levels for details.
|
# https://docs.python.org/3/library/logging.html#logging-levels for details.
|
||||||
stdout: INFO
|
# Prior to PyLink 1.2, this option was erroneously named 'log:stdout', even though the actual
|
||||||
|
# logging output goes to stderr. That option name (log:stdout) is now *deprecated*.
|
||||||
|
console: INFO
|
||||||
|
|
||||||
channels:
|
channels:
|
||||||
# Logs to channels on the specified networks.
|
# Logs to channels on the specified networks.
|
||||||
|
19
log.py
19
log.py
@ -22,20 +22,21 @@ os.makedirs(logdir, exist_ok=True)
|
|||||||
_format = '%(asctime)s [%(levelname)s] %(message)s'
|
_format = '%(asctime)s [%(levelname)s] %(message)s'
|
||||||
logformatter = logging.Formatter(_format)
|
logformatter = logging.Formatter(_format)
|
||||||
|
|
||||||
def stdoutLogLevel():
|
def getConsoleLogLevel():
|
||||||
"""
|
"""
|
||||||
Returns the configured STDOUT log level.
|
Returns the configured console log level.
|
||||||
"""
|
"""
|
||||||
return conf.conf['logging'].get('stdout') or 'INFO'
|
logconf = conf.conf['logging']
|
||||||
|
return logconf.get('console', logconf.get('stdout')) or 'INFO'
|
||||||
|
|
||||||
# Set up logging to STDERR
|
# Set up logging to STDERR
|
||||||
world.stdout_handler = logging.StreamHandler()
|
world.console_handler = logging.StreamHandler()
|
||||||
world.stdout_handler.setFormatter(logformatter)
|
world.console_handler.setFormatter(logformatter)
|
||||||
world.stdout_handler.setLevel(stdoutLogLevel())
|
world.console_handler.setLevel(getConsoleLogLevel())
|
||||||
|
|
||||||
# Get the main logger object; plugins can import this variable for convenience.
|
# Get the main logger object; plugins can import this variable for convenience.
|
||||||
log = logging.getLogger()
|
log = logging.getLogger()
|
||||||
log.addHandler(world.stdout_handler)
|
log.addHandler(world.console_handler)
|
||||||
|
|
||||||
# This is confusing, but we have to set the root logger to accept all events. Only this way
|
# This is confusing, but we have to set the root logger to accept all events. Only this way
|
||||||
# can other loggers filter out events on their own, instead of having everything dropped by
|
# can other loggers filter out events on their own, instead of having everything dropped by
|
||||||
@ -62,8 +63,8 @@ def makeFileLogger(filename, level=None):
|
|||||||
filelogger = logging.handlers.RotatingFileHandler(target, maxBytes=maxbytes, backupCount=backups)
|
filelogger = logging.handlers.RotatingFileHandler(target, maxBytes=maxbytes, backupCount=backups)
|
||||||
filelogger.setFormatter(logformatter)
|
filelogger.setFormatter(logformatter)
|
||||||
|
|
||||||
# If no log level is specified, use the same one as STDOUT.
|
# If no log level is specified, use the same one as the console logger.
|
||||||
level = level or stdout_level
|
level = level or getConsoleLogLevel()
|
||||||
filelogger.setLevel(level)
|
filelogger.setLevel(level)
|
||||||
|
|
||||||
log.addHandler(filelogger)
|
log.addHandler(filelogger)
|
||||||
|
@ -209,10 +209,10 @@ def loglevel(irc, source, args):
|
|||||||
irc.error('Unknown log level "%s".' % level)
|
irc.error('Unknown log level "%s".' % level)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
world.stdout_handler.setLevel(loglevel)
|
world.console_handler.setLevel(loglevel)
|
||||||
irc.reply("Done.")
|
irc.reply("Done.")
|
||||||
except IndexError:
|
except IndexError:
|
||||||
irc.reply(world.stdout_handler.level)
|
irc.reply(world.console_handler.level)
|
||||||
|
|
||||||
@utils.add_cmd
|
@utils.add_cmd
|
||||||
def mkpasswd(irc, source, args):
|
def mkpasswd(irc, source, args):
|
||||||
|
Loading…
Reference in New Issue
Block a user