From c53f8cd5105a965e4f1d4db1a82b54dd4c2649c2 Mon Sep 17 00:00:00 2001 From: James Vega Date: Sat, 31 Oct 2009 18:22:14 -0400 Subject: [PATCH] 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 (cherry picked from commit acaa9b1fd6cc9a137db9f97e446ff994c0499273) --- plugins/Owner/plugin.py | 45 ++++++++++------------------------------- plugins/Owner/test.py | 4 ++-- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/plugins/Owner/plugin.py b/plugins/Owner/plugin.py index cd44ec15c..5c3d895f8 100644 --- a/plugins/Owner/plugin.py +++ b/plugins/Owner/plugin.py @@ -1,6 +1,6 @@ ### # Copyright (c) 2002-2005, Jeremiah Fincher -# Copyright (c) 2008, James Vega +# Copyright (c) 2008-2009, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -100,32 +100,6 @@ registerDefaultPlugin('capabilities', 'User') registerDefaultPlugin('addcapability', '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): - """ - - Logs 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): # This plugin must be first; its priority must be lowest; otherwise odd # things will happen when adding callbacks. @@ -134,8 +108,6 @@ class Owner(callbacks.Plugin): assert not irc.getCallback(self.name()) self.__parent = super(Owner, self) self.__parent.__init__(irc) - # Setup log object/command. - self.log = LogProxy(self.log) # Setup command flood detection. self.commands = ircutils.FloodQueue(60) # Setup plugins and default plugins for commands. @@ -185,10 +157,6 @@ class Owner(callbacks.Plugin): return None return msg - def isCommandMethod(self, name): - return name == 'log' or \ - self.__parent.isCommandMethod(name) - def reset(self): # This has to be done somewhere, I figure here is as good place as any. callbacks.IrcObjectProxy._mores.clear() @@ -298,6 +266,16 @@ class Owner(callbacks.Plugin): except SyntaxError, e: irc.queueMsg(callbacks.error(msg, str(e))) + def logmark(self, irc, msg, args, text): + """ + + Logs 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): """ @@ -622,4 +600,3 @@ class Owner(callbacks.Plugin): Class = Owner # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: - diff --git a/plugins/Owner/test.py b/plugins/Owner/test.py index 625332827..61b5f2531 100644 --- a/plugins/Owner/test.py +++ b/plugins/Owner/test.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2002-2005, Jeremiah Fincher +# Copyright (c) 2009, James Vega # All rights reserved. # # 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 class OwnerTestCase(PluginTestCase): - # Defaults, but hey, I'm cool. plugins = ('Owner', 'Config', 'Misc', 'Admin') def testHelpLog(self): - self.assertHelp('help log') + self.assertHelp('help logmark') def testSrcAmbiguity(self): self.assertError('capability add foo bar')