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  {
49  //! Flag to specify a minimum logging level for this LogSender<br/>
50  //! usually is set by Logging-Class
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  try
89  {
90  return std::make_shared<LogSender>();
91  }
92  catch (...)
93  {
94  return nullptr;
95  }
96  }
97 
98 
99 
101  : impl(new Impl)
102  {
103  impl->minimumLoggingLevel = MessageTypeT::UNDEFINED;
104  impl->cancelNextMessage = false;
105  impl->currentSeverity = MessageTypeT::INFO;
106  impl->printBackTrace = boost::logic::indeterminate;
107 
108  initConsole();
109  resetLocation();
110  }
111 
112 
113 
114  LogSender::LogSender(const std::string& componentName, LogPrx logProxy)
115  : impl(new Impl)
116  {
117  impl->minimumLoggingLevel = MessageTypeT::UNDEFINED;
118  impl->cancelNextMessage = false;
119  impl->currentSeverity = MessageTypeT::INFO;
120  impl->printBackTrace = true;
121 
122  initConsole();
123  setProxy(componentName, logProxy);
124  resetLocation();
125  }
126 
128  {
129  if (!currentMessage.str().empty())
130  {
131  flush();
132  }
133  }
134 
135 
136  void LogSender::setProxy(const std::string& componentName, LogPrx logProxy)
137  {
138  std::unique_lock lock(Impl::mutex);
139  LogSender_logProxy = logProxy;
140  LogSender_componentName = componentName;
141 
142  if (!logProxy)
143  {
144  return;
145  }
146 
147  for (unsigned int i = 0; i < LogSender_buffer.size(); ++i)
148  {
149  LogSender_logProxy->writeLog(LogSender_buffer[i]);
150  }
151 
152  LogSender_buffer.clear();
153  }
154 
155  void LogSender::SetComponentName(const std::string& componentName)
156  {
157  std::unique_lock lock(Impl::mutex);
158  LogSender_componentName = componentName;
159  }
160 
161  void LogSender::SetLoggingGroup(const std::string& loggingGroup)
162  {
163  std::unique_lock lock(Impl::mutex);
164  LogSender_loggingGroup = loggingGroup;
165  }
166 
167  LogSender& LogSender::operator<<(const std::chrono::nanoseconds& timestamp)
168  {
169  if (timestamp.count() > 1000)
170  {
171  return *this << std::chrono::duration_cast<std::chrono::microseconds>(timestamp);
172  }
173 
174  currentMessage << timestamp.count() << " ns";
175  return *this;
176  }
177 
178  LogSender& LogSender::operator<<(const std::chrono::microseconds& timestamp)
179  {
180  if (timestamp.count() > 1000)
181  {
182  return *this << std::chrono::duration_cast<std::chrono::milliseconds>(timestamp);
183  }
184 
185  if (timestamp.count() <= 1. / 1000)
186  {
187  return *this << std::chrono::duration_cast<std::chrono::nanoseconds>(timestamp);
188  }
189 
190  currentMessage << timestamp.count() << " µs";
191  return *this;
192  }
193 
194  LogSender& LogSender::operator<<(const std::chrono::milliseconds& timestamp)
195  {
196  if (timestamp.count() > 1000)
197  {
198  return *this << std::chrono::duration_cast<std::chrono::seconds>(timestamp);
199  }
200 
201  if (timestamp.count() <= 1. / 1000)
202  {
203  return *this << std::chrono::duration_cast<std::chrono::microseconds>(timestamp);
204  }
205 
206  currentMessage << timestamp.count() << " ms";
207  return *this;
208  }
209 
210  LogSender& LogSender::operator<<(const std::chrono::seconds& timestamp)
211  {
212  if (timestamp.count() > 60)
213  {
214  return *this << std::chrono::duration_cast<std::chrono::minutes>(timestamp);
215  }
216 
217  if (timestamp.count() <= 1. / 1000)
218  {
219  return *this << std::chrono::duration_cast<std::chrono::milliseconds>(timestamp);
220  }
221 
222  currentMessage << timestamp.count() << " s";
223  return *this;
224  }
225 
226  LogSender& LogSender::operator<<(const std::chrono::minutes& timestamp)
227  {
228  if (timestamp.count() < 1. / 60)
229  {
230  return *this << std::chrono::duration_cast<std::chrono::seconds>(timestamp);
231  }
232 
233  currentMessage << timestamp.count() << " min";
234  return *this;
235  }
236 
238  {
239  double time_count = timestamp.toMicroSecondsDouble();
240  std::string unit = "µs";
241 
242  if (time_count >= 1000)
243  {
244  time_count /= 1000;
245  unit = "ms";
246 
247  if (time_count >= 1000)
248  {
249  time_count /= 1000;
250  unit = "s";
251 
252  if (time_count >= 60)
253  {
254  time_count /= 60;
255  unit = "min";
256 
257  if (time_count >= 60)
258  {
259  time_count /= 60;
260  unit = "h";
261 
262  if (time_count >= 24)
263  {
264  return *this << timestamp.toDateTime();
265  }
266  }
267  }
268  }
269  }
270 
271  return *this << std::to_string(time_count) + " " + unit;
272  }
273 
275  {
276  switch (type)
277  {
278  case eVERBOSE:
279  return LogSender::eBlue;
280  break;
281 
282  case eIMPORTANT:
283  return LogSender::eGreen;
284 
285  case eWARN:
286  return LogSender::eYellow;
287  break;
288 
289  case eERROR:
290  case eFATAL:
291  return LogSender::eRed;
292  break;
293 
294  default:
295  return LogSender::eReset;
296  break;
297  }
298  }
299 
300  std::string LogSender::GetColorCodeString(MessageTypeT verbosityLevel)
301  {
302 
303  ConsoleColor colorCode = GetColorCode((MessageType)verbosityLevel);
304  return GetColorCodeString(colorCode);
305  }
306 
308  {
309  std::stringstream stream;
310 
311  if (colorCode == LogSender::eReset)
312  {
313  stream << "\033[0" << "m";
314  }
315  else
316  {
317  stream << "\033[3" << colorCode << "m";
318  }
319 
320  return stream.str();
321  }
322 
323  void LogSender::resetLocation()
324  {
325  impl->currentFile = "";
326  impl->currentLine = -1;
327  impl->currentFunction = "";
328  }
329 
330  void LogSender::log(MessageTypeT severity, std::string message)
331  {
332  simox::alg::trim(message);
333  if (impl->cancelNextMessage)
334  {
335  impl->cancelNextMessage = false;
336  return;
337  }
338 
340  {
341  return;
342  }
343 
344  if (severity < impl->minimumLoggingLevel)
345  {
346  return;
347  }
348 
349  if (impl->minimumLoggingLevel == MessageTypeT::UNDEFINED
351  )
352  {
353  return;
354  }
355 
356  IceUtil::Time time = IceUtil::Time::now();
357 
358  std::string catStr;
359 
360  if (!impl->currentTag.tagName.empty())
361  {
362  catStr = "[" + impl->currentTag.tagName + "]: ";
363  }
364  else
365  {
366  catStr = "[" + CropFunctionName(impl->currentFunction) + "]: ";
367  }
368 
369  std::string outputStr;
370 
372  {
373  outputStr += GetColorCodeString(severity);
374 
375  if (severity >= MessageTypeT::FATAL)
376  {
377  outputStr += "\033[1m"; // Bold text
378  }
379  }
380 
381  outputStr += "[" + time.toDateTime().substr(time.toDateTime().find(' ') + 1) + "]" + "[" + LogSender_componentName + "]" + catStr;
382 
384  {
385  outputStr += GetColorCodeString(eReset);
386  }
387 
388  outputStr += message;
389 
391  {
393  }
394 
395  LogMessage msg;
396  msg.who = LogSender_componentName;
397  msg.group = LogSender_loggingGroup;
398  msg.time = time.toMicroSeconds();
399  msg.tag = impl->currentTag.tagName;
400  msg.type = (MessageType)severity;
401  msg.what = message;
402  msg.file = impl->currentFile;
403  msg.line = impl->currentLine;
404  msg.function = impl->currentFunction;
405  msg.threadId = impl->threadId ? *impl->threadId : getThreadId();
406 
407  if ((severity >= MessageTypeT::WARN && boost::logic::indeterminate(impl->printBackTrace))
408  || impl->printBackTrace)
409  {
410  msg.backtrace = CreateBackTrace();
411  }
412 
414  {
415  LogSender_logProxy->begin_writeLog(msg); // use async function, so that it returns faster
416  }
417 
418 
419 
420  try
421  {
422  std::unique_lock lock(Impl::mutex); // std::cout is not threadsafe and also lock for inserting into buffer
423 
424  if (severity >= MessageTypeT::ERROR)
425  {
426  LogSender_errbuf << "[" << msg.threadId << "]" << outputStr << std::endl;
427  }
428  else
429  {
430  LogSender_outbuf << "[" << msg.threadId << "]" << outputStr << std::endl;
431  }
432 
433  if (!LogSender_logProxy)
434  {
435  LogSender_buffer.push_back(msg);
436  }
437 
438  resetLocation();
439  }
440  catch (...)
441  {
442  std::cout << outputStr << std::endl;
443  return; // mutex may be deleted already if the system shuts down at this moment
444  }
445  }
446 
448  {
449  return syscall(SYS_gettid);
450  }
451 
453  {
454 #ifdef WIN32
455  return 0;
456 #else
457  return getpid();
458 #endif
459  }
460 
461 
463  {
464 
465  log(impl->currentSeverity, currentMessage.str());
466  currentMessage.str(""); // reset
467  }
468 
469  std::string LogSender::CropFunctionName(std::string const& originalFunctionName)
470  {
471  unsigned int maxLength = 40;
472  std::string result;
473 
474  if (originalFunctionName.length() <= maxLength)
475  {
476  return originalFunctionName;
477  }
478 
479  std::string beforeFunctionName = originalFunctionName.substr(0, originalFunctionName.rfind("::"));
480  std::string::size_type namespaceDotsPos = beforeFunctionName.find("::", beforeFunctionName.find(' '));
481 
482  if (namespaceDotsPos != std::string::npos)
483  {
484  std::string afterClassName = originalFunctionName.substr(originalFunctionName.rfind("::"));
485  result = beforeFunctionName.substr(namespaceDotsPos + 2) + afterClassName;
486  }
487  else
488  {
489  result = originalFunctionName;
490  }
491 
492  if (result.length() <= maxLength)
493  {
494  return result;
495  }
496 
497 
498  result = result.substr(0, result.find("("));
499  result += "(...)";
500 
501  return result;
502 
503 
504 
505  }
506 
507 
508  std::string LogSender::CreateBackTrace(int linesToSkip)
509  {
510  void* callstack[128];
511  const int nMaxFrames = sizeof(callstack) / sizeof(callstack[0]);
512  char buf[1024];
513 
514  int nFrames = ::backtrace(callstack, nMaxFrames);
515  char** symbols = backtrace_symbols(callstack, nFrames);
516 
517  std::ostringstream trace_buf;
518 
519  for (int i = linesToSkip; i < nFrames; i++)
520  {
521  Dl_info info;
522 
523  if (dladdr(callstack[i], &info) && info.dli_sname)
524  {
525  char* demangled = nullptr;
526  int status = -1;
527 
528  if (info.dli_sname[0] == '_')
529  {
530  demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status);
531  }
532 
533  snprintf(buf, sizeof(buf), "%-3d %*p %s + %zd\n",
534  i - linesToSkip + 1, int(2 + sizeof(void*) * 2), callstack[i],
535  status == 0 ? demangled :
536  info.dli_sname == nullptr ? symbols[i] : info.dli_sname,
537  (char*)callstack[i] - (char*)info.dli_saddr);
538  free(demangled);
539  }
540  else
541  {
542  snprintf(buf, sizeof(buf), "%-3d %*p %s\n",
543  i - linesToSkip + 1, int(2 + sizeof(void*) * 2), callstack[i], symbols[i]);
544  }
545 
546  trace_buf << buf;
547  }
548 
549  free(symbols);
550 
551  if (nFrames == nMaxFrames)
552  {
553  trace_buf << "[truncated]\n";
554  }
555 
556  return trace_buf.str();
557  }
558 
560  {
561  return impl->currentSeverity;
562  }
563 
564  LogSenderPtr LogSender::setFile(const std::string& file)
565  {
566  impl->currentFile = file;
567  return shared_from_this();
568  }
569 
571  {
572  impl->currentLine = line;
573  return shared_from_this();
574  }
575 
576  LogSenderPtr LogSender::setFunction(const std::string& function)
577  {
578  impl->currentFunction = function;
579  return shared_from_this();
580  }
581 
583  {
584  impl->minimumLoggingLevel = level;
585  return shared_from_this();
586  }
587 
589  {
590  impl->printBackTrace = printBackTrace;
591  return shared_from_this();
592  }
594  {
595  impl->threadId = tid;
596  return shared_from_this();
597  }
598 
600  {
601  impl->currentTag = tag;
602  return shared_from_this();
603  }
604 
605  //LogSenderPtr LogSender::setSpamFilter(SpamFilterMapPtr spamFilter)
606  //{
607  // this->spamFilter = spamFilter;
608  // return shared_from_this();
609  //}
610 
612  {
613  switch (type)
614  {
615  case MessageTypeT::DEBUG:
616  return "Debug";
617 
619  return "Verbose";
620 
621  case MessageTypeT::INFO:
622  return "Info";
623 
625  return "Important";
626 
627  case MessageTypeT::WARN:
628  return "Warning";
629 
630  case MessageTypeT::ERROR:
631  return "Error";
632 
633  case MessageTypeT::FATAL:
634  return "Fatal";
635 
636  default:
637  return "Undefined";
638  }
639  }
640 
641  MessageTypeT LogSender::StringToLevel(const std::string& typeStr)
642  {
643  if (simox::alg::to_lower(typeStr) == "debug")
644  {
645  return MessageTypeT::DEBUG;
646  }
647 
648  if (simox::alg::to_lower(typeStr) == "verbose")
649  {
650  return MessageTypeT::VERBOSE;
651  }
652 
653  if (simox::alg::to_lower(typeStr) == "important")
654  {
656  }
657 
658  if (simox::alg::to_lower(typeStr) == "warning")
659  {
660  return MessageTypeT::WARN;
661  }
662 
663  if (simox::alg::to_lower(typeStr) == "error")
664  {
665  return MessageTypeT::ERROR;
666  }
667 
668  if (simox::alg::to_lower(typeStr) == "fatal")
669  {
670  return MessageTypeT::FATAL;
671  }
672 
674 
675  }
676 
678  {
680  {
681  return;
682  }
683 
685  std::cout << "setting global logging level to " << LogSender::levelToString(level) << std::endl;
686  }
687 
689  {
691  }
692 
693 
694  void LogSender::SetLoggingActivated(bool activated, bool showMessage)
695  {
696  if (LogSender_LoggingActivated && showMessage && !activated)
697  {
698  std::cout << "logging is now DEACTIVATED" << std::endl;
699  }
700 
701  if (activated && LogSender_LoggingActivated != activated && showMessage)
702  {
703  std::cout << "logging is now ACTIVATED" << std::endl;
704  }
705  LogSender_LoggingActivated = activated;
706  }
707 
709  {
710  LogSender_SendLogging = activated;
711  }
712 
714  {
715  LogSender_ColoringActivated = activated;
716  }
717 
718  void LogSender::initConsole()
719  {
720  static bool initialized = false;
721 
722  if (!initialized)
723  {
724  initialized = true;
725  char* termType = getenv("TERM");
726 
727  if (termType != nullptr)
728  {
729  std::string termTypeStr(termType);
730 
731  if (termTypeStr != "xterm"
732  && termTypeStr != "emacs"
733  && termTypeStr != "xterm-256color")
734  {
736  }
737  }
738  else
739  {
741  }
742 
743  }
744  }
745 
746  template<>
747  ARMARXCORE_IMPORT_EXPORT LogSender& LogSender::operator<< <LogSender::ConsoleColor>(const LogSender::ConsoleColor& colorCode)
748  {
749  currentMessage << LogSender::GetColorCodeString(colorCode);
750 
751  return *this;
752  }
753 
754 
755 
756 
757  template<>
758  LogSender& LogSender::operator<< <MessageTypeT>(const MessageTypeT& severity)
759  {
760  impl->currentSeverity = severity;
761 
762  return *this;
763  }
764 
765  template<>
766  LogSender& LogSender::operator<< <LogTag>(const LogTag& tag)
767  {
768  impl->currentTag = tag;
769 
770  return *this;
771  }
772 
773  template<>
774  LogSender& LogSender::operator<< <LogSender::manipulator>(const manipulator& manipulator)
775  {
776  (this->*manipulator)();
777 
778  return *this;
779  }
780 
781  LogSender& LogSender::operator<< (const StandardEndLine& manipulator)
782  {
783  flush();
784 
785  return *this;
786  }
787 
788  template<>
789  LogSender& LogSender::operator<< <bool>(const bool& duality)
790  {
791  if (duality)
792  {
793  currentMessage << "true";
794  }
795  else
796  {
797  currentMessage << "false";
798  }
799 
800  return *this;
801  }
802 
803  template<>
804  LogSender& LogSender::operator<< <SpamFilterDataPtr>(const SpamFilterDataPtr& spamFilterData)
805  {
806  if (!spamFilterData)
807  {
808  return *this;
809  }
810 
811  std::unique_lock lock(*spamFilterData->mutex);
812  float deactivationDurationSec = spamFilterData->durationSec;
813  SpamFilterMapPtr spamFilter = spamFilterData->filterMap;
814  std::string id = impl->currentFile + ":" + to_string(impl->currentLine);
815  auto it = spamFilter->find(spamFilterData->identifier);
816 
817  if (it != spamFilter->end())
818  {
819  auto itSub = it->second.find(id);
820  IceUtil::Time durationEnd = IceUtil::Time::now() + IceUtil::Time::milliSecondsDouble(deactivationDurationSec * 1000);
821 
822  if (itSub == it->second.end())
823  {
824  itSub = it->second.insert(
825  std::make_pair(
826  id,
827  durationEnd)).first;
828  impl->cancelNextMessage = false;
829  }
830  else if (IceUtil::Time::now() < itSub->second)
831  {
832  impl->cancelNextMessage = true;
833  }
834  else
835  {
836  impl->cancelNextMessage = false;
837  itSub->second = durationEnd;
838  }
839  }
840 
841  return *this;
842  }
843 }
armarx::MessageTypeT::ERROR
@ ERROR
armarx::MessageTypeT
MessageTypeT
Definition: LogSender.h:45
armarx::GetColorCode
LogSender::ConsoleColor GetColorCode(MessageType type)
Definition: LogSender.cpp:274
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:300
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:677
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:599
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:469
armarx::LogSender::getThreadId
static long getThreadId()
Definition: LogSender.cpp:447
armarx::LogSender::setThreadId
LogSenderPtr setThreadId(Ice::Int tid)
Definition: LogSender.cpp:593
armarx::LogSender::Impl
Definition: LogSender.cpp:47
armarx::LogSender::SetSendLoggingActivated
static void SetSendLoggingActivated(bool activated=true)
Definition: LogSender.cpp:708
armarx::LogSender::~LogSender
~LogSender()
Definition: LogSender.cpp:127
armarx::MessageTypeT::IMPORTANT
@ IMPORTANT
armarx::LogSender::GetGlobalMinimumLoggingLevel
static MessageTypeT GetGlobalMinimumLoggingLevel()
Definition: LogSender.cpp:688
armarx::LogSender::SetLoggingGroup
static void SetLoggingGroup(const std::string &loggingGroup)
Definition: LogSender.cpp:161
message
message(STATUS "Boost-Library-Dir: " "${Boost_LIBRARY_DIRS}") message(STATUS "Boost-LIBRARIES
Definition: CMakeLists.txt:8
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:582
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:559
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:588
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:100
armarx::LogSender::setFile
LogSenderPtr setFile(const std::string &file)
Set the source code filename associated with this message.
Definition: LogSender.cpp:564
armarx::LogSender::log
void log(MessageTypeT severity, std::string message)
Sends a message to the logging component.
Definition: LogSender.cpp:330
armarx::LogSender::Impl::currentTag
LogTag currentTag
Definition: LogSender.cpp:60
armarx::LogSender::CreateBackTrace
static std::string CreateBackTrace(int linesToSkip=1)
Definition: LogSender.cpp:508
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:452
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:694
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:136
armarx::LogSender::flush
void flush()
Sends the current message to the log and resets the content.
Definition: LogSender.cpp:462
armarx::LogSender::SetComponentName
static void SetComponentName(const std::string &componentName)
Definition: LogSender.cpp:155
LogSender.h
IceInternal::ProxyHandle< ::IceProxy::armarx::Log >
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:570
armarx::LogSender::StringToLevel
static MessageTypeT StringToLevel(const std::string &typeStr)
stringToLevel converts a string into a LoggingLevel, if possible.
Definition: LogSender.cpp:641
armarx::LogSender::SetColoredConsoleActivated
static void SetColoredConsoleActivated(bool activated=true)
Definition: LogSender.cpp:713
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:576
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:611