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

Skip to content

Commit bcefe69

Browse files
committed
Add logging changes
1 parent 6fe93cd commit bcefe69

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

Doc/whatsnew/whatsnew24.tex

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,33 @@ \section{New, Improved, and Deprecated Modules}
782782
another, \function{tee()} is ideal. Possible applications include
783783
bookmarking, windowing, or lookahead iterators.
784784

785+
\item A \function{basicConfig} function was added to the
786+
\module{logging} package to simplify log configuration. It defaults
787+
to logging to standard error, but a
788+
number of optional keyword arguments can be specified to
789+
log to a particular file, change the logging format, or set the
790+
logging level. For example:
791+
792+
\begin{verbatim}
793+
import logging
794+
logging.basicConfig(filename = '/var/log/application.log',
795+
level=0, # Log all messages, including debugging,
796+
format='%(levelname):%(process):%(thread):%(message)')
797+
\end{verbatim}
798+
799+
Another addition to \module{logging} is a
800+
\class{TimedRotatingFileHandler} class which rotates its log files at
801+
a timed interval. The module already had \class{RotatingFileHandler},
802+
which rotated logs once the file exceeded a certain size. Both
803+
classes derive from a new \class{BaseRotatingHandler} class that can
804+
be used to implement other rotating handlers.
805+
785806
\item The \module{operator} module gained two new functions,
786807
\function{attrgetter(\var{attr})} and \function{itemgetter(\var{index})}.
787808
Both functions return callables that take a single argument and return
788809
the corresponding attribute or item; these callables make excellent
789-
data extractors when used with \function{map()} or \function{sorted()}.
790-
For example:
810+
data extractors when used with \function{map()} or
811+
\function{sorted()}. For example:
791812

792813
\begin{verbatim}
793814
>>> L = [('c', 2), ('d', 1), ('a', 4), ('b', 3)]

0 commit comments

Comments
 (0)