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

Skip to content

Commit b4bf62f

Browse files
committed
Added an extra example to the basic example section
1 parent 0ad20f1 commit b4bf62f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Doc/lib/liblogging.tex

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,27 @@ \subsection{Basic example \label{minimal-example}}
470470
that if both \var{stream} and \var{filename} keyword arguments are passed,
471471
the \var{stream} argument is ignored.
472472

473+
Of course, you can put variable information in your output. To do this,
474+
simply have the message be a format string and pass in additional arguments
475+
containing the variable information, as in the following example:
476+
477+
\begin{verbatim}
478+
import logging
479+
480+
logging.basicConfig(level=logging.DEBUG,
481+
format='%(asctime)s %(levelname)-8s %(message)s',
482+
datefmt='%a, %d %b %Y %H:%M:%S',
483+
filename='/temp/myapp.log',
484+
filemode='w')
485+
logging.error('Pack my box with %d dozen %s', 12, 'liquor jugs')
486+
\end{verbatim}
487+
488+
which would result in
489+
490+
\begin{verbatim}
491+
Wed, 21 Jul 2004 15:35:16 ERROR Pack my box with 12 dozen liquor jugs
492+
\end{verbatim}
493+
473494
\subsection{Handler Objects}
474495

475496
Handlers have the following attributes and methods. Note that

0 commit comments

Comments
 (0)