00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #include "AreaRegistry.hh"
00027 #include "AreaRegistry.ih"
00028
00029
00030 #include "Target.hh"
00031
00032
00033 #define prefix_
00034
00035
00036
00037
00038
00039 prefix_ senf::log::detail::AreaBase::AreaBase()
00040 : alive_ (true)
00041 {}
00042
00043 prefix_ senf::log::detail::AreaBase::~AreaBase()
00044 {
00045 alive_ = false;
00046 }
00047
00048 prefix_ void senf::log::detail::AreaBase::updateRoutingCache(Target & target,
00049 StreamBase const & stream,
00050 unsigned limit)
00051 const
00052 {
00053 if (stream.index >= routingCache_.size())
00054 routingCache_.resize(stream.index+1);
00055 unsigned l (limit);
00056 Routes::iterator i (routingCache_[stream.index].routes.begin());
00057 Routes::iterator const i_end (routingCache_[stream.index].routes.end());
00058 for (; i != i_end; ++i) {
00059 if (i->target == &target) {
00060 i->limit = limit;
00061 break;
00062 }
00063 if (i->limit < l)
00064 l = i->limit;
00065 }
00066 if (i == i_end)
00067 routingCache_[stream.index].routes.push_back(RouteEntry(limit, &target));
00068 else
00069 for (; i != i_end; ++i)
00070 if (i->limit < l)
00071 l = i->limit;
00072 routingCache_[stream.index].limit = l;
00073 }
00074
00075 prefix_ void senf::log::detail::AreaBase::removeRoutingCache(Target & target,
00076 StreamBase const & stream)
00077 const
00078 {
00079 if (stream.index >= routingCache_.size())
00080 return;
00081 unsigned l (DISABLED::value);
00082 Routes::iterator i (routingCache_[stream.index].routes.begin());
00083 Routes::iterator const i_end (routingCache_[stream.index].routes.end());
00084 while (i != i_end) {
00085 if (i->target == &target)
00086 i = routingCache_[stream.index].routes.erase(i);
00087 else {
00088 if (i->limit < l)
00089 l = i->limit;
00090 ++i;
00091 }
00092 }
00093 routingCache_[stream.index].limit = l;
00094 }
00095
00096 prefix_ void senf::log::detail::AreaBase::write(time_type timestamp,
00097 StreamBase const & stream, unsigned level,
00098 std::string const & msg)
00099 const
00100 {
00101 if (stream.index >= routingCache_.size())
00102 return;
00103 Routes::iterator i (routingCache_[stream.index].routes.begin());
00104 Routes::iterator const i_end (routingCache_[stream.index].routes.end());
00105 for (; i != i_end; ++i)
00106 i->target->write(timestamp, stream, *this, level, msg);
00107 }
00108
00109
00110 #undef prefix_
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122