From 1eb09b8ff8b6c2036038eea07851d376b5c439aa Mon Sep 17 00:00:00 2001 From: hawkowl Date: Tue, 4 Nov 2014 10:05:29 +0000 Subject: [PATCH] Revert r42936: Revert #6750 and related tickets Please see http://twistedmatrix.com/pipermail/twisted-python/2014-November/028912.html for more details. Reopens: #7548 git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@43428 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb --- docs/core/howto/logger.rst | 41 ++----------------------- twisted/python/logger/_file.py | 14 +++------ twisted/python/logger/test/test_file.py | 27 ---------------- twisted/topfiles/7548.bugfix | 2 -- 4 files changed, 6 insertions(+), 78 deletions(-) delete mode 100644 twisted/topfiles/7548.bugfix diff --git a/docs/core/howto/logger.rst b/docs/core/howto/logger.rst index 4c668e49ba9..b26695f8b17 100644 --- a/docs/core/howto/logger.rst +++ b/docs/core/howto/logger.rst @@ -100,38 +100,6 @@ For example: This example will show the string "object with value 7 doing a task" because the ``log_source`` key is automatically set to the ``MyObject`` instance that the ``Logger`` is retrieved from. -Capturing Failures -~~~~~~~~~~~~~~~~~~ - -:api:`twisted.python.logger.Logger ` provides a :api:`twisted.python.logger.Logger.failure ` method, which allows one to capture a :api:`twisted.python.failure.Failure ` object conveniently: - -.. code-block:: python - - from twisted.python.logger import Logger - log = Logger() - - try: - 1 / 0 - except: - log.failure("Math is hard!") - -The emitted event will have the ``"log_failure"`` key set, which is a :api:`twisted.python.failure.Failure ` than captures the exception. -This can be used my observers to obtain a traceback. -For example, :api:`twisted.python.logger.FileLogObserver ` will append the traceback to it's output:: - - Math is hard! - - Traceback (most recent call last): - --- --- - File "/tmp/test.py", line 8, in - 1/0 - exceptions.ZeroDivisionError: integer division or modulo by zero - -Note that this API is meant to capture unexpected and unhandled errors (that is: bugs, which is why tracebacks are preserved). -As such, it defaults to logging that the :api:`twisted.python.logger.LogLevel.critical ` level. -It is generally more appropriate to instead use `log.error()` when logging an expected error condition that was appropriately handled by the software. - - Namespaces ~~~~~~~~~~ @@ -237,9 +205,8 @@ Event keys added by the system The logging system will add keys to emitted events. All event keys that are inserted by the logging system with have a ``log_`` prefix, to avoid namespace collisions with application-provided event keys. -Applications should therefore not insert event keys using the ``log_`` prefix, as that prefix is reserved for the logging system. System-provided event keys include: - + ``log_logger`` :api:`twisted.python.logger.Logger ` object that the event was emitted to. @@ -268,15 +235,11 @@ System-provided event keys include: The time that the event was emitted, as returned by :api:`time.time