@@ -156,7 +156,8 @@ class Foundation_API Logger: public Channel
156156 template <typename T, typename ... Args>
157157 void fatal (const std::string& fmt, T arg1, Args&&... args)
158158 {
159- log (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_FATAL);
159+ if (fatal ())
160+ logAlways (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_FATAL);
160161 }
161162
162163 void critical (const std::string& msg);
@@ -178,7 +179,8 @@ class Foundation_API Logger: public Channel
178179 template <typename T, typename ... Args>
179180 void critical (const std::string& fmt, T arg1, Args&&... args)
180181 {
181- log (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_CRITICAL);
182+ if (critical ())
183+ logAlways (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_CRITICAL);
182184 }
183185
184186 void error (const std::string& msg);
@@ -200,7 +202,8 @@ class Foundation_API Logger: public Channel
200202 template <typename T, typename ... Args>
201203 void error (const std::string& fmt, T arg1, Args&&... args)
202204 {
203- log (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_ERROR);
205+ if (error ())
206+ logAlways (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_ERROR);
204207 }
205208
206209 void warning (const std::string& msg);
@@ -222,7 +225,8 @@ class Foundation_API Logger: public Channel
222225 template <typename T, typename ... Args>
223226 void warning (const std::string& fmt, T arg1, Args&&... args)
224227 {
225- log (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_WARNING);
228+ if (warning ())
229+ logAlways (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_WARNING);
226230 }
227231
228232 void notice (const std::string& msg);
@@ -244,7 +248,8 @@ class Foundation_API Logger: public Channel
244248 template <typename T, typename ... Args>
245249 void notice (const std::string& fmt, T arg1, Args&&... args)
246250 {
247- log (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_NOTICE);
251+ if (notice ())
252+ logAlways (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_NOTICE);
248253 }
249254
250255 void information (const std::string& msg);
@@ -266,7 +271,8 @@ class Foundation_API Logger: public Channel
266271 template <typename T, typename ... Args>
267272 void information (const std::string& fmt, T arg1, Args&&... args)
268273 {
269- log (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_INFORMATION);
274+ if (information ())
275+ logAlways (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_INFORMATION);
270276 }
271277
272278 void debug (const std::string& msg);
@@ -288,7 +294,8 @@ class Foundation_API Logger: public Channel
288294 template <typename T, typename ... Args>
289295 void debug (const std::string& fmt, T arg1, Args&&... args)
290296 {
291- log (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_DEBUG);
297+ if (debug ())
298+ logAlways (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_DEBUG);
292299 }
293300
294301 void trace (const std::string& msg);
@@ -310,7 +317,8 @@ class Foundation_API Logger: public Channel
310317 template <typename T, typename ... Args>
311318 void trace (const std::string& fmt, T arg1, Args&&... args)
312319 {
313- log (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_TRACE);
320+ if (trace ())
321+ logAlways (Poco::format (fmt, arg1, std::forward<Args>(args)...), Message::PRIO_TRACE);
314322 }
315323
316324 void dump (const std::string& msg, const void * buffer, std::size_t length, Message::Priority prio = Message::PRIO_DEBUG);
@@ -468,6 +476,8 @@ class Foundation_API Logger: public Channel
468476 Logger (const Logger&);
469477 Logger& operator = (const Logger&);
470478
479+ void logAlways (const std::string& text, Message::Priority prio);
480+
471481 std::string _name;
472482 Channel::Ptr _pChannel;
473483 int _level;
@@ -674,6 +684,15 @@ inline void Logger::log(const std::string& text, Message::Priority prio, const c
674684}
675685
676686
687+ inline void Logger::logAlways (const std::string& text, Message::Priority prio)
688+ {
689+ if (_pChannel)
690+ {
691+ _pChannel->log (Message (_name, text, prio));
692+ }
693+ }
694+
695+
677696inline void Logger::fatal (const std::string& msg)
678697{
679698 log (msg, Message::PRIO_FATAL);
0 commit comments