Package winappdbg :: Module textio :: Class Logger
[hide private]
[frames] | no frames]

Class Logger

source code


Logs text to standard output and/or a text file.

Instance Methods [hide private]
 
__init__(self, logfile=None, verbose=True)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__logfile_error(self, e)
Shows an error message to standard error if the log file can't be written to.
source code
 
__do_log(self, text)
Writes the given text verbatim into the log file (if any) and/or standard input (if the verbose flag is turned on).
source code
 
log_text(self, text)
Log lines of text, inserting a timestamp.
source code
 
log_event(self, event, text=None)
Log lines of text associated with a debug event.
source code
 
log_exc(self)
Log lines of text associated with the last Python exception.
source code
bool
is_enabled(self)
Determines if the logger will actually print anything when the log_* methods are called.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
file fd
File object where log messages are printed to.
str or None logfile
Append messages to this text file.
bool verbose
True to print messages to standard output.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, logfile=None, verbose=True)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • logfile (str or None) - Append messages to this text file.
  • verbose (bool) - True to print messages to standard output.
Overrides: object.__init__

__logfile_error(self, e)

source code 

Shows an error message to standard error if the log file can't be written to.

Used internally.

Parameters:
  • e (Exception) - Exception raised when trying to write to the log file.

__do_log(self, text)

source code 

Writes the given text verbatim into the log file (if any) and/or standard input (if the verbose flag is turned on).

Used internally.

Parameters:
  • text (str) - Text to print.

log_text(self, text)

source code 

Log lines of text, inserting a timestamp.

Parameters:
  • text (str) - Text to log.

log_event(self, event, text=None)

source code 

Log lines of text associated with a debug event.

Parameters:
  • event (Event) - Event object.
  • text (str) - (Optional) Text to log. If no text is provided the default is to show a description of the event itself.

is_enabled(self)

source code 

Determines if the logger will actually print anything when the log_* methods are called.

This may save some processing if the log text requires a lengthy calculation to prepare. If no log file is set and stdout logging is disabled, there's no point in preparing a log text that won't be shown to anyone.

Returns: bool
True if a log file was set and/or standard output logging is enabled, or False otherwise.

Instance Variable Details [hide private]

fd

File object where log messages are printed to. None if no log file is used.
Type:
file