RDLog.h
Go to the documentation of this file.
//
// Copyright (C) 2005-2008 Greg Landrum and Rational Discovery LLC
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#ifndef _RDLOG_H_29JUNE2005_
#define _RDLOG_H_29JUNE2005_
#if 1
#include <boost/iostreams/tee.hpp>
#include <boost/iostreams/stream.hpp>
#include <iostream>
namespace boost {
namespace logging {
typedef boost::iostreams::tee_device<std::ostream, std::ostream> RDTee;
typedef boost::iostreams::stream<RDTee> RDTeeStream;
class rdLogger {
public:
std::ostream *dp_dest;
bool df_owner, df_enabled;
RDTee *tee;
RDTeeStream *teestream;
rdLogger(std::ostream *dest, bool owner = false)
: dp_dest(dest), df_owner(owner), df_enabled(true),
tee(0), teestream(0){};
void AddTee(std::ostream &stream) {
if (dp_dest) {
tee = new RDTee(*dp_dest, stream);
teestream = new RDTeeStream(*tee);
}
}
~rdLogger() {
if (dp_dest) {
dp_dest->flush();
if (df_owner) {
delete dp_dest;
}
}
delete teestream;
delete tee;
}
};
void enable_logs(const char *arg);
void enable_logs(const std::string &arg);
void disable_logs(const char *arg);
void disable_logs(const std::string &arg);
}
}
namespace RDLog {
std::ostream &toStream(std::ostream &);
}
#define BOOST_LOG(__arg__) \
if ((!__arg__) || (!__arg__->dp_dest) || !(__arg__->df_enabled)) \
; \
else \
RDLog::toStream((__arg__->teestream) ? *(__arg__->teestream) : *(__arg__->dp_dest))
extern boost::logging::rdLogger *rdAppLog;
extern boost::logging::rdLogger *rdDebugLog;
extern boost::logging::rdLogger *rdInfoLog;
extern boost::logging::rdLogger *rdErrorLog;
extern boost::logging::rdLogger *rdWarningLog;
extern boost::logging::rdLogger *rdStatusLog;
#else
#define BOOST_LOG_NO_LIB
#include <boost/log/log.hpp>
BOOST_DECLARE_LOG(rdAppLog)
BOOST_DECLARE_LOG(rdDebugLog)
BOOST_DECLARE_LOG(rdInfoLog)
BOOST_DECLARE_LOG(rdErrorLog)
BOOST_DECLARE_LOG(rdWarningLog)
BOOST_DECLARE_LOG(rdStatusLog)
#endif
namespace RDLog {
void InitLogs();
}
#endif
boost
Definition: RDLog.h:18
boost::logging::rdLogger::~rdLogger
~rdLogger()
Definition: RDLog.h:42
RDLog
Definition: RDLog.h:59
boost::logging::rdLogger::rdLogger
rdLogger(std::ostream *dest, bool owner=false)
Definition: RDLog.h:32
boost::logging::rdLogger::dp_dest
std::ostream * dp_dest
Definition: RDLog.h:26
RDLog::InitLogs
void InitLogs()
rdWarningLog
boost::logging::rdLogger * rdWarningLog
rdAppLog
boost::logging::rdLogger * rdAppLog
boost::logging::rdLogger::AddTee
void AddTee(std::ostream &stream)
Definition: RDLog.h:36
boost::logging::RDTeeStream
boost::iostreams::stream< RDTee > RDTeeStream
Definition: RDLog.h:22
boost::logging::RDTee
boost::iostreams::tee_device< std::ostream, std::ostream > RDTee
Definition: RDLog.h:21
boost::logging::rdLogger::tee
RDTee * tee
Definition: RDLog.h:29
boost::logging::rdLogger::teestream
RDTeeStream * teestream
Definition: RDLog.h:30
boost::logging::rdLogger::df_owner
bool df_owner
Definition: RDLog.h:27
rdStatusLog
boost::logging::rdLogger * rdStatusLog
rdDebugLog
boost::logging::rdLogger * rdDebugLog
boost::logging::rdLogger::df_enabled
bool df_enabled
Definition: RDLog.h:27
RDLog::toStream
std::ostream & toStream(std::ostream &)
rdInfoLog
boost::logging::rdLogger * rdInfoLog
boost::logging::enable_logs
void enable_logs(const char *arg)
boost::logging::rdLogger
Definition: RDLog.h:24
rdErrorLog
boost::logging::rdLogger * rdErrorLog
boost::logging::disable_logs
void disable_logs(const char *arg)