Skip to content

Commit bd06caa

Browse files
committed
https://telecominfraproject.atlassian.net/browse/WIFI-13172
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
1 parent 5a7a38c commit bd06caa

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/framework/MicroService.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ namespace OpenWifi {
4747
void MicroService::BusMessageReceived([[maybe_unused]] const std::string &Key,
4848
const std::string &Payload) {
4949
std::lock_guard G(InfraMutex_);
50+
51+
Poco::Logger &BusLogger = Poco::Logger::create(
52+
"BusMessageReceived", Poco::Logger::root().getChannel(), Poco::Logger::root().getLevel());
5053
try {
5154
Poco::JSON::Parser P;
5255
auto Object = P.parse(Payload).extract<Poco::JSON::Object::Ptr>();
@@ -69,7 +72,7 @@ namespace OpenWifi {
6972
if (Event == KafkaTopics::ServiceEvents::EVENT_LEAVE) {
7073
Services_.erase(PrivateEndPoint);
7174
poco_information(
72-
Logger_,
75+
BusLogger,
7376
fmt::format(
7477
"Service {} ID={} leaving system.",
7578
Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE)
@@ -99,7 +102,7 @@ namespace OpenWifi {
99102
Services_[PrivateEndPoint] = ServiceInfo;
100103
if(Event == KafkaTopics::ServiceEvents::EVENT_JOIN) {
101104
poco_information(
102-
Logger_,
105+
BusLogger,
103106
fmt::format(
104107
"Service {} ID={} is joining the system. old={}",
105108
Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE)
@@ -113,13 +116,13 @@ namespace OpenWifi {
113116
SvcList += ", " + Svc.second.Type;
114117
}
115118
poco_information(
116-
Logger_,
119+
BusLogger,
117120
fmt::format("Current list of microservices: {}", SvcList));
118121
}
119122
}
120123
} else {
121124
poco_information(
122-
Logger_,
125+
BusLogger,
123126
fmt::format("KAFKA-MSG: invalid event '{}', missing a field.",
124127
Event));
125128
}
@@ -131,18 +134,18 @@ namespace OpenWifi {
131134
#endif
132135
} else {
133136
poco_information(
134-
Logger_,
137+
BusLogger,
135138
fmt::format("KAFKA-MSG: invalid event '{}', missing token", Event));
136139
}
137140
} else {
138-
poco_information(Logger_,
141+
poco_information(BusLogger,
139142
fmt::format("Unknown Event: {} Source: {}", Event, ID));
140143
}
141144
}
142145
} else {
143146
std::ostringstream os;
144147
Object->stringify(std::cout);
145-
poco_error(Logger_, fmt::format("Bad bus message: {}", os.str()));
148+
poco_error(BusLogger, fmt::format("Bad bus message: {}", os.str()));
146149
}
147150

148151
auto ServiceHint = Services_.begin();
@@ -151,18 +154,18 @@ namespace OpenWifi {
151154
auto ss1 = MakeServiceListString(Services_);
152155
while(ServiceHint!=Services_.end()) {
153156
if ((now - ServiceHint->second.LastUpdate) > 120) {
154-
poco_information(Logger_, fmt::format("ZombieService: Removing service {}, ", ServiceHint->second.PublicEndPoint));
157+
poco_information(BusLogger, fmt::format("ZombieService: Removing service {}, ", ServiceHint->second.PublicEndPoint));
155158
ServiceHint = Services_.erase(ServiceHint);
156159
} else
157160
++ServiceHint;
158161
}
159162
if(Services_.size() != si1) {
160163
auto ss2 = MakeServiceListString(Services_);
161-
poco_information(Logger_, fmt::format("Current list of microservices: {} -> {}", ss1, ss2));
164+
poco_information(BusLogger, fmt::format("Current list of microservices: {} -> {}", ss1, ss2));
162165
}
163166

164167
} catch (const Poco::Exception &E) {
165-
Logger_.log(E);
168+
BusLogger.log(E);
166169
}
167170
}
168171

0 commit comments

Comments
 (0)