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, const std::string& progname);
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 std::string& programName);
00083
00088 void output(const std::string& name);
00089
00091 void output(std::auto_ptr<Output> out);
00092
00094 void clear();
00095
00096 private:
00097 typedef boost::ptr_vector<Output> Outputs;
00098 typedef std::set<Statement*> Statements;
00099
00100 sys::Mutex lock;
00101 inline void enable_unlocked(Statement* s);
00102
00103 std::string syslogName;
00104 Statements statements;
00105 Outputs outputs;
00106 Selector selector;
00107 int flags;
00108 };
00109
00110 }}
00111
00112
00113 #endif