IMP
2.0.0
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
base/log.py
Show various ways to use the log and control it.
1
## \example base/log.py
2
## Show various ways to use the log and control it.
3
4
import
IMP.base
5
6
class
DummyObject(
IMP.base.Object
):
7
def
__init__(self):
8
IMP.base.Object.__init__(self,
"DummyObject%1%"
)
9
def
add_log(self):
10
# these are done by the IMP_OBJECT_LOG macro in C++
11
state=
IMP.base.SetLogState
(self.get_log_level())
12
context=
IMP.base.CreateLogContext
(self.get_name()+
"::add_log"
)
13
self.set_was_used(
True
)
14
IMP.base.add_to_log
(IMP.base.VERBOSE,
15
"A verbose message in the object\n"
)
16
# we can set the log level for all of IMP
17
IMP.base.set_log_level
(IMP.base.TERSE)
18
19
# we can tell it to print the time each even occurs
20
IMP.base.set_log_timer
(
True
)
21
22
# we can create a log context
23
lc=
IMP.base.CreateLogContext
(
"my context"
)
24
25
# we can print a message
26
IMP.base.add_to_log
(IMP.base.TERSE,
"This is my log message\n"
)
27
28
o= DummyObject()
29
o.set_log_level(IMP.base.VERBOSE)
30
o.add_log()