mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Rename Owner.log to Owner.logmark
Since every plugin has a log method (to do actual logging), the log command
was conflicting with that. The attempted workaround was overly complicated
and broken. Simply renaming the command to logmark simplifies everything.
Closes Sf #2889709
Signed-off-by: James Vega <jamessan@users.sourceforge.net>
(cherry picked from commit acaa9b1fd6
)
This commit is contained in:
parent
d95cdfec34
commit
c53f8cd510
@ -1,6 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||||
# Copyright (c) 2008, James Vega
|
# Copyright (c) 2008-2009, James Vega
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -100,32 +100,6 @@ registerDefaultPlugin('capabilities', 'User')
|
|||||||
registerDefaultPlugin('addcapability', 'Admin')
|
registerDefaultPlugin('addcapability', 'Admin')
|
||||||
registerDefaultPlugin('removecapability', 'Admin')
|
registerDefaultPlugin('removecapability', 'Admin')
|
||||||
|
|
||||||
class holder(object):
|
|
||||||
pass
|
|
||||||
|
|
||||||
# This is used so we can support a "log" command as well as a "self.log"
|
|
||||||
# Logger.
|
|
||||||
class LogProxy(object):
|
|
||||||
"""<text>
|
|
||||||
|
|
||||||
Logs <text> to the global Supybot log at critical priority. Useful for
|
|
||||||
marking logfiles for later searching.
|
|
||||||
"""
|
|
||||||
__name__ = 'log' # Necessary for help.
|
|
||||||
def __init__(self, log):
|
|
||||||
self.log = log
|
|
||||||
self.im_func = holder()
|
|
||||||
self.im_func.func_name = 'log'
|
|
||||||
|
|
||||||
def __call__(self, irc, msg, args, text):
|
|
||||||
log.critical(text)
|
|
||||||
irc.replySuccess()
|
|
||||||
__call__ = wrap(__call__, ['text'])
|
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
|
||||||
return getattr(self.log, attr)
|
|
||||||
|
|
||||||
|
|
||||||
class Owner(callbacks.Plugin):
|
class Owner(callbacks.Plugin):
|
||||||
# This plugin must be first; its priority must be lowest; otherwise odd
|
# This plugin must be first; its priority must be lowest; otherwise odd
|
||||||
# things will happen when adding callbacks.
|
# things will happen when adding callbacks.
|
||||||
@ -134,8 +108,6 @@ class Owner(callbacks.Plugin):
|
|||||||
assert not irc.getCallback(self.name())
|
assert not irc.getCallback(self.name())
|
||||||
self.__parent = super(Owner, self)
|
self.__parent = super(Owner, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
# Setup log object/command.
|
|
||||||
self.log = LogProxy(self.log)
|
|
||||||
# Setup command flood detection.
|
# Setup command flood detection.
|
||||||
self.commands = ircutils.FloodQueue(60)
|
self.commands = ircutils.FloodQueue(60)
|
||||||
# Setup plugins and default plugins for commands.
|
# Setup plugins and default plugins for commands.
|
||||||
@ -185,10 +157,6 @@ class Owner(callbacks.Plugin):
|
|||||||
return None
|
return None
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
def isCommandMethod(self, name):
|
|
||||||
return name == 'log' or \
|
|
||||||
self.__parent.isCommandMethod(name)
|
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
# This has to be done somewhere, I figure here is as good place as any.
|
# This has to be done somewhere, I figure here is as good place as any.
|
||||||
callbacks.IrcObjectProxy._mores.clear()
|
callbacks.IrcObjectProxy._mores.clear()
|
||||||
@ -298,6 +266,16 @@ class Owner(callbacks.Plugin):
|
|||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
irc.queueMsg(callbacks.error(msg, str(e)))
|
irc.queueMsg(callbacks.error(msg, str(e)))
|
||||||
|
|
||||||
|
def logmark(self, irc, msg, args, text):
|
||||||
|
"""<text>
|
||||||
|
|
||||||
|
Logs <text> to the global Supybot log at critical priority. Useful for
|
||||||
|
marking logfiles for later searching.
|
||||||
|
"""
|
||||||
|
self.log.critical(text)
|
||||||
|
irc.replySuccess()
|
||||||
|
logmark = wrap(logmark, ['text'])
|
||||||
|
|
||||||
def announce(self, irc, msg, args, text):
|
def announce(self, irc, msg, args, text):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
|
||||||
@ -622,4 +600,3 @@ class Owner(callbacks.Plugin):
|
|||||||
Class = Owner
|
Class = Owner
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||||
|
# Copyright (c) 2009, James Vega
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -33,10 +34,9 @@ import supybot.conf as conf
|
|||||||
import supybot.plugin as plugin
|
import supybot.plugin as plugin
|
||||||
|
|
||||||
class OwnerTestCase(PluginTestCase):
|
class OwnerTestCase(PluginTestCase):
|
||||||
# Defaults, but hey, I'm cool.
|
|
||||||
plugins = ('Owner', 'Config', 'Misc', 'Admin')
|
plugins = ('Owner', 'Config', 'Misc', 'Admin')
|
||||||
def testHelpLog(self):
|
def testHelpLog(self):
|
||||||
self.assertHelp('help log')
|
self.assertHelp('help logmark')
|
||||||
|
|
||||||
def testSrcAmbiguity(self):
|
def testSrcAmbiguity(self):
|
||||||
self.assertError('capability add foo bar')
|
self.assertError('capability add foo bar')
|
||||||
|
Loading…
Reference in New Issue
Block a user