common.log package


common.log.Comment module

Persistent Comment class

class common.log.Comment.Comment(**kwargs)

Bases: common.database.DBMain.DBObject

Class for storing comments related to a DBObject

Example, showing how to couple a comment to a RegriddedFrame

awe> from common.log.Comment import Comment awe> q = == ‘WFI’ awe> regrid = q[567] awe> c = Comment() awe> c.make(‘A comment text’, regrid) awe> c.commit()


This is the comment [None]


Date this object was created [None]


The object_id of the commented object [None]


The type of the commented object [None]


Check whether a comment already exists with the same content, that points to the same object

classmethod getCommentsObject(a_object)

get all the comments for the object

classmethod getCommentsObjectId(objectid)

get all the comments for the objectid

classmethod getCommentsUser()

return all comments from the current user

make(content, db_object)

set dependencies


The object identifier

The object identifier is an attribute shared by all persistent instances. It is the prime key, by which object identity is established


The username [None]

common.log.Error module

Implements ‘Error’, a class that sends the error message to the log provided by

Errors can be raised as any other exception:

>>> raise Error, 'my error message' or
>>> raise Error('my error message')
exception common.log.Error.Error(message)

Bases: Exception

If an Error is raised, it will be written to log.

common.log.Log module


class common.log.Log.Log(log_dir='.', prefix='')

Bases: object

This class provides general logging facilities.

__init__(log_dir=’.’, prefix=’‘) – Construct a Log object. write(text) – Write a message to the standard or error logfile.

The class can be instantiated with two optional parameters. The first parameter is the name of the directory where the logfiles will be written. It defaults to the current directory. The second paramater is a prefix that will be attached to the logfilenames. The prefix defaults to the empty string.


return the filepath of the log file


Write a text to the Log object.

text – Message to be written to the Log.

If “text” contains the string “ERROR” it is written to the error logfile, otherwise it is written to the standard logfile. Only when a Log object is being written to, the standard or error logfile is created.

common.log.Mail module

common.log.Mail.mail(address, subject, text, address_from=None)

Send a mail to address - can be a list of addresses with subject and text

common.log.Message module


common.log.Message.Message(text, loglevel=1)

Log the given text uring Env[‘log’] (default) or use the python logging facility

common.log.PythonLogging module

python logging facility initialization

class common.log.PythonLogging.StoreLogHandler(*arg, **kwargs)

Bases: logging.Handler


log the record


flush is not needed, but must be defined

class common.log.PythonLogging.ThreadedLogHandler(level=0)

Bases: logging.Handler

python logging handler forwarding all logging to the ThreadedLog used in web services


log the record


the ThreadedLog class does not support flushing so pass for the moment


return the default logging formatter


return the log level


initialize the python logging facility

common.log.PythonLogging.init_python_logging_console(loglevel=20, replace=True)

initialize a console log handler for the python logging facility, if replace is True then a previous console handler will be removed

common.log.PythonLogging.init_python_logging_logfile(filename, loglevel=20, delay=True, replace=True)

initialize a log file handler for the python logging facility delay=True will prevent creating empty log files

common.log.PythonLogging.init_python_logging_store(loglevel=30, replace=True)

this log handler can be used to collect all WARNINGS and more severe messages


initialize the the python logging so it uses the ThreadedLog class for writing log

common.log.ThreadedLog module

ThreadedLog module

class common.log.ThreadedLog.ThreadedLog

Bases: object

thread safe logging using profiles profiles provide an unique id for identifying the log writer to use in multithreaded environments like webservers

default_filename = 'ThreadedLog.log'
dummy = 1

dummy mode, do not create file, do not write anything is used for unit tests

generate_filename(prefix, log_per_user, log_per_day)

generate the filename


get the filename of the log file for the current thread


return the filepath of the log file same as get_filename, that also includes the full path

level = 0

this is the base level, any write call with a higher level is not logged the base level should be set by the application

start(log_dir='.', prefix='', filename=None, log_per_user=False, log_per_day=False)

start logging for this thread in file with filename: - the given filename - or generate the filename using the log_per_X switches (when set) - or generate the filename starting with prefix and current datetime


start a dummy log for this thread


stop the log file for the current thread

to_file = True

write all the logging to a file True -> yes False -> no (in case of for example the cluster) print to screen

to_screen = False

print all logging to the screen

write(text, level=0, date=True)

write a log line for the current thread


get the class name from a class


get the class name from an object

Module contents