Known subclasses: twisted.python.logfile.DailyLogFile, twisted.python.logfile.LogFile

The base class for a log file that can be rotated.

Method __init__ Create a log file.
Class Method fromFullPath Construct a log file from a full file path.
Method shouldRotate Override with a method to that returns true if the log should be rotated.
Method __getstate__ Undocumented
Method __setstate__ Undocumented
Method write Write some data to the file.
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.
Method _openFile Open the log file.
def __init__(self, name, directory, defaultMode=None): (source)

Create a log file.

Parametersnamename of the file
directorydirectory holding the file
defaultModepermissions used to create the file. Default to current permissions of the file if the file exists.
@classmethod
def fromFullPath(cls, filename, *args, **kwargs): (source)

Construct a log file from a full file path.

def shouldRotate(self): (source)

Override with a method to that returns true if the log should be rotated.

def _openFile(self): (source)

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 https://twistedmatrix.com/trac/ticket/989)
  • logging plain ASCII messages is fine with any non-binary mode.

See https://twistedmatrix.com/pipermail/twisted-python/2013-October/027651.html for more information.

def __getstate__(self): (source)
def __setstate__(self, state): (source)
Undocumented
def write(self, data): (source)

Write some data to the file.

def flush(self): (source)

Flush the file.

def close(self): (source)

Close the file.

The file cannot be used once it has been closed.

def reopen(self): (source)

Reopen the log file. This is mainly useful if you use an external log rotation tool, which moves under your feet.

Note that on Windows you probably need a specific API to rename the file, as it's not supported to simply use os.rename, for example.

def getCurrentLog(self): (source)

Return a LogReader for the current log file.

API Documentation for Twisted, generated by pydoctor at 2017-06-11 10:59:01.