mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Added loglevel RFE.
This commit is contained in:
parent
2ea181073b
commit
1a824e4c2e
15
src/Admin.py
15
src/Admin.py
@ -41,10 +41,12 @@ import fix
|
||||
import time
|
||||
import pprint
|
||||
import string
|
||||
import logging
|
||||
import smtplib
|
||||
import textwrap
|
||||
from itertools import imap
|
||||
|
||||
import log
|
||||
import conf
|
||||
import ircdb
|
||||
import utils
|
||||
@ -369,6 +371,19 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
||||
irc.replySuccess()
|
||||
reportbug = privmsgs.thread(reportbug)
|
||||
|
||||
def loglevel(self, irc, msg, args):
|
||||
"""{DEBUG,INFO,WARNING,ERROR,CRITICAL}
|
||||
|
||||
Sets the logging level of the bot's logs.
|
||||
"""
|
||||
level = privmsgs.getArgs(args)
|
||||
try:
|
||||
level = getattr(logging, level.upper())
|
||||
except AttributeError:
|
||||
raise callbacks.ArgumentError
|
||||
log.setLevel(level)
|
||||
irc.replySuccess()
|
||||
|
||||
|
||||
Class = Admin
|
||||
|
||||
|
@ -150,16 +150,16 @@ pluginFormatter = Formatter('%(levelname)s %(asctime)s %(name)s %(message)s')
|
||||
_logger = logging.getLogger('supybot')
|
||||
_handler = BetterFileHandler(os.path.join(conf.logDir, 'misc.log'))
|
||||
_handler.setFormatter(formatter)
|
||||
_handler.setLevel(conf.minimumLogPriority)
|
||||
_handler.setLevel(-1)
|
||||
_logger.addHandler(_handler)
|
||||
_logger.setLevel(-1)
|
||||
_logger.setLevel(conf.minimumLogPriority)
|
||||
|
||||
if conf.stdoutLogging:
|
||||
_stdoutHandler = BetterStreamHandler(sys.stdout)
|
||||
_formatString = '%(name)s: %(levelname)s %(message)s'
|
||||
_stdoutFormatter = ColorizedFormatter(_formatString)
|
||||
_stdoutHandler.setFormatter(_stdoutFormatter)
|
||||
_stdoutHandler.setLevel(conf.minimumLogPriority)
|
||||
_stdoutHandler.setLevel(-1)
|
||||
_logger.addHandler(_stdoutHandler)
|
||||
|
||||
debug = _logger.debug
|
||||
@ -169,6 +169,8 @@ error = _logger.error
|
||||
critical = _logger.critical
|
||||
exception = _logger.exception
|
||||
|
||||
setLevel = _logger.setLevel
|
||||
|
||||
atexit.register(logging.shutdown)
|
||||
|
||||
def getPluginLogger(name):
|
||||
|
@ -44,6 +44,7 @@ import threading
|
||||
import conf
|
||||
import ircdb
|
||||
import world
|
||||
import ircmsgs
|
||||
import ircutils
|
||||
import callbacks
|
||||
import structures
|
||||
@ -78,6 +79,7 @@ def getArgs(args, required=1, optional=0):
|
||||
let the caller handle sending the help message.
|
||||
"""
|
||||
assert not isinstance(args, str), 'args should be a list.'
|
||||
assert not isinstance(args, ircmsgs.IrcMsg), 'args should be a list.'
|
||||
if len(args) < required:
|
||||
raise callbacks.ArgumentError
|
||||
if len(args) < required + optional:
|
||||
|
Loading…
Reference in New Issue
Block a user