I have been looking through SiteErrorLog and you use SiteErrorLog.raising(self, info) where info is apparently a tuple but it is requiring me to pass self and nothing I've tried works.
Also, trying your example of
from logging import getLogger
logger = getLogger(__name__)
logger.exception(e)
does not work for a few reasons:
- you cannot use underscores in a zope python script
- restrictedPython doesn't allow the use of exception
I am not trying to log to a file. I am just trying to get the same error log result as would normally occur.
Also, I tried using raising in an external method but I can't get that to work either. I am using an external method because I could not get raising authorized within the ZMI no matter what I tried. For example, in my __init__.py
I have
allow_module("Products.SiteErrorLog.SiteErrorLog")
from Products.SiteErrorLog.SiteErrorLog import SiteErrorLog
allow_class(SiteErrorLog)
but it refuses to allow me to use raising within the python script in the ZMI.
My external method looks like this:
from Products.SiteErrorLog.SiteErrorLog import SiteErrorLog
def logError(error):
errorType = type(error).__name__
errorStr = str(error)
error_info = (errorType, errorStr, None)
SiteErrorLog.raising(None, error_info)
Can you provide an actual example of the code that will properly log the exception as zope normally does if I did not have an except block? That's what I am trying to accomplish.