IMP  2.3.1
The Integrative Modeling Platform
log.py
1 ## \example base/log.py
2 # Show various ways to use the log and control it.
3 
4 import IMP.base
5 
6 
7 class DummyObject(IMP.base.Object):
8 
9  def __init__(self):
10  IMP.base.Object.__init__(self, "DummyObject%1%")
11 
12  def add_log(self):
13  # these are done by the IMP_OBJECT_LOG macro in C++
14  state = IMP.base.SetLogState(self.get_log_level())
15  context = IMP.base.CreateLogContext(self.get_name() + "::add_log")
16  self.set_was_used(True)
17  IMP.base.add_to_log(IMP.base.VERBOSE,
18  "A verbose message in the object\n")
19 # we can set the log level for all of IMP
20 IMP.base.set_log_level(IMP.base.TERSE)
21 
22 # we can tell it to print the time each even occurs
24 
25 # we can create a log context
26 lc = IMP.base.CreateLogContext("my context")
27 
28 # we can print a message
29 IMP.base.add_to_log(IMP.base.TERSE, "This is my log message\n")
30 
31 o = DummyObject()
32 o.set_log_level(IMP.base.VERBOSE)
33 o.add_log()
void set_log_timer(bool tb)
Set whether log messages are tagged with the current log time.
void set_log_level(LogLevel l)
Set the current global log level.
Low level functionality (logging, error handling, profiling, command line flags etc) that is used by ...
A class to change and restore log state.
Definition: SetLogState.h:31
void add_to_log(LogLevel level, std::string to_write)
Write a string to the log, for Python.
Common base class for heavy weight IMP objects.
Definition: Object.h:106
Create a new log context.