X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FTarget.hh;h=9a47194aec847b10869557a488240caf35ae34fc;hb=ae06fe86f16fdabb7ffb219d255444d2eb4f4f79;hp=6298800532f49b7ef3e6714dd4db26c058b5b14c;hpb=61419d9a2e1060f7ede22fa19fd9d0b401bbc87a;p=senf.git diff --git a/Utils/Logger/Target.hh b/Utils/Logger/Target.hh index 6298800..9a47194 100644 --- a/Utils/Logger/Target.hh +++ b/Utils/Logger/Target.hh @@ -27,7 +27,11 @@ #define HH_Target_ 1 // Custom includes +#include +#include +#include #include "../singleton.hh" +#include "../mpl.hh" #include "StreamRegistry.hh" #include "AreaRegistry.hh" @@ -37,6 +41,8 @@ namespace senf { namespace log { + class TargetRegistry; + /** \brief Logging target base class All enabled log messages are eventually routed to one or more logging targets. It is the @@ -45,8 +51,7 @@ namespace log { passed the log message and a complete set of logging parameters (\e stream, \e area and \e level). */ - class Target - : public senf::singleton + class Target : private boost::noncopyable { public: /////////////////////////////////////////////////////////////////////////// @@ -56,19 +61,24 @@ namespace log { ///\name Structors and default members ///@{ + Target(); virtual ~Target(); - // default default constructor - // default copy constructor - // default copy assignment - // default destructor + ///@} + + template + void route(); - // no conversion constructors + template + void route(); - ///@} + template + void route(); protected: + std::string timestamp(); + private: void route(detail::StreamBase const * stream, detail::AreaBase const * area, @@ -76,15 +86,30 @@ namespace log { void unroute(detail::StreamBase const * stream, detail::AreaBase const * area, unsigned level); + template + void route(detail::StreamBase const * stream, detail::AreaBase const *); + + template + void route(detail::StreamBase const * stream, detail::LevelBase const *); + void updateAreaCache(detail::AreaBase const & area, detail::StreamBase const * stream, unsigned level); - void write(detail::StreamBase const & stream, detail::AreaBase const & area, - unsigned level, std::string const & message); - - virtual void v_write(std::string const & stream, std::string const & area, unsigned level, + void write(boost::posix_time::ptime timestamp, detail::StreamBase const & stream, + detail::AreaBase const & area, unsigned level, std::string const & message); + +# ifdef DOXYGEN + protected: +# endif + + virtual void v_write(boost::posix_time::ptime, std::string const & stream, + std::string const & area, unsigned level, std::string const & message) = 0; +# ifdef DOXYGEN + private: +# endif + struct RoutingEntry { RoutingEntry(detail::StreamBase const * stream_, detail::AreaBase const * area_, @@ -104,14 +129,43 @@ namespace log { typedef std::vector RIB; RIB rib_; + + friend class TargetRegistry; }; + /** \brief Target registry + + The TargetRegistry keeps a record of all existing targets. + */ + class TargetRegistry + : public senf::singleton + { + public: + using senf::singleton::instance; + + void write(detail::StreamBase const & stream, detail::AreaBase const & area, + unsigned level, std::string msg); + + private: + void registerTarget(Target * target); + void unregisterTarget(Target * target); + + typedef std::set Targets; + Targets targets_; + + friend class Target; + }; + + + template + void write(std::string msg); + }} ///////////////////////////////hh.e//////////////////////////////////////// #include "Target.cci" //#include "Target.ct" -//#include "Target.cti" +#include "Target.cti" #endif