X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FTarget.cc;h=91d231e98ed78fb25c0b9357e541cc8e57b0ac1e;hb=d0776a27ffd63ab51b4e3419a8a6f87d11e60594;hp=3c32f95b597296b3bf6f3b9e74d1125e7455e324;hpb=044a1bfb46ce16c3daac307b8c684604b43dd4cf;p=senf.git diff --git a/Utils/Logger/Target.cc b/Utils/Logger/Target.cc index 3c32f95..91d231e 100644 --- a/Utils/Logger/Target.cc +++ b/Utils/Logger/Target.cc @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -28,6 +28,7 @@ // Custom includes #include +#include "ConsoleTarget.hh" //#include "Target.mpp" #define prefix_ @@ -44,8 +45,8 @@ prefix_ senf::log::Target::Target() prefix_ senf::log::Target::~Target() { while( ! rib_.empty()) { - // This is terribly slow but simplifies the area cache handling and removing a target should - // be quite seldom + // This is slow but simplifies the area cache handling and removing a target should be + // relatively seldom RIB::reverse_iterator i (rib_.rbegin()); unroute(i->stream_, i->area_, i->level_, i->action_); } @@ -135,6 +136,8 @@ prefix_ void senf::log::Target::route(detail::StreamBase const * stream, rib_.insert(i, RoutingEntry(stream, area, level, action)); if (action == ACCEPT) updateRoutingCache(stream, area); + // This disables the initial fallback routing + detail::TargetRegistry::instance().routed(); } prefix_ void senf::log::Target::unroute(detail::StreamBase const * stream, @@ -199,14 +202,34 @@ prefix_ void senf::log::Target::write(boost::posix_time::ptime timestamp, } /////////////////////////////////////////////////////////////////////////// -// senf::log::TargetRegistry +// senf::log::detail::TargetRegistry prefix_ void senf::log::detail::TargetRegistry::write(StreamBase const & stream, AreaBase const & area, unsigned level, std::string msg) { - boost::posix_time::ptime timestamp (boost::posix_time::microsec_clock::universal_time()); - area.write(timestamp, stream, level, msg); + if (fallbackRouting_) { + if (level >= stream.defaultRuntimeLimit()) + static_cast(ConsoleTarget::instance()).v_write( + (*timeSource_)(), stream.v_name(), area.v_name(), level, msg ); + } + else + area.write( (*timeSource_)(), stream, level, msg ); +} + +/////////////////////////////////////////////////////////////////////////// +// senf::log::TimeSource + +prefix_ senf::log::TimeSource::~TimeSource() +{} + +/////////////////////////////////////////////////////////////////////////// +// senf::log::SystemTimeSource + +prefix_ boost::posix_time::ptime senf::log::SystemTimeSource::operator()() + const +{ + return boost::posix_time::microsec_clock::universal_time(); } ///////////////////////////////cc.e////////////////////////////////////////