X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FTarget.hh;h=b4137d6db827249696c1a8c78460d8bcb4d74f80;hb=ac86c2bb40746fbedf70a19af3307e5da642b04a;hp=56cf519b877be646f7e8b2e65c0c728f1ffecc55;hpb=f6f670f2dbc82b77db29df6cd452f2b351b9662a;p=senf.git diff --git a/Utils/Logger/Target.hh b/Utils/Logger/Target.hh index 56cf519..b4137d6 100644 --- a/Utils/Logger/Target.hh +++ b/Utils/Logger/Target.hh @@ -30,6 +30,7 @@ #include #include #include +#include #include "../singleton.hh" #include "../mpl.hh" #include "StreamRegistry.hh" @@ -62,6 +63,34 @@ namespace log { enum action_t { ACCEPT, REJECT }; + struct RoutingEntry + { + RoutingEntry(); + bool operator==(RoutingEntry const & other); + + std::string stream() const; + std::string area() const; + unsigned level() const; + action_t action() const; + + private: + RoutingEntry(detail::StreamBase const * stream, detail::AreaBase const * area, + unsigned level, action_t action); + + detail::StreamBase const * stream_; + detail::AreaBase const * area_; + unsigned level_; + action_t action_; + + friend class Target; + }; + + private: + typedef std::vector RIB; + + public: + typedef RIB::const_iterator iterator; + /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ @@ -71,46 +100,76 @@ namespace log { ///@} - template - void route(action_t action=ACCEPT); - - template - void route(action_t action=ACCEPT); - - template - void route(action_t action=ACCEPT); - - void route(std::string const & stream, action_t action=ACCEPT); - void route(std::string const & stream, std::string const & area, action_t action=ACCEPT); - void route(std::string const & stream, unsigned level, action_t action=ACCEPT); - void route(std::string const & stream, std::string const & area, unsigned level, - action_t action=ACCEPT); + template void route( + action_t action = ACCEPT, int index = -1); + template void route( + action_t action = ACCEPT, int index = -1, + typename boost::enable_if< boost::is_convertible >::type * = 0); + template void route( + action_t action = ACCEPT, int index = -1, + typename boost::enable_if< boost::is_convertible >::type * = 0); + template void route( + action_t action = ACCEPT, int index = -1, + typename boost::enable_if< boost::is_convertible >::type * = 0); + template void route( + action_t action = ACCEPT, int index = -1, + typename boost::enable_if< boost::is_convertible >::type * = 0); + template void route( + action_t action = ACCEPT, int index = -1, + typename boost::enable_if< boost::is_convertible >::type * = 0); + + void route(std::string const & stream, std::string const & area = "", + unsigned level = NONE::value, action_t action = ACCEPT, int index = -1); + + template void unroute( + action_t action = ACCEPT); + template void unroute( + action_t action = ACCEPT, + typename boost::enable_if< boost::is_convertible >::type * = 0); + template void unroute( + action_t action = ACCEPT, + typename boost::enable_if< boost::is_convertible >::type * = 0); + template void unroute( + action_t action = ACCEPT, + typename boost::enable_if< boost::is_convertible >::type * = 0); + template void unroute( + action_t action = ACCEPT, + typename boost::enable_if< boost::is_convertible >::type * = 0); + template void unroute( + action_t action = ACCEPT, + typename boost::enable_if< boost::is_convertible >::type * = 0); + + void unroute(std::string const & stream, std::string const & area = "", + unsigned level = NONE::value, action_t action = ACCEPT); + void unroute(int index); struct InvalidStreamException : public std::exception { virtual char const * what() const throw() { return "senf::log::Target::InvalidStreamException"; } }; - + struct InvalidAreaException : public std::exception { virtual char const * what() const throw() { return "senf::log::Target::InvalidAreaException"; } }; - - protected: - - std::string timestamp(); + iterator begin() const; + iterator end() const; + private: - void route(detail::StreamBase const * stream, detail::AreaBase const * area, - unsigned level, action_t action); + unsigned level, action_t action, int index); void unroute(detail::StreamBase const * stream, detail::AreaBase const * area, unsigned level, action_t action); - template - void route(detail::StreamBase const * stream, detail::AreaBase const *, action_t action); - - template - void route(detail::StreamBase const * stream, detail::LevelBase const *, action_t action); - void updateRoutingCache(detail::StreamBase const * stream, detail::AreaBase const * area); void write(boost::posix_time::ptime timestamp, detail::StreamBase const & stream, @@ -128,21 +187,6 @@ namespace log { private: # endif - struct RoutingEntry - { - RoutingEntry(detail::StreamBase const * stream_, detail::AreaBase const * area_, - unsigned level_, action_t action_); - RoutingEntry(); - - bool operator==(RoutingEntry const & other); - - detail::StreamBase const * stream; - detail::AreaBase const * area; - unsigned level; action_t action; - }; - - typedef std::vector RIB; - RIB rib_; friend class detail::AreaBase;