RDKit: RDLog.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

RDLog.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005-2008 Greg Landrum and Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10
11 #ifndef _RDLOG_H_29JUNE2005_
12 #define _RDLOG_H_29JUNE2005_
13
14 #if 1
15 #include <boost/iostreams/tee.hpp>
16 #include <boost/iostreams/stream.hpp>
17 #include <iostream>
18 namespace boost {
19 namespace logging {
20
21 typedef boost::iostreams::tee_device<std::ostream, std::ostream> RDTee;
22 typedef boost::iostreams::stream<RDTee> RDTeeStream;
23
24 class rdLogger {
25 public:
26 std::ostream *dp_dest;
27 bool df_owner, df_enabled;
28
29 RDTee *tee;
30 RDTeeStream *teestream;
31
32 rdLogger(std::ostream *dest, bool owner = false)
33 : dp_dest(dest), df_owner(owner), df_enabled(true),
34 tee(0), teestream(0){};
35
36 void AddTee(std::ostream &stream) {
37 if (dp_dest) {
38 tee = new RDTee(*dp_dest, stream);
39 teestream = new RDTeeStream(*tee);
40 }
41 }
42 ~rdLogger() {
43 if (dp_dest) {
44 dp_dest->flush();
45 if (df_owner) {
46 delete dp_dest;
47 }
48 }
49 delete teestream;
50 delete tee;
51 }
52 };
53 void enable_logs(const char *arg);
54 void enable_logs(const std::string &arg);
55 void disable_logs(const char *arg);
56 void disable_logs(const std::string &arg);
57 }
58 }
59 namespace RDLog {
60 std::ostream &toStream(std::ostream &);
61 }
62 #define BOOST_LOG(__arg__) \
63 if ((!__arg__) || (!__arg__->dp_dest) || !(__arg__->df_enabled)) \
64 ; \
65 else \
66 RDLog::toStream((__arg__->teestream) ? *(__arg__->teestream) : *(__arg__->dp_dest))
67
68 extern boost::logging::rdLogger *rdAppLog;
69 extern boost::logging::rdLogger *rdDebugLog;
70 extern boost::logging::rdLogger *rdInfoLog;
71 extern boost::logging::rdLogger *rdErrorLog;
72 extern boost::logging::rdLogger *rdWarningLog;
73 extern boost::logging::rdLogger *rdStatusLog;
74
75 #else
76 #define BOOST_LOG_NO_LIB
77 #include <boost/log/log.hpp>
78 BOOST_DECLARE_LOG(rdAppLog)
79 BOOST_DECLARE_LOG(rdDebugLog)
80 BOOST_DECLARE_LOG(rdInfoLog)
81 BOOST_DECLARE_LOG(rdErrorLog)
82 BOOST_DECLARE_LOG(rdWarningLog)
83 BOOST_DECLARE_LOG(rdStatusLog)
84 #endif
85 namespace RDLog {
86 void InitLogs();
87 }
88 #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)