9#ifndef IMPKERNEL_CREATE_LOG_CONTEXT_H
10#define IMPKERNEL_CREATE_LOG_CONTEXT_H
12#include <IMP/kernel_config.h>
16#if IMP_KERNEL_HAS_LOG4CXX
17#include <log4cxx/ndc.h>
18#include <boost/scoped_ptr.hpp>
21IMPKERNEL_BEGIN_NAMESPACE
47class CreateLogContext :
public RAII {
48#if IMP_KERNEL_HAS_LOG4CXX
50 boost::scoped_ptr<log4cxx::NDC> ndc1_;
53 CreateLogContext(
const char* fname,
const Object*
object)
54 : ndc0_(object->get_quoted_name_c_string()),
55 ndc1_(
new log4cxx::NDC(fname)) {}
56 CreateLogContext(
const char* fname) : ndc0_(fname) {}
57 CreateLogContext(std::string name) : ndc0_(name) {}
64 CreateLogContext(std::string fname,
const Object*
object =
nullptr)
65 : pushed_(
true), name_(fname) {
67 push_log_context(name_.c_str(),
object);
70 (
const char* fname,
const Object*
object =
nullptr), ,
71 { push_log_context(fname,
object);
73 {
if (pushed_) pop_log_context();
74 pushed_ =
false; }, );
80IMPKERNEL_END_NAMESPACE
A shared base class to help in debugging and things.
Common base class for heavy weight IMP objects.
Logging and error reporting support.
Macros to aid in writing RAII-style classes.
#define IMP_RAII(Name, args, Initialize, Set, Reset, Show)
Declares RAII-style methods in a class.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
#define IMP_UNUSED(variable)