twisted.python.logfile.LogFile(BaseLogFile) class documentationtwisted.python.logfile
View Source
(View In Hierarchy)
A log file that can be rotated.
A rotateLength of None disables automatic log rotation.
| Method | __init__ | Create a log file rotating on length. |
| Method | shouldRotate | Rotate when the log file size is larger than rotateLength. |
| Method | getLog | Given an integer, return a LogReader for an old log file. |
| Method | write | Write some data to the file. |
| Method | rotate | Rotate the file and create a new one. |
| Method | listLogs | Return sorted list of integers - the old logs' identifiers. |
| Method | __getstate__ | Undocumented |
| Method | _openFile | Open the log file. |
Inherited from BaseLogFile:
| Class Method | fromFullPath | Construct a log file from a full file path. |
| Method | __setstate__ | Undocumented |
| Method | flush | Flush the file. |
| Method | close | Close the file. |
| Method | reopen | Reopen the log file. This is mainly useful if you use an external log rotation tool, which moves under your feet. |
| Method | getCurrentLog | Return a LogReader for the current log file. |
Create a log file rotating on length.
| Parameters | name | file name. (type: str) |
| directory | path of the log file. (type: str) | |
| rotateLength | size of the log file where it rotates. Default to 1M. (type: int) | |
| defaultMode | mode used to create the file. (type: int) | |
| maxRotatedFiles | if not None, max number of log files the class creates. Warning: it removes
all log files above this number. (type: int) |
Open the log file.
We don't open files in binary mode since:
* an encoding would have to be chosen and that would have to be
configurable
* Twisted doesn't actually support logging non-ASCII messages
(see U{https://twistedmatrix.com/trac/ticket/989})
* logging plain ASCII messages is fine with any non-binary mode.
See
U{https://twistedmatrix.com/pipermail/twisted-python/2013-October/027651.html}
for more information.
Write some data to the file.
Rotate the file and create a new one.
If it's not possible to open new logfile, this will fail silently, and continue logging to old logfile.