Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1ff01fb0
Commit
1ff01fb0
authored
Jan 14, 2007
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added documentation for WatchedFileHandler (based on SF patch #1598415)
parent
73306b07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
2 deletions
+38
-2
Doc/lib/liblogging.tex
Doc/lib/liblogging.tex
+38
-2
No files found.
Doc/lib/liblogging.tex
View file @
1ff01fb0
...
...
@@ -989,10 +989,11 @@ The \class{FileHandler} class, located in the core \module{logging}
package, sends logging output to a disk file. It inherits the output
functionality from
\class
{
StreamHandler
}
.
\begin{classdesc}
{
FileHandler
}{
filename
\optional
{
, mode
}}
\begin{classdesc}
{
FileHandler
}{
filename
\optional
{
, mode
\optional
{
, encoding
}
}}
Returns a new instance of the
\class
{
FileHandler
}
class. The specified
file is opened and used as the stream for logging. If
\var
{
mode
}
is
not specified,
\constant
{
'a'
}
is used. By default, the file grows
not specified,
\constant
{
'a'
}
is used. If
\var
{
encoding
}
is not
\var
{
None
}
,
it is used to open the file with that encoding. By default, the file grows
indefinitely.
\end{classdesc}
...
...
@@ -1004,6 +1005,41 @@ Closes the file.
Outputs the record to the file.
\end{methoddesc}
\subsubsection
{
WatchedFileHandler
}
\versionadded
{
2.6
}
The
\class
{
WatchedFileHandler
}
class, located in the
\module
{
logging.handlers
}
module, is a
\class
{
FileHandler
}
which watches the file it is logging to.
If the file changes, it is closed and reopened using the file name.
A file change can happen because of usage of programs such as
\var
{
newsyslog
}
and
\var
{
logrotate
}
which perform log file rotation. This handler, intended
for use under Unix/Linux, watches the file to see if it has changed since the
last emit. (A file is deemed to have changed if its device or inode have
changed.) If the file has changed, the old file stream is closed, and the file
opened to get a new stream.
This handler is not appropriate for use under Windows, because under Windows
open log files cannot be moved or renamed - logging opens the files with
exclusive locks - and so there is no need for such a handler. Furthermore,
\var
{
ST
_
INO
}
is not supported under Windows;
\function
{
stat()
}
always returns
zero for this value.
\begin{classdesc}
{
WatchedFileHandler
}{
filename
\optional
{
,mode
\optional
{
,
encoding
}}}
Returns a new instance of the
\class
{
WatchedFileHandler
}
class. The specified
file is opened and used as the stream for logging. If
\var
{
mode
}
is
not specified,
\constant
{
'a'
}
is used. If
\var
{
encoding
}
is not
\var
{
None
}
,
it is used to open the file with that encoding. By default, the file grows
indefinitely.
\end{classdesc}
\begin{methoddesc}
{
emit
}{
record
}
Outputs the record to the file, but first checks to see if the file has
changed. If it has, the existing stream is flushed and closed and the file
opened again, before outputting the record to the file.
\end{methoddesc}
\subsubsection
{
RotatingFileHandler
}
The
\class
{
RotatingFileHandler
}
class, located in the
\module
{
logging.handlers
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment