diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2004-07-21 14:40:11 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2004-07-21 14:40:11 (GMT) |
commit | b4bf62f807af67a39c0ec8d835a368165857652f (patch) | |
tree | a6baafed6658e26d78c0a83ed7ec4878aef99259 | |
parent | 0ad20f18feb1d21a128fc86f046325d583d86fcd (diff) | |
download | cpython-b4bf62f807af67a39c0ec8d835a368165857652f.zip cpython-b4bf62f807af67a39c0ec8d835a368165857652f.tar.gz cpython-b4bf62f807af67a39c0ec8d835a368165857652f.tar.bz2 |
Added an extra example to the basic example section
-rw-r--r-- | Doc/lib/liblogging.tex | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Doc/lib/liblogging.tex b/Doc/lib/liblogging.tex index 5f0fee3..306d10d 100644 --- a/Doc/lib/liblogging.tex +++ b/Doc/lib/liblogging.tex @@ -470,6 +470,27 @@ to \function{basicConfig()} using the \var{stream} keyword argument. Note that if both \var{stream} and \var{filename} keyword arguments are passed, the \var{stream} argument is ignored. +Of course, you can put variable information in your output. To do this, +simply have the message be a format string and pass in additional arguments +containing the variable information, as in the following example: + +\begin{verbatim} +import logging + +logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(levelname)-8s %(message)s', + datefmt='%a, %d %b %Y %H:%M:%S', + filename='/temp/myapp.log', + filemode='w') +logging.error('Pack my box with %d dozen %s', 12, 'liquor jugs') +\end{verbatim} + +which would result in + +\begin{verbatim} +Wed, 21 Jul 2004 15:35:16 ERROR Pack my box with 12 dozen liquor jugs +\end{verbatim} + \subsection{Handler Objects} Handlers have the following attributes and methods. Note that |