@@ -469,12 +469,13 @@ Handlers
469469
470470:class: `~logging.Handler ` objects are responsible for dispatching the
471471appropriate log messages (based on the log messages' severity) to the handler's
472- specified destination. Logger objects can add zero or more handler objects to
473- themselves with an :func: `addHandler ` method. As an example scenario, an
474- application may want to send all log messages to a log file, all log messages
475- of error or higher to stdout, and all messages of critical to an email address.
476- This scenario requires three individual handlers where each handler is
477- responsible for sending messages of a specific severity to a specific location.
472+ specified destination. :class: `Logger ` objects can add zero or more handler
473+ objects to themselves with an :meth: `~Logger.addHandler ` method. As an example
474+ scenario, an application may want to send all log messages to a log file, all
475+ log messages of error or higher to stdout, and all messages of critical to an
476+ email address. This scenario requires three individual handlers where each
477+ handler is responsible for sending messages of a specific severity to a specific
478+ location.
478479
479480The standard library includes quite a few handler types (see
480481:ref: `useful-handlers `); the tutorials use mainly :class: `StreamHandler ` and
@@ -485,16 +486,17 @@ themselves with. The only handler methods that seem relevant for application
485486developers who are using the built-in handler objects (that is, not creating
486487custom handlers) are the following configuration methods:
487488
488- * The :meth: `Handler.setLevel ` method, just as in logger objects, specifies the
489+ * The :meth: `~ Handler.setLevel ` method, just as in logger objects, specifies the
489490 lowest severity that will be dispatched to the appropriate destination. Why
490491 are there two :func: `setLevel ` methods? The level set in the logger
491492 determines which severity of messages it will pass to its handlers. The level
492493 set in each handler determines which messages that handler will send on.
493494
494- * :func: `setFormatter ` selects a Formatter object for this handler to use.
495+ * :meth: `~Handler.setFormatter ` selects a Formatter object for this handler to
496+ use.
495497
496- * :func: ` addFilter ` and :func: ` removeFilter ` respectively configure and
497- deconfigure filter objects on handlers.
498+ * :meth: ` ~Handler. addFilter ` and :meth: ` ~Handler. removeFilter ` respectively
499+ configure and deconfigure filter objects on handlers.
498500
499501Application code should not directly instantiate and use instances of
500502:class: `Handler `. Instead, the :class: `Handler ` class is a base class that
@@ -948,16 +950,16 @@ Logged messages are formatted for presentation through instances of the
948950use with the % operator and a dictionary.
949951
950952For formatting multiple messages in a batch, instances of
951- :class: `BufferingFormatter ` can be used. In addition to the format string (which
952- is applied to each message in the batch), there is provision for header and
953- trailer format strings.
953+ :class: `~handlers. BufferingFormatter ` can be used. In addition to the format
954+ string (which is applied to each message in the batch), there is provision for
955+ header and trailer format strings.
954956
955957When filtering based on logger level and/or handler level is not enough,
956958instances of :class: `Filter ` can be added to both :class: `Logger ` and
957- :class: `Handler ` instances (through their :meth: `addFilter ` method). Before
958- deciding to process a message further, both loggers and handlers consult all
959- their filters for permission. If any filter returns a false value, the message
960- is not processed further.
959+ :class: `Handler ` instances (through their :meth: `~Handler. addFilter ` method).
960+ Before deciding to process a message further, both loggers and handlers consult
961+ all their filters for permission. If any filter returns a false value, the
962+ message is not processed further.
961963
962964The basic :class: `Filter ` functionality allows filtering by specific logger
963965name. If this feature is used, messages sent to the named logger and its
@@ -975,12 +977,14 @@ in production. This is so that errors which occur while handling logging events
975977cause the application using logging to terminate prematurely.
976978
977979:class: `SystemExit ` and :class: `KeyboardInterrupt ` exceptions are never
978- swallowed. Other exceptions which occur during the :meth: `emit ` method of a
979- :class: `Handler ` subclass are passed to its :meth: `handleError ` method.
980+ swallowed. Other exceptions which occur during the :meth: `~Handler.emit ` method
981+ of a :class: `Handler ` subclass are passed to its :meth: `~Handler.handleError `
982+ method.
980983
981- The default implementation of :meth: `handleError ` in :class: `Handler ` checks
982- to see if a module-level variable, :data: `raiseExceptions `, is set. If set, a
983- traceback is printed to :data: `sys.stderr `. If not set, the exception is swallowed.
984+ The default implementation of :meth: `~Handler.handleError ` in :class: `Handler `
985+ checks to see if a module-level variable, :data: `raiseExceptions `, is set. If
986+ set, a traceback is printed to :data: `sys.stderr `. If not set, the exception is
987+ swallowed.
984988
985989.. note :: The default value of :data:`raiseExceptions` is ``True``. This is
986990 because during development, you typically want to be notified of any
@@ -997,11 +1001,11 @@ Using arbitrary objects as messages
9971001In the preceding sections and examples, it has been assumed that the message
9981002passed when logging the event is a string. However, this is not the only
9991003possibility. You can pass an arbitrary object as a message, and its
1000- :meth: `__str__ ` method will be called when the logging system needs to convert
1001- it to a string representation. In fact, if you want to, you can avoid
1004+ :meth: `~object. __str__ ` method will be called when the logging system needs to
1005+ convert it to a string representation. In fact, if you want to, you can avoid
10021006computing a string representation altogether - for example, the
1003- :class: `SocketHandler ` emits an event by pickling it and sending it over the
1004- wire.
1007+ :class: `~handlers. SocketHandler ` emits an event by pickling it and sending it
1008+ over the wire.
10051009
10061010
10071011Optimization
@@ -1010,9 +1014,10 @@ Optimization
10101014Formatting of message arguments is deferred until it cannot be avoided.
10111015However, computing the arguments passed to the logging method can also be
10121016expensive, and you may want to avoid doing it if the logger will just throw
1013- away your event. To decide what to do, you can call the :meth: `isEnabledFor `
1014- method which takes a level argument and returns true if the event would be
1015- created by the Logger for that level of call. You can write code like this::
1017+ away your event. To decide what to do, you can call the
1018+ :meth: `~Logger.isEnabledFor ` method which takes a level argument and returns
1019+ true if the event would be created by the Logger for that level of call.
1020+ You can write code like this::
10161021
10171022 if logger.isEnabledFor(logging.DEBUG):
10181023 logger.debug('Message with %s, %s', expensive_func1(),
0 commit comments