00001 #ifndef QPID_LOG_LOGGER_H
00002 #define QPID_LOG_LOGGER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "Selector.h"
00016 #include "Options.h"
00017 #include "qpid/sys/Mutex.h"
00018 #include <boost/ptr_container/ptr_vector.hpp>
00019 #include <boost/noncopyable.hpp>
00020 #include <set>
00021
00022 namespace qpid {
00023 namespace log {
00024
00035 class Logger : private boost::noncopyable {
00036 public:
00038 enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32};
00039
00049 class Output {
00050 public:
00051 Output();
00052 virtual ~Output();
00054 virtual void log(const Statement&, const std::string&) =0;
00055 };
00056
00057 static Logger& instance();
00058
00059 Logger();
00060 ~Logger();
00061
00063 void select(const Selector& s);
00064
00066 void format(int formatFlags);
00067
00071 int format(const Options&);
00072
00074 void configure(const Options& o);
00075
00077 void add(Statement& s);
00078
00080 void log(const Statement&, const std::string&);
00081
00083 void output(std::auto_ptr<Output> out);
00084
00086 void setPrefix(const std::string& prefix);
00087
00089 void clear();
00090
00092 const Options& getOptions() const { return options; }
00093
00094
00095 private:
00096 typedef boost::ptr_vector<Output> Outputs;
00097 typedef std::set<Statement*> Statements;
00098
00099 sys::Mutex lock;
00100 inline void enable_unlocked(Statement* s);
00101
00102 Statements statements;
00103 Outputs outputs;
00104 Selector selector;
00105 int flags;
00106 std::string prefix;
00107 Options options;
00108 };
00109
00110 }}
00111
00112
00113 #endif