IMP
2.1.1
The Integrative Modeling Platform
IMP Mainpage
All IMP Modules
Related Pages
Modules
Namespaces
Classes
Files
Examples
Indexes
File List
File Members
base/log.h
Go to the documentation of this file.
1
/**
2
* \file IMP/base/log.h
3
* \brief Logging and error reporting support.
4
*
5
* Copyright 2007-2013 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPBASE_LOG_H
10
#define IMPBASE_LOG_H
11
12
#include <IMP/base/base_config.h>
13
#include "
enums.h
"
14
#include "
WarningContext.h
"
15
#include "internal/static.h"
16
#include <iostream>
17
#include <cstdlib>
18
#include <string>
19
#include <sstream>
20
#if IMP_BASE_HAS_LOG4CXX
21
#include <log4cxx/logger.h>
22
#endif
23
24
IMPBASE_BEGIN_NAMESPACE
25
26
/** \name Logging
27
\anchor log
28
\imp provides tools for controlling the amount of log output produced
29
and directing it to the terminal or a file. Only log messages tagged
30
with a lower level than the current LogLevel are emitted. In addition
31
to a global log level (get_log_level(), set_log_level()), each
32
IMP::Object has an internal log level (IMP::Object::get_log_level(),
33
IMP::Object::set_log_level()) which is used when executing code on
34
that object.
35
36
Logging is provided by IMP/base/log.h.
37
38
People implementing IMP::Object classes should also see IMP_OBJECT_LOG()
39
and IMP::SetLogState.
40
41
All logging is disabled when \imp is built using \c build='fast'.
42
@{
43
*/
44
#ifndef IMP_DOXYGEN
45
#if !IMP_BASE_HAS_LOG4CXX
46
//! Push a new log context onto the stack
47
/** A log context is, eg, a function name.
48
*/
49
IMPBASEEXPORT
void
push_log_context(
const
char
*functionname,
50
const
void
*
object
);
51
52
//! pop the top log context
53
IMPBASEEXPORT
void
pop_log_context();
54
55
//! Write a string to the log
56
IMPBASEEXPORT
void
add_to_log
(std::string to_write);
57
#endif
58
#endif
59
60
//! Write a string to the log, for python
61
IMPBASEEXPORT
void
add_to_log
(
LogLevel
level, std::string to_write);
62
63
//! Set the current global log level
64
/** Set the current global log level
65
66
@note may be overriden by set_log_level of specific objects that inherit
67
from IMP::base::Object
68
@note this global method should not, currently, be used directly during
69
kernel::Model::evaluate() calls.
70
71
\see get_log_level()
72
\see IMP::base::Object::set_log_level()
73
*/
74
IMPBASEEXPORT
void
set_log_level
(
LogLevel
l);
75
76
//! Set whether log messages are tagged with the current log time
77
IMPBASEEXPORT
void
set_log_timer
(
bool
tb);
78
79
//! Reset the log timer
80
IMPBASEEXPORT
void
reset_log_timer
();
81
82
//! Get the currently active global log level
83
/** Get the currently active global log level
84
85
@note This may not always match the value passed to set_log_level()
86
as objects can temporarily override the global level
87
while they are evaluating.
88
89
\see set_log_level()
90
\see IMP::base::Object::set_log_level()
91
92
*/
93
inline
LogLevel
get_log_level
() {
return
LogLevel
(internal::log_level); }
94
95
#if IMP_BASE_HAS_LOG4CXX
96
inline
log4cxx::LoggerPtr get_logger() {
97
static
log4cxx::LoggerPtr ret = log4cxx::Logger::getLogger(
"IMP"
);
98
return
ret;
99
}
100
#else
101
#if !defined(IMP_DOXYGEN) && !defined(SWIG)
102
inline
bool
get_is_log_output(
LogLevel
l) {
return
l <=
get_log_level
(); }
103
#endif
104
#endif
105
106
/** @} */
107
108
/** \name Create a progress bar in the terminal
109
110
@{
111
*/
112
/** Set up the progress bar with the passed description.
113
114
See IMP_PROGRESS_DISPLAY().
115
*/
116
IMPBASEEXPORT
void
set_progress_display
(std::string description,
117
unsigned
int
steps);
118
/** Set the current progress. When it equals the number of steps,
119
the bar is done.*/
120
IMPBASEEXPORT
void
add_to_progress_display
(
unsigned
int
step = 1);
121
122
/** @} */
123
124
IMPBASE_END_NAMESPACE
125
126
#endif
/* IMPBASE_LOG_H */
IMP::base::set_log_timer
void set_log_timer(bool tb)
Set whether log messages are tagged with the current log time.
IMP::base::LogLevel
LogLevel
The log levels supported by IMP.
Definition:
base/enums.h:18
IMP::base::reset_log_timer
void reset_log_timer()
Reset the log timer.
IMP::base::set_log_level
void set_log_level(LogLevel l)
Set the current global log level.
IMP::base::set_progress_display
void set_progress_display(std::string description, unsigned int steps)
IMP::base::get_log_level
LogLevel get_log_level()
Get the currently active global log level.
Definition:
base/log.h:93
IMP::base::add_to_log
void add_to_log(LogLevel level, std::string to_write)
Write a string to the log, for python.
enums.h
Basic types used by IMP.
IMP::base::add_to_progress_display
void add_to_progress_display(unsigned int step=1)
WarningContext.h
Logging and error reporting support.