Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82a6384

Browse files
authored
Indented Handler sections for improved clarity. (#1554)
Indented parts of the Handler class documentation for improved presentation, analogous to a recent similar change for the Logger class.
1 parent 31b3901 commit 82a6384

1 file changed

Lines changed: 67 additions & 66 deletions

File tree

Doc/library/logging.rst

Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ is the module's name in the Python package namespace.
7171

7272
.. attribute:: Logger.propagate
7373

74-
If this evaluates to true, events logged to this logger will be passed to the
75-
handlers of higher level (ancestor) loggers, in addition to any handlers
76-
attached to this logger. Messages are passed directly to the ancestor
77-
loggers' handlers - neither the level nor filters of the ancestor loggers in
78-
question are considered.
74+
If this attribute evaluates to true, events logged to this logger will be
75+
passed to the handlers of higher level (ancestor) loggers, in addition to
76+
any handlers attached to this logger. Messages are passed directly to the
77+
ancestor loggers' handlers - neither the level nor filters of the ancestor
78+
loggers in question are considered.
7979

8080
If this evaluates to false, logging messages are not passed to the handlers
8181
of ancestor loggers.
@@ -362,113 +362,114 @@ is never instantiated directly; this class acts as a base for more useful
362362
subclasses. However, the :meth:`__init__` method in subclasses needs to call
363363
:meth:`Handler.__init__`.
364364

365+
.. class:: Handler
365366

366-
.. method:: Handler.__init__(level=NOTSET)
367+
.. method:: Handler.__init__(level=NOTSET)
367368

368-
Initializes the :class:`Handler` instance by setting its level, setting the list
369-
of filters to the empty list and creating a lock (using :meth:`createLock`) for
370-
serializing access to an I/O mechanism.
369+
Initializes the :class:`Handler` instance by setting its level, setting the list
370+
of filters to the empty list and creating a lock (using :meth:`createLock`) for
371+
serializing access to an I/O mechanism.
371372

372373

373-
.. method:: Handler.createLock()
374+
.. method:: Handler.createLock()
374375

375-
Initializes a thread lock which can be used to serialize access to underlying
376-
I/O functionality which may not be threadsafe.
376+
Initializes a thread lock which can be used to serialize access to underlying
377+
I/O functionality which may not be threadsafe.
377378

378379

379-
.. method:: Handler.acquire()
380+
.. method:: Handler.acquire()
380381

381-
Acquires the thread lock created with :meth:`createLock`.
382+
Acquires the thread lock created with :meth:`createLock`.
382383

383384

384-
.. method:: Handler.release()
385+
.. method:: Handler.release()
385386

386-
Releases the thread lock acquired with :meth:`acquire`.
387+
Releases the thread lock acquired with :meth:`acquire`.
387388

388389

389-
.. method:: Handler.setLevel(lvl)
390+
.. method:: Handler.setLevel(lvl)
390391

391-
Sets the threshold for this handler to *lvl*. Logging messages which are less
392-
severe than *lvl* will be ignored. When a handler is created, the level is set
393-
to :const:`NOTSET` (which causes all messages to be processed).
392+
Sets the threshold for this handler to *lvl*. Logging messages which are less
393+
severe than *lvl* will be ignored. When a handler is created, the level is set
394+
to :const:`NOTSET` (which causes all messages to be processed).
394395

395-
See :ref:`levels` for a list of levels.
396+
See :ref:`levels` for a list of levels.
396397

397-
.. versionchanged:: 3.2
398-
The *lvl* parameter now accepts a string representation of the
399-
level such as 'INFO' as an alternative to the integer constants
400-
such as :const:`INFO`.
398+
.. versionchanged:: 3.2
399+
The *lvl* parameter now accepts a string representation of the
400+
level such as 'INFO' as an alternative to the integer constants
401+
such as :const:`INFO`.
401402

402403

403-
.. method:: Handler.setFormatter(form)
404+
.. method:: Handler.setFormatter(form)
404405

405-
Sets the :class:`Formatter` for this handler to *form*.
406+
Sets the :class:`Formatter` for this handler to *form*.
406407

407408

408-
.. method:: Handler.addFilter(filt)
409+
.. method:: Handler.addFilter(filt)
409410

410-
Adds the specified filter *filt* to this handler.
411+
Adds the specified filter *filt* to this handler.
411412

412413

413-
.. method:: Handler.removeFilter(filt)
414+
.. method:: Handler.removeFilter(filt)
414415

415-
Removes the specified filter *filt* from this handler.
416+
Removes the specified filter *filt* from this handler.
416417

417418

418-
.. method:: Handler.filter(record)
419+
.. method:: Handler.filter(record)
419420

420-
Applies this handler's filters to the record and returns a true value if the
421-
record is to be processed. The filters are consulted in turn, until one of
422-
them returns a false value. If none of them return a false value, the record
423-
will be emitted. If one returns a false value, the handler will not emit the
424-
record.
421+
Applies this handler's filters to the record and returns a true value if the
422+
record is to be processed. The filters are consulted in turn, until one of
423+
them returns a false value. If none of them return a false value, the record
424+
will be emitted. If one returns a false value, the handler will not emit the
425+
record.
425426

426427

427-
.. method:: Handler.flush()
428+
.. method:: Handler.flush()
428429

429-
Ensure all logging output has been flushed. This version does nothing and is
430-
intended to be implemented by subclasses.
430+
Ensure all logging output has been flushed. This version does nothing and is
431+
intended to be implemented by subclasses.
431432

432433

433-
.. method:: Handler.close()
434+
.. method:: Handler.close()
434435

435-
Tidy up any resources used by the handler. This version does no output but
436-
removes the handler from an internal list of handlers which is closed when
437-
:func:`shutdown` is called. Subclasses should ensure that this gets called
438-
from overridden :meth:`close` methods.
436+
Tidy up any resources used by the handler. This version does no output but
437+
removes the handler from an internal list of handlers which is closed when
438+
:func:`shutdown` is called. Subclasses should ensure that this gets called
439+
from overridden :meth:`close` methods.
439440

440441

441-
.. method:: Handler.handle(record)
442+
.. method:: Handler.handle(record)
442443

443-
Conditionally emits the specified logging record, depending on filters which may
444-
have been added to the handler. Wraps the actual emission of the record with
445-
acquisition/release of the I/O thread lock.
444+
Conditionally emits the specified logging record, depending on filters which may
445+
have been added to the handler. Wraps the actual emission of the record with
446+
acquisition/release of the I/O thread lock.
446447

447448

448-
.. method:: Handler.handleError(record)
449+
.. method:: Handler.handleError(record)
449450

450-
This method should be called from handlers when an exception is encountered
451-
during an :meth:`emit` call. If the module-level attribute
452-
``raiseExceptions`` is ``False``, exceptions get silently ignored. This is
453-
what is mostly wanted for a logging system - most users will not care about
454-
errors in the logging system, they are more interested in application
455-
errors. You could, however, replace this with a custom handler if you wish.
456-
The specified record is the one which was being processed when the exception
457-
occurred. (The default value of ``raiseExceptions`` is ``True``, as that is
458-
more useful during development).
451+
This method should be called from handlers when an exception is encountered
452+
during an :meth:`emit` call. If the module-level attribute
453+
``raiseExceptions`` is ``False``, exceptions get silently ignored. This is
454+
what is mostly wanted for a logging system - most users will not care about
455+
errors in the logging system, they are more interested in application
456+
errors. You could, however, replace this with a custom handler if you wish.
457+
The specified record is the one which was being processed when the exception
458+
occurred. (The default value of ``raiseExceptions`` is ``True``, as that is
459+
more useful during development).
459460

460461

461-
.. method:: Handler.format(record)
462+
.. method:: Handler.format(record)
462463

463-
Do formatting for a record - if a formatter is set, use it. Otherwise, use the
464-
default formatter for the module.
464+
Do formatting for a record - if a formatter is set, use it. Otherwise, use the
465+
default formatter for the module.
465466

466467

467-
.. method:: Handler.emit(record)
468+
.. method:: Handler.emit(record)
468469

469-
Do whatever it takes to actually log the specified logging record. This version
470-
is intended to be implemented by subclasses and so raises a
471-
:exc:`NotImplementedError`.
470+
Do whatever it takes to actually log the specified logging record. This version
471+
is intended to be implemented by subclasses and so raises a
472+
:exc:`NotImplementedError`.
472473

473474
For a list of handlers included as standard, see :mod:`logging.handlers`.
474475

0 commit comments

Comments
 (0)