LogSender.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarXCore::core
19 * @author Nils Adermann (naderman at naderman dot de)
20 * @date 2010
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24 
25 #include "LogSender.h"
26 #include "SpamFilterData.h"
28 #include <ArmarXCore/interface/core/Log.h>
29 
30 #include <memory>
31 #include <optional>
32 
33 #include <sys/syscall.h>
34 #include <execinfo.h>
35 #include <dlfcn.h>
36 #include <cxxabi.h>
37 
38 #include <boost/logic/tribool.hpp>
39 
40 #include <SimoxUtility/algorithm/string/string_tools.h>
41 
42 #include <IceUtil/Time.h>
43 
44 
45 namespace armarx
46 {
48  {
52 
56 
57  std::string currentFile;
59  std::string currentFunction;
61  boost::logic::tribool printBackTrace;
62 
63  std::optional<Ice::Int> threadId;
64 
65  static std::mutex mutex;
66  };
67 
71  std::vector<LogMessage> LogSender_buffer;
72  std::mutex LogSender::Impl::mutex;
76  bool LogSender_SendLogging = true;
77  std::ostream LogSender_outbuf(std::cout.rdbuf());
78  std::ostream LogSender_errbuf(std::cerr.rdbuf());
79 
80 
81 
82 
83 
84 
85 
87  {
88  return LogSenderPtr(new LogSender());
89  }
90 
91 
92 
94  : impl(new Impl)
95  {
96  impl->minimumLoggingLevel = MessageTypeT::UNDEFINED;
97  impl->cancelNextMessage = false;
98  impl->currentSeverity = MessageTypeT::INFO;
99  impl->printBackTrace = boost::logic::indeterminate;
100 
101  initConsole();
102  resetLocation();
103  }
104 
105 
106 
107  LogSender::LogSender(const std::string& componentName, LogPrx logProxy)
108  : impl(new Impl)
109  {
110  impl->minimumLoggingLevel = MessageTypeT::UNDEFINED;
111  impl->cancelNextMessage = false;
112  impl->currentSeverity = MessageTypeT::INFO;
113  impl->printBackTrace = true;
114 
115  initConsole();
116  setProxy(componentName, logProxy);
117  resetLocation();
118  }
119 
121  {
122  if (!currentMessage.str().empty())
123  {
124  flush();
125  }
126  }
127 
128 
129  void LogSender::setProxy(const std::string& componentName, LogPrx logProxy)
130  {
131  std::unique_lock lock(Impl::mutex);
132  LogSender_logProxy = logProxy;
133  LogSender_componentName = componentName;
134 
135  if (!logProxy)
136  {
137  return;
138  }
139 
140  for (unsigned int i = 0; i < LogSender_buffer.size(); ++i)
141  {
142  LogSender_logProxy->writeLog(LogSender_buffer[i]);
143  }
144 
145  LogSender_buffer.clear();
146  }
147 
148  void LogSender::SetComponentName(const std::string& componentName)
149  {
150  std::unique_lock lock(Impl::mutex);
151  LogSender_componentName = componentName;
152  }
153 
154  void LogSender::SetLoggingGroup(const std::string& loggingGroup)
155  {
156  std::unique_lock lock(Impl::mutex);
157  LogSender_loggingGroup = loggingGroup;
158  }
159 
160  LogSender& LogSender::operator<<(const std::chrono::nanoseconds& timestamp)
161  {
162  if (timestamp.count() > 1000)
163  {
164  return *this << std::chrono::duration_cast<std::chrono::microseconds>(timestamp);
165  }
166 
167  currentMessage << timestamp.count() << " ns";
168  return *this;
169  }
170 
171  LogSender& LogSender::operator<<(const std::chrono::microseconds& timestamp)
172  {
173  if (timestamp.count() > 1000)
174  {
175  return *this << std::chrono::duration_cast<std::chrono::milliseconds>(timestamp);
176  }
177 
178  if (timestamp.count() <= 1. / 1000)
179  {
180  return *this << std::chrono::duration_cast<std::chrono::nanoseconds>(timestamp);
181  }
182 
183  currentMessage << timestamp.count() << " µs";
184  return *this;
185  }
186 
187  LogSender& LogSender::operator<<(const std::chrono::milliseconds& timestamp)
188  {
189  if (timestamp.count() > 1000)
190  {
191  return *this << std::chrono::duration_cast<std::chrono::seconds>(timestamp);
192  }
193 
194  if (timestamp.count() <= 1. / 1000)
195  {
196  return *this << std::chrono::duration_cast<std::chrono::microseconds>(timestamp);
197  }
198 
199  currentMessage << timestamp.count() << " ms";
200  return *this;
201  }
202 
203  LogSender& LogSender::operator<<(const std::chrono::seconds& timestamp)
204  {
205  if (timestamp.count() > 60)
206  {
207  return *this << std::chrono::duration_cast<std::chrono::minutes>(timestamp);
208  }
209 
210  if (timestamp.count() <= 1. / 1000)
211  {
212  return *this << std::chrono::duration_cast<std::chrono::milliseconds>(timestamp);
213  }
214 
215  currentMessage << timestamp.count() << " s";
216  return *this;
217  }
218 
219  LogSender& LogSender::operator<<(const std::chrono::minutes& timestamp)
220  {
221  if (timestamp.count() < 1. / 60)
222  {
223  return *this << std::chrono::duration_cast<std::chrono::seconds>(timestamp);
224  }
225 
226  currentMessage << timestamp.count() << " min";
227  return *this;
228  }
229 
231  {
232  double time_count = timestamp.toMicroSecondsDouble();
233  std::string unit = "µs";
234 
235  if (time_count >= 1000)
236  {
237  time_count /= 1000;
238  unit = "ms";
239 
240  if (time_count >= 1000)
241  {
242  time_count /= 1000;
243  unit = "s";
244 
245  if (time_count >= 60)
246  {
247  time_count /= 60;
248  unit = "min";
249 
250  if (time_count >= 60)
251  {
252  time_count /= 60;
253  unit = "h";
254 
255  if (time_count >= 24)
256  {
257  return *this << timestamp.toDateTime();
258  }
259  }
260  }
261  }
262  }
263 
264  return *this << std::to_string(time_count) + " " + unit;
265  }
266 
268  {
269  switch (type)
270  {
271  case eVERBOSE:
272  return LogSender::eBlue;
273  break;
274 
275  case eIMPORTANT:
276  return LogSender::eGreen;
277 
278  case eWARN:
279  return LogSender::eYellow;
280  break;
281 
282  case eERROR:
283  case eFATAL:
284  return LogSender::eRed;
285  break;
286 
287  default:
288  return LogSender::eReset;
289  break;
290  }
291  }
292 
293  std::string LogSender::GetColorCodeString(MessageTypeT verbosityLevel)
294  {
295 
296  ConsoleColor colorCode = GetColorCode((MessageType)verbosityLevel);
297  return GetColorCodeString(colorCode);
298  }
299 
301  {
302  std::stringstream stream;
303 
304  if (colorCode == LogSender::eReset)
305  {
306  stream << "\033[0" << "m";
307  }
308  else
309  {
310  stream << "\033[3" << colorCode << "m";
311  }
312 
313  return stream.str();
314  }
315 
316  void LogSender::resetLocation()
317  {
318  impl->currentFile = "";
319  impl->currentLine = -1;
320  impl->currentFunction = "";
321  }
322 
323  void LogSender::log(MessageTypeT severity, std::string message)
324  {
325  simox::alg::trim(message);
326  if (impl->cancelNextMessage)
327  {
328  impl->cancelNextMessage = false;
329  return;
330  }
331 
333  {
334  return;
335  }
336 
337  if (severity < impl->minimumLoggingLevel)
338  {
339  return;
340  }
341 
342  if (impl->minimumLoggingLevel == MessageTypeT::UNDEFINED
344  )
345  {
346  return;
347  }
348 
349  IceUtil::Time time = IceUtil::Time::now();
350 
351  std::string catStr;
352 
353  if (!impl->currentTag.tagName.empty())
354  {
355  catStr = "[" + impl->currentTag.tagName + "]: ";
356  }
357  else
358  {
359  catStr = "[" + CropFunctionName(impl->currentFunction) + "]: ";
360  }
361 
362  std::string outputStr;
363 
365  {
366  outputStr += GetColorCodeString(severity);
367 
368  if (severity >= MessageTypeT::FATAL)
369  {
370  outputStr += "\033[1m"; // Bold text
371  }
372  }
373 
374  outputStr += "[" + time.toDateTime().substr(time.toDateTime().find(' ') + 1) + "]" + "[" + LogSender_componentName + "]" + catStr;
375 
377  {
378  outputStr += GetColorCodeString(eReset);
379  }
380 
381  outputStr += message;
382 
384  {
386  }
387 
388  LogMessage msg;
389  msg.who = LogSender_componentName;
390  msg.group = LogSender_loggingGroup;
391  msg.time = time.toMicroSeconds();
392  msg.tag = impl->currentTag.tagName;
393  msg.type = (MessageType)severity;
394  msg.what = message;
395  msg.file = impl->currentFile;
396  msg.line = impl->currentLine;
397  msg.function = impl->currentFunction;
398  msg.threadId = impl->threadId ? *impl->threadId : getThreadId();
399 
400  if ((severity >= MessageTypeT::WARN && boost::logic::indeterminate(impl->printBackTrace))
401  || impl->printBackTrace)
402  {
403  msg.backtrace = CreateBackTrace();
404  }
405 
407  {
408  LogSender_logProxy->begin_writeLog(msg); // use async function, so that it returns faster
409  }
410 
411 
412 
413  try
414  {
415  std::unique_lock lock(Impl::mutex); // std::cout is not threadsafe and also lock for inserting into buffer
416 
417  if (severity >= MessageTypeT::ERROR)
418  {
419  LogSender_errbuf << "[" << msg.threadId << "]" << outputStr << std::endl;
420  }
421  else
422  {
423  LogSender_outbuf << "[" << msg.threadId << "]" << outputStr << std::endl;
424  }
425 
426  if (!LogSender_logProxy)
427  {
428  LogSender_buffer.push_back(msg);
429  }
430 
431  resetLocation();
432  }
433  catch (...)
434  {
435  std::cout << outputStr << std::endl;
436  return; // mutex may be deleted already if the system shuts down at this moment
437  }
438  }
439 
441  {
442  return syscall(SYS_gettid);
443  }
444 
446  {
447 #ifdef WIN32
448  return 0;
449 #else
450  return getpid();
451 #endif
452  }
453 
454 
456  {
457 
458  log(impl->currentSeverity, currentMessage.str());
459  currentMessage.str(""); // reset
460  }
461 
462  std::string LogSender::CropFunctionName(std::string const& originalFunctionName)
463  {
464  unsigned int maxLength = 40;
465  std::string result;
466 
467  if (originalFunctionName.length() <= maxLength)
468  {
469  return originalFunctionName;
470  }
471 
472  std::string beforeFunctionName = originalFunctionName.substr(0, originalFunctionName.rfind("::"));
473  std::string::size_type namespaceDotsPos = beforeFunctionName.find("::", beforeFunctionName.find(' '));
474 
475  if (namespaceDotsPos != std::string::npos)
476  {
477  std::string afterClassName = originalFunctionName.substr(originalFunctionName.rfind("::"));
478  result = beforeFunctionName.substr(namespaceDotsPos + 2) + afterClassName;
479  }
480  else
481  {
482  result = originalFunctionName;
483  }
484 
485  if (result.length() <= maxLength)
486  {
487  return result;
488  }
489 
490 
491  result = result.substr(0, result.find("("));
492  result += "(...)";
493 
494  return result;
495 
496 
497 
498  }
499 
500 
501  std::string LogSender::CreateBackTrace(int linesToSkip)
502  {
503  void* callstack[128];
504  const int nMaxFrames = sizeof(callstack) / sizeof(callstack[0]);
505  char buf[1024];
506 
507  int nFrames = ::backtrace(callstack, nMaxFrames);
508  char** symbols = backtrace_symbols(callstack, nFrames);
509 
510  std::ostringstream trace_buf;
511 
512  for (int i = linesToSkip; i < nFrames; i++)
513  {
514  Dl_info info;
515 
516  if (dladdr(callstack[i], &info) && info.dli_sname)
517  {
518  char* demangled = nullptr;
519  int status = -1;
520 
521  if (info.dli_sname[0] == '_')
522  {
523  demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status);
524  }
525 
526  snprintf(buf, sizeof(buf), "%-3d %*p %s + %zd\n",
527  i - linesToSkip + 1, int(2 + sizeof(void*) * 2), callstack[i],
528  status == 0 ? demangled :
529  info.dli_sname == nullptr ? symbols[i] : info.dli_sname,
530  (char*)callstack[i] - (char*)info.dli_saddr);
531  free(demangled);
532  }
533  else
534  {
535  snprintf(buf, sizeof(buf), "%-3d %*p %s\n",
536  i - linesToSkip + 1, int(2 + sizeof(void*) * 2), callstack[i], symbols[i]);
537  }
538 
539  trace_buf << buf;
540  }
541 
542  free(symbols);
543 
544  if (nFrames == nMaxFrames)
545  {
546  trace_buf << "[truncated]\n";
547  }
548 
549  return trace_buf.str();
550  }
551 
553  {
554  return impl->currentSeverity;
555  }
556 
557  LogSenderPtr LogSender::setFile(const std::string& file)
558  {
559  impl->currentFile = file;
560  return shared_from_this();
561  }
562 
564  {
565  impl->currentLine = line;
566  return shared_from_this();
567  }
568 
569  LogSenderPtr LogSender::setFunction(const std::string& function)
570  {
571  impl->currentFunction = function;
572  return shared_from_this();
573  }
574 
576  {
577  impl->minimumLoggingLevel = level;
578  return shared_from_this();
579  }
580 
582  {
583  impl->printBackTrace = printBackTrace;
584  return shared_from_this();
585  }
587  {
588  impl->threadId = tid;
589  return shared_from_this();
590  }
591 
593  {
594  impl->currentTag = tag;
595  return shared_from_this();
596  }
597 
598  //LogSenderPtr LogSender::setSpamFilter(SpamFilterMapPtr spamFilter)
599  //{
600  // this->spamFilter = spamFilter;
601  // return shared_from_this();
602  //}
603 
605  {
606  switch (type)
607  {
608  case MessageTypeT::DEBUG:
609  return "Debug";
610 
612  return "Verbose";
613 
614  case MessageTypeT::INFO:
615  return "Info";
616 
618  return "Important";
619 
620  case MessageTypeT::WARN:
621  return "Warning";
622 
623  case MessageTypeT::ERROR:
624  return "Error";
625 
626  case MessageTypeT::FATAL:
627  return "Fatal";
628 
629  default:
630  return "Undefined";
631  }
632  }
633 
634  MessageTypeT LogSender::StringToLevel(const std::string& typeStr)
635  {
636  if (simox::alg::to_lower(typeStr) == "debug")
637  {
638  return MessageTypeT::DEBUG;
639  }
640 
641  if (simox::alg::to_lower(typeStr) == "verbose")
642  {
643  return MessageTypeT::VERBOSE;
644  }
645 
646  if (simox::alg::to_lower(typeStr) == "important")
647  {
649  }
650 
651  if (simox::alg::to_lower(typeStr) == "warning")
652  {
653  return MessageTypeT::WARN;
654  }
655 
656  if (simox::alg::to_lower(typeStr) == "error")
657  {
658  return MessageTypeT::ERROR;
659  }
660 
661  if (simox::alg::to_lower(typeStr) == "fatal")
662  {
663  return MessageTypeT::FATAL;
664  }
665 
667 
668  }
669 
671  {
673  {
674  return;
675  }
676 
678  std::cout << "setting global logging level to " << LogSender::levelToString(level) << std::endl;
679  }
680 
682  {
684  }
685 
686 
687  void LogSender::SetLoggingActivated(bool activated, bool showMessage)
688  {
689  if (LogSender_LoggingActivated && showMessage && !activated)
690  {
691  std::cout << "logging is now DEACTIVATED" << std::endl;
692  }
693 
694  if (activated && LogSender_LoggingActivated != activated && showMessage)
695  {
696  std::cout << "logging is now ACTIVATED" << std::endl;
697  }
698  LogSender_LoggingActivated = activated;
699  }
700 
702  {
703  LogSender_SendLogging = activated;
704  }
705 
707  {
708  LogSender_ColoringActivated = activated;
709  }
710 
711  void LogSender::initConsole()
712  {
713  static bool initialized = false;
714 
715  if (!initialized)
716  {
717  initialized = true;
718  char* termType = getenv("TERM");
719 
720  if (termType != nullptr)
721  {
722  std::string termTypeStr(termType);
723 
724  if (termTypeStr != "xterm"
725  && termTypeStr != "emacs"
726  && termTypeStr != "xterm-256color")
727  {
729  }
730  }
731  else
732  {
734  }
735 
736  }
737  }
738 
739  template<>
740  ARMARXCORE_IMPORT_EXPORT LogSender& LogSender::operator<< <LogSender::ConsoleColor>(const LogSender::ConsoleColor& colorCode)
741  {
742  currentMessage << LogSender::GetColorCodeString(colorCode);
743 
744  return *this;
745  }
746 
747 
748 
749 
750  template<>
751  LogSender& LogSender::operator<< <MessageTypeT>(const MessageTypeT& severity)
752  {
753  impl->currentSeverity = severity;
754 
755  return *this;
756  }
757 
758  template<>
759  LogSender& LogSender::operator<< <LogTag>(const LogTag& tag)
760  {
761  impl->currentTag = tag;
762 
763  return *this;
764  }
765 
766  template<>
767  LogSender& LogSender::operator<< <LogSender::manipulator>(const manipulator& manipulator)
768  {
769  (this->*manipulator)();
770 
771  return *this;
772  }
773 
774  LogSender& LogSender::operator<< (const StandardEndLine& manipulator)
775  {
776  flush();
777 
778  return *this;
779  }
780 
781  template<>
782  LogSender& LogSender::operator<< <bool>(const bool& duality)
783  {
784  if (duality)
785  {
786  currentMessage << "true";
787  }
788  else
789  {
790  currentMessage << "false";
791  }
792 
793  return *this;
794  }
795 
796  template<>
797  LogSender& LogSender::operator<< <SpamFilterDataPtr>(const SpamFilterDataPtr& spamFilterData)
798  {
799  if (!spamFilterData)
800  {
801  return *this;
802  }
803 
804  std::unique_lock lock(*spamFilterData->mutex);
805  float deactivationDurationSec = spamFilterData->durationSec;
806  SpamFilterMapPtr spamFilter = spamFilterData->filterMap;
807  std::string id = impl->currentFile + ":" + to_string(impl->currentLine);
808  auto it = spamFilter->find(spamFilterData->identifier);
809 
810  if (it != spamFilter->end())
811  {
812  auto itSub = it->second.find(id);
813  IceUtil::Time durationEnd = IceUtil::Time::now() + IceUtil::Time::milliSecondsDouble(deactivationDurationSec * 1000);
814 
815  if (itSub == it->second.end())
816  {
817  itSub = it->second.insert(
818  std::make_pair(
819  id,
820  durationEnd)).first;
821  impl->cancelNextMessage = false;
822  }
823  else if (IceUtil::Time::now() < itSub->second)
824  {
825  impl->cancelNextMessage = true;
826  }
827  else
828  {
829  impl->cancelNextMessage = false;
830  itSub->second = durationEnd;
831  }
832  }
833 
834  return *this;
835  }
836 }
armarx::MessageTypeT::ERROR
@ ERROR
armarx::MessageTypeT
MessageTypeT
Definition: LogSender.h:45
armarx::GetColorCode
LogSender::ConsoleColor GetColorCode(MessageType type)
Definition: LogSender.cpp:267
armarx::LogSender_errbuf
std::ostream LogSender_errbuf(std::cerr.rdbuf())
armarx::MessageTypeT::WARN
@ WARN
armarx::LogSender::GetColorCodeString
static std::string GetColorCodeString(MessageTypeT verbosityLevel)
Definition: LogSender.cpp:293
armarx::MessageTypeT::FATAL
@ FATAL
armarx::LogSender::SetGlobalMinimumLoggingLevel
static void SetGlobalMinimumLoggingLevel(MessageTypeT level)
With setGlobalMinimumLoggingLevel the minimum verbosity-level of log-messages can be set for the whol...
Definition: LogSender.cpp:670
armarx::LogSender::eRed
@ eRed
Definition: LogSender.h:73
armarx::MessageTypeT::UNDEFINED
@ UNDEFINED
armarx::MessageTypeT::INFO
@ INFO
armarx::LogSender::setTag
LogSenderPtr setTag(const LogTag &tag)
Definition: LogSender.cpp:592
armarx::LogPrx
::IceInternal::ProxyHandle< ::IceProxy::armarx::Log > LogPrx
Definition: LogSender.h:58
armarx::MessageTypeT::VERBOSE
@ VERBOSE
armarx::LogSender
Wrapper for the Log IceStorm topic with convenience methods for logging.
Definition: LogSender.h:66
armarx::LogSender::CropFunctionName
static std::string CropFunctionName(const std::string &originalFunctionName)
Definition: LogSender.cpp:462
armarx::LogSender::getThreadId
static long getThreadId()
Definition: LogSender.cpp:440
armarx::LogSender::setThreadId
LogSenderPtr setThreadId(Ice::Int tid)
Definition: LogSender.cpp:586
armarx::LogSender::Impl
Definition: LogSender.cpp:47
armarx::LogSender::SetSendLoggingActivated
static void SetSendLoggingActivated(bool activated=true)
Definition: LogSender.cpp:701
armarx::LogSender::~LogSender
~LogSender()
Definition: LogSender.cpp:120
armarx::MessageTypeT::IMPORTANT
@ IMPORTANT
armarx::LogSender::GetGlobalMinimumLoggingLevel
static MessageTypeT GetGlobalMinimumLoggingLevel()
Definition: LogSender.cpp:681
armarx::LogSender::SetLoggingGroup
static void SetLoggingGroup(const std::string &loggingGroup)
Definition: LogSender.cpp:154
armarx::detail::StreamPrinterTag::tag
@ tag
armarx::LogSender::Impl::currentLine
int currentLine
Definition: LogSender.cpp:58
armarx::LogSender::setLocalMinimumLoggingLevel
LogSenderPtr setLocalMinimumLoggingLevel(MessageTypeT level)
Definition: LogSender.cpp:575
StringHelpers.h
armarx::LogSender_LoggingActivated
bool LogSender_LoggingActivated
Definition: LogSender.cpp:73
armarx::LogSender::getSeverity
MessageTypeT getSeverity()
Retrieves the current message severity.
Definition: LogSender.cpp:552
armarx::status
status
Definition: FiniteStateMachine.h:259
armarx::LogSender::Impl::cancelNextMessage
bool cancelNextMessage
Definition: LogSender.cpp:54
armarx::LogSender::setBacktrace
LogSenderPtr setBacktrace(bool printBackTrace)
Definition: LogSender.cpp:581
message
message(STATUS "Boost-Library-Dir: " "${Boost_LIBRARY_DIRS}") message(STATUS "Boost-LIBRARIES
Definition: CMakeLists.txt:8
armarx::LogSender::operator<<
LogSender & operator<<(const T &message)
Appends a variable to the current message stringstream.
Definition: LogSender.h:116
armarx::LogSender_ColoringActivated
bool LogSender_ColoringActivated
Definition: LogSender.cpp:75
armarx::LogSender::Impl::spamFilter
SpamFilterMapPtr spamFilter
Definition: LogSender.cpp:53
armarx::SpamFilterDataPtr
std::shared_ptr< SpamFilterData > SpamFilterDataPtr
Definition: Logging.h:220
armarx::LogSender_buffer
std::vector< LogMessage > LogSender_buffer
Definition: LogSender.cpp:71
armarx::LogSender::Impl::printBackTrace
boost::logic::tribool printBackTrace
Definition: LogSender.cpp:61
armarx::LogSender::LogSender
LogSender()
Definition: LogSender.cpp:93
armarx::LogSender::setFile
LogSenderPtr setFile(const std::string &file)
Set the source code filename associated with this message.
Definition: LogSender.cpp:557
armarx::LogSender::log
void log(MessageTypeT severity, std::string message)
Sends a message to the logging component.
Definition: LogSender.cpp:323
armarx::LogSender::Impl::currentTag
LogTag currentTag
Definition: LogSender.cpp:60
armarx::LogSender::CreateBackTrace
static std::string CreateBackTrace(int linesToSkip=1)
Definition: LogSender.cpp:501
timestamp
std::string timestamp()
Definition: CartographerAdapter.cpp:85
armarx::LogSender_logProxy
LogPrx LogSender_logProxy
Definition: LogSender.cpp:68
armarx::LogSender::Impl::mutex
static std::mutex mutex
Definition: LogSender.cpp:65
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:40
armarx::LogSender::getProcessId
static long getProcessId()
Definition: LogSender.cpp:445
armarx::LogSender_GlobalMinimumLoggingLevel
MessageTypeT LogSender_GlobalMinimumLoggingLevel
Definition: LogSender.cpp:74
armarx::LogSender::Impl::currentFunction
std::string currentFunction
Definition: LogSender.cpp:59
armarx::LogSender_componentName
std::string LogSender_componentName
Definition: LogSender.cpp:69
SpamFilterData.h
armarx::LogSender::SetLoggingActivated
static void SetLoggingActivated(bool activated=true, bool showMessage=true)
setLoggingActivated() is used to activate or disable the logging facilities in the whole application
Definition: LogSender.cpp:687
armarx::LogSender::eGreen
@ eGreen
Definition: LogSender.h:74
armarx::LogSenderPtr
std::shared_ptr< LogSender > LogSenderPtr
Typedef of std::shared_ptr for convenience.
Definition: Logging.h:217
armarx::LogSender::setProxy
static void setProxy(const std::string &componentName, LogPrx logProxy)
Definition: LogSender.cpp:129
armarx::LogSender::flush
void flush()
Sends the current message to the log and resets the content.
Definition: LogSender.cpp:455
armarx::LogSender::SetComponentName
static void SetComponentName(const std::string &componentName)
Definition: LogSender.cpp:148
LogSender.h
armarx::MessageTypeT::DEBUG
@ DEBUG
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
armarx::SpamFilterMapPtr
std::shared_ptr< SpamFilterMap > SpamFilterMapPtr
Definition: SpamFilterData.h:13
armarx::LogSender::setLine
LogSenderPtr setLine(int line)
Set the source code line associated with this message.
Definition: LogSender.cpp:563
armarx::LogSender::StringToLevel
static MessageTypeT StringToLevel(const std::string &typeStr)
stringToLevel converts a string into a LoggingLevel, if possible.
Definition: LogSender.cpp:634
armarx::LogSender::SetColoredConsoleActivated
static void SetColoredConsoleActivated(bool activated=true)
Definition: LogSender.cpp:706
armarx::LogSender::Impl::currentFile
std::string currentFile
Definition: LogSender.cpp:57
armarx::LogSender_loggingGroup
std::string LogSender_loggingGroup
Definition: LogSender.cpp:70
ARMARXCORE_IMPORT_EXPORT
#define ARMARXCORE_IMPORT_EXPORT
Definition: ImportExport.h:38
armarx::LogSender::setFunction
LogSenderPtr setFunction(const std::string &function)
Set the function name associated with this message.
Definition: LogSender.cpp:569
armarx::LogSender::createLogSender
static LogSenderPtr createLogSender()
Definition: LogSender.cpp:86
armarx::LogSender::Impl::currentSeverity
MessageTypeT currentSeverity
Definition: LogSender.cpp:55
armarx::LogSender::Impl::threadId
std::optional< Ice::Int > threadId
Definition: LogSender.cpp:63
armarx::LogSender::eYellow
@ eYellow
Definition: LogSender.h:75
armarx::LogTag
Definition: LoggingUtil.h:66
armarx::LogSender_SendLogging
bool LogSender_SendLogging
Definition: LogSender.cpp:76
armarx::LogSender::eBlue
@ eBlue
Definition: LogSender.h:76
armarx::LogSender::Impl::minimumLoggingLevel
MessageTypeT minimumLoggingLevel
Flag to specify a minimum logging level for this LogSender usually is set by Logging-Class.
Definition: LogSender.cpp:51
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::LogSender_outbuf
std::ostream LogSender_outbuf(std::cout.rdbuf())
armarx::LogSender::eReset
@ eReset
Definition: LogSender.h:71
armarx::LogSender::ConsoleColor
ConsoleColor
Definition: LogSender.h:69
armarx::LogSender::levelToString
static std::string levelToString(MessageTypeT type)
Definition: LogSender.cpp:604