X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FTarget.cc;h=068631c7df3e5cbbd7d4778d33c7441f422437f2;hb=5bf459d443ab7cef04116bc0cb95e1af0178334f;hp=d352836c30125fc23c6363b2ed6d0c7a90b972e3;hpb=456ee576285b76aa46240f8001f426757810dcc1;p=senf.git diff --git a/Utils/Logger/Target.cc b/Utils/Logger/Target.cc index d352836..068631c 100644 --- a/Utils/Logger/Target.cc +++ b/Utils/Logger/Target.cc @@ -85,6 +85,8 @@ prefix_ void senf::log::Target::unroute(std::string const & stream, std::string prefix_ void senf::log::Target::unroute(int index) { + if (rib_.empty()) + return; RIB::iterator i; if (index < 0) { if (RIB::size_type(-index) >= rib_.size()) @@ -110,6 +112,17 @@ prefix_ void senf::log::Target::unroute(int index) updateRoutingCache(entry.stream_, entry.area_); } +prefix_ void senf::log::Target::flush() +{ + RIB old; + rib_.swap(old); + RIB::const_iterator i (old.begin()); + RIB::const_iterator const i_end (old.end()); + for (; i != i_end; ++i) + if (i->action_ == ACCEPT) + updateRoutingCache(i->stream_, i->area_); +} + //////////////////////////////////////// // private members @@ -141,10 +154,10 @@ prefix_ void senf::log::Target::route(detail::StreamBase const * stream, } prefix_ void senf::log::Target::unroute(detail::StreamBase const * stream, - detail::AreaBase const * area, unsigned level, + detail::AreaBase const * area, unsigned level, action_t action) { - RIB::iterator i = std::find(rib_.begin(), rib_.end(), + RIB::iterator i = std::find(rib_.begin(), rib_.end(), RoutingEntry(stream, area, level, action)); if (i != rib_.end()) unroute(std::distance(rib_.begin(), i)); @@ -174,7 +187,7 @@ prefix_ void senf::log::Target::updateRoutingCache(detail::StreamBase const * st if ( (! i->stream_ || i->stream_ == stream) && (! i->area_ || i->area_ == area) && i->action_ == ACCEPT ) { - unsigned l (i->level_ == NONE::value ? i->stream_->defaultRuntimeLimit() : i->level_); + unsigned l (i->level_ == NONE::value ? stream->defaultRuntimeLimit() : i->level_); if (l < limit) limit = l; } @@ -194,7 +207,7 @@ prefix_ void senf::log::Target::write(time_type timestamp, for (; i != i_end; ++i) if ( (! i->stream_ || i->stream_ == &stream) && (! i->area_ || i->area_ == &area) && - (i->level_ == NONE::value ? i->stream_->defaultRuntimeLimit() : i->level_) <= level ) { + (i->level_ == NONE::value ? stream.defaultRuntimeLimit() : i->level_) <= level ) { if (i->action_ == ACCEPT) v_write(timestamp, stream.v_name(), area.v_name(), level, message); return; @@ -206,22 +219,33 @@ prefix_ void senf::log::Target::write(time_type timestamp, prefix_ void senf::log::detail::TargetRegistry::write(StreamBase const & stream, AreaBase const & area, unsigned level, - std::string msg) + std::string const & msg) { if (fallbackRouting_) { if (level >= stream.defaultRuntimeLimit()) - static_cast(ConsoleTarget::instance()).v_write( + static_cast(ConsoleTarget::instance()).v_write( TimeSource::now(), stream.v_name(), area.v_name(), level, msg ); } else area.write( TimeSource::now(), stream, level, msg ); } +/////////////////////////////////////////////////////////////////////////// +// namespace members + +prefix_ std::ostream & senf::log::operator<<(std::ostream & os, senf::log::Target::action_t const & action) +{ + if( action == Target::ACCEPT) os << "ACCEPT"; + else if( action == Target::REJECT) os << "REJECT"; + else os << "unknown action"; + return os; +} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "Target.mpp" - + // Local Variables: // mode: c++ // fill-column: 100