Package schrodinger :: Package application :: Package matsci :: Module textlogger
[hide private]
[frames] | no frames]

Module textlogger

Classes [hide private]
  GetLogger
Set up a textwrapped log file.
Functions [hide private]
 
log(logger, msg, level=logging.INFO)
Log a message if the logger is defined, else print it
 
log_namespace(namespace, logger, msgwidth=None, header='Command line options:')
Log the value of all properties on a object, such as logging all the parameters of an argparse.Namespace object.
(logging.Logger, str)
create_logger(logfilename=None, extension='-driver.log', related_filename=None, verbose=False, width=80)
Create a logger that can be used for logging information to a file
str
get_param_string(identifier, value, msgwidth)
Return a formatted line with identifier on the left and value right-justified.
Variables [hide private]
  __doc__ = ...
  _version = '$Revision 0.0 $'
Function Details [hide private]

log(logger, msg, level=logging.INFO)

 

Log a message if the logger is defined, else print it

Parameters:
  • logger (logging.Logger) - The logger object or None if no logger is defined
  • msg (str) - The message to log
  • level (int) - The log level to use when logging. These are constants from the Python logging module. The default is INFO.

log_namespace(namespace, logger, msgwidth=None, header='Command line options:')

 

Log the value of all properties on a object, such as logging all the parameters of an argparse.Namespace object.

Parameters:
  • namespace (object) - The object whose properties should be logged. In typical use, this is an argparse.Namespace object. All the values in the __dict__ of this object will be logged. Note that __dict__ does not contain the double-underscore class methods.
  • logger (logging.Logger) - The logger to log with
  • msgwidth (int) - The width of the log messages. Taken from the logger if not supplied
  • header (str or None) - If not None, this line will be printed above the logged properties

create_logger(logfilename=None, extension='-driver.log', related_filename=None, verbose=False, width=80)

 

Create a logger that can be used for logging information to a file

If running under job control, the log file this logger writes to will be added to the backend as a Log File.

Parameters:
  • logfilename (str) - The name of the log file the logger should write to. If not supplied, the name will be based off the Job name if running under job control or based off of the basename of a related_file if not. As a last resort, the logfile name will use 'logfile' as the base name.
  • extension (str) - The extension to add to the file name if logfilename is not supplied.
  • related_filanem - The basename of this filename will be used as the base of the log file name IF logfilename is not supplied directly and we are not running under job control.
  • verbose (bool) - Whether to enable verbose logging
  • width (int) - Text width of the file
  • related_filename (str)
Returns: (logging.Logger, str)
The logger and the name of the file it logs to.

get_param_string(identifier, value, msgwidth)

 

Return a formatted line with identifier on the left and value right-justified. A line of '...' will consume the intervening space.

Parameters:
  • identifier (str) - description of the value
  • value (any) - the value of the descriptor
  • msgwidth (int) - the length of the msg
Returns: str
msg, formatted msg

Variables Details [hide private]

__doc__

Value:
"""
Class to set up a nicely formatted logger

Copyright Schrodinger, LLC.  All rights reserved."""