00001 #ifndef LOGGER_H
00002 #define LOGGER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "Selector.h"
00016 #include "qpid/sys/Mutex.h"
00017 #include <boost/ptr_container/ptr_vector.hpp>
00018 #include <boost/noncopyable.hpp>
00019 #include <set>
00020
00021 namespace qpid {
00022 namespace log {
00023
00024 class Options;
00025
00031 class Logger : private boost::noncopyable {
00032 public:
00034 enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32};
00035
00040 class Output {
00041 public:
00042 Output();
00043 virtual ~Output();
00045 virtual void log(const Statement&, const std::string&) =0;
00046 };
00047
00048 static Logger& instance();
00049
00050 Logger();
00051 ~Logger();
00052
00054 void select(const Selector& s);
00055
00057 void format(int formatFlags);
00058
00062 int format(const Options&);
00063
00065 void configure(const Options& o);
00066
00068 void add(Statement& s);
00069
00071 void log(const Statement&, const std::string&);
00072
00079 void output(std::ostream&);
00080
00082 void syslog(const Options&);
00083
00088 void output(const std::string& name, const Options&);
00089
00091 void output(std::auto_ptr<Output> out);
00092
00094 void setPrefix(const std::string& prefix);
00095
00097 void clear();
00098
00099
00100 private:
00101 typedef boost::ptr_vector<Output> Outputs;
00102 typedef std::set<Statement*> Statements;
00103
00104 sys::Mutex lock;
00105 inline void enable_unlocked(Statement* s);
00106
00107 Statements statements;
00108 Outputs outputs;
00109 Selector selector;
00110 int flags;
00111 std::string prefix;
00112 };
00113
00114 }}
00115
00116
00117 #endif