OrocosComponentLibrary  2.8.3
LoggingEvent.cpp
1 #include "LoggingEvent.hpp"
2 #include <log4cpp/Priority.hh>
3 #include <log4cpp/threading/Threading.hh>
4 #include <cstdio>
5 
6 using namespace RTT;
7 
8 namespace OCL {
9 namespace logging {
10 
11 LoggingEvent::LoggingEvent() :
12  categoryName(""),
13  message(""),
14  ndc(""),
15  priority(log4cpp::Priority::NOTSET),
16  threadName(""),
17  timeStamp()
18 {
19 }
20 
22  categoryName(toCopy.categoryName),
23  message(toCopy.message),
24  ndc(toCopy.ndc),
25  priority(toCopy.priority),
26  threadName(toCopy.threadName),
27  timeStamp(toCopy.timeStamp)
28 {
29 }
30 
31 LoggingEvent::LoggingEvent(const rt_string& categoryName,
32  const rt_string& message,
33  const rt_string& ndc,
34  log4cpp::Priority::Value priority) :
35  categoryName(categoryName),
36  message(message),
37  ndc(ndc),
38  priority(priority),
39  threadName(""),
40  timeStamp()
41 {
42  char buffer[16];
43  threadName = log4cpp::threading::getThreadId(&buffer[0]);
44 }
45 
46 const LoggingEvent& LoggingEvent::operator=(const LoggingEvent& rhs)
47 {
48  if (&rhs != this) // prevent self-copy
49  {
50  categoryName = rhs.categoryName;
51  message = rhs.message;
52  ndc = rhs.ndc;
53  priority = rhs.priority;
54  threadName = rhs.threadName;
55  timeStamp = rhs.timeStamp;
56  }
57  return *this;
58 }
59 
60 LoggingEvent::~LoggingEvent()
61 {
62 }
63 
64 log4cpp::LoggingEvent LoggingEvent::toLog4cpp()
65 {
66  return log4cpp::LoggingEvent(makeString(this->categoryName),
67  makeString(this->message),
68  makeString(this->ndc),
69  this->priority,
70  makeString(this->threadName),
71  this->timeStamp);
72 }
73 
74 
75 // namespaces
76 }
77 }
A mirror of log4cpp::LoggingEvent, except using real-time capable strings.
The Orocos Component Library.
Definition: Component.hpp:43
Definition: Category.hpp:10
log4cpp::LoggingEvent toLog4cpp()
Convert to log4cpp class.
LoggingEvent()
Create with empty values.