Missing files ...
[senf.git] / Utils / Logger / Target.hh
index 502bae8..dbbad15 100644 (file)
@@ -36,6 +36,7 @@
 #include "StreamRegistry.hh"
 #include "../Exception.hh"
 #include "TimeSource.hh"
+#include "../Console/LazyDirectory.hh"
 
 //#include "Target.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
@@ -55,6 +56,7 @@ namespace log {
 
     namespace detail { class TargetRegistry; }
     namespace detail { class AreaBase; }
+    namespace detail { struct LogParameters; }
 
     /** \brief Logging target base class
 
@@ -76,13 +78,13 @@ namespace log {
             stream
         \li (optional) \e area. If the area is specified, only messages directed at that area are
             matched, otherwise any area will be allowed
-        \li (optional) \e level. If the log level is specified, messages will be accepted if their
+        \li (optional) \e level. If the %log level is specified, messages will be accepted if their
             level is at least that value. If the value is not specified, the limit will be taken
             from the stream's default value.
 
         Each parameter (stream, area and level) has two representations: A static (compile time
-        constant) representation, which is the representation also used in the log statements, and a
-        dynamic representation, which may be used for manipulating the routing table.
+        constant) representation, which is the representation also used in the %log statements, and a
+        dynamic (runtime) representation.
 
         The static representation is used, when passing routing parameters via template arguments:
         \code
@@ -112,6 +114,21 @@ namespace log {
             loglevels. Dynamically, it is represented by an unsigned integer number, the \c value
             member of that class.
 
+        \subsection target_routing_processing Ordering routing entries and route processing
+
+        The routing table is processed from first route to last route, the first matching entry
+        determines the fate of a log messages. Therefore, the ordering of routing entries is
+        important.
+        
+        If no position is explicitly specified, new routing entries are added to the end of the
+        routing table. All routing statements however take an index as optional argument to
+        explicitly specify the position of the new routing entry.
+
+        The index value starts from 0 for the first route. The value gives the position the new
+        routing entry will have after it has been added. An index of 0 will thus insert the new
+        routing entry at the beginning of the table. Negative values count from the back, -1 being
+        the last entry.
+
         \section target_impl Implementing new targets
 
         To implement a new target type, you need to derive from senf::log::Target and implement the
@@ -160,7 +177,7 @@ namespace log {
 #           endif
 
             RoutingEntry();
-            bool operator==(RoutingEntry const & other);
+            bool operator==(RoutingEntry const & other) const;
 
         private:
             RoutingEntry(detail::StreamBase const * stream, detail::AreaBase const * area,
@@ -185,7 +202,7 @@ namespace log {
         ///\name Structors and default members
         ///@{
 
-        Target();
+        explicit Target(std::string const & name);
         virtual ~Target();
 
         ///@}
@@ -338,7 +355,9 @@ namespace log {
         size_type size() const;         ///< Number of routing table entries
         bool empty() const;             ///< \c true, if routing table empty, \c false otherwise
 
-        void clear();                   ///< Clear routing table
+        void flush();                   ///< Clear routing table
+
+        senf::console::ScopedDirectory<> & consoleDir(); ///< Get console/config directory
 
     private:
         void route(detail::StreamBase const * stream, detail::AreaBase const * area,
@@ -351,6 +370,10 @@ namespace log {
         void write(time_type timestamp, detail::StreamBase const & stream,
                    detail::AreaBase const & area, unsigned level, std::string const & message);
 
+        void consoleList(std::ostream & os);
+        void consoleRoute(int index, detail::LogParameters const & pm, action_t action);
+        void consoleUnroute(detail::LogParameters const & pm, action_t action);
+
 #   ifdef DOXYGEN
     protected:
 #   endif
@@ -382,6 +405,8 @@ namespace log {
 
         RIB rib_;
 
+        console::LazyDirectory consoleDir_;
+
         friend class detail::AreaBase;
         friend class detail::TargetRegistry;
     };