Orocos Real-Time Toolkit  2.9.0
Logger.inl
Go to the documentation of this file.
1 #ifndef ORO_CORELIB_LOGGER_INL
2 #define ORO_CORELIB_LOGGER_INL
3 
12 namespace RTT
13 {
14  template< class T>
15  Logger& Logger::operator<<( const T &t ) {
16 #ifndef OROBLD_DISABLE_LOGGING
17  if ( !mayLog() )
18  return *this;
19 
20  os::MutexLock lock( inpguard );
21  if ( this->mayLogStdOut() )
22  logline << t;
23 
24 #if defined(OROSEM_FILE_LOGGING) || defined(OROSEM_REMOTE_LOGGING)
25  // log Info or better to log file, even if not started.
26  if ( this->mayLogFile() )
27  fileline << t;
28 #endif
29 #endif
30  return *this;
31  }
32 
33 #ifdef OROBLD_DISABLE_LOGGING
34 
35  // instance will be actually null
36  inline Logger& Logger::log() {
37  return *_instance;
38  }
39 
40  inline Logger& Logger::log(LogLevel) {
41  return *_instance;
42  }
43 
44  inline bool Logger::mayLog() const {
45  return false;
46  }
47 
48  inline void Logger::mayLogStdOut(bool ) {
49  }
50 
51  inline void Logger::mayLogFile(bool ) {
52  }
53 
54  inline void Logger::allowRealTime() {
55  }
56 
57  inline void Logger::disallowRealTime() {
58  }
59 
60  inline std::ostream&
61  Logger::nl(std::ostream& __os)
62  {
63  return __os;
64  }
65 
66  inline std::ostream&
67  Logger::endl(std::ostream& __os)
68  {
69  return __os;
70  }
71 
72  inline std::ostream&
73  Logger::flush(std::ostream& __os)
74  {
75  return __os;
76  }
77 
78 
79  inline Logger::In::In(const std::string&)
80  {
81  }
82 
83  inline Logger::In::~In()
84  {
85  }
86 
87  inline Logger& Logger::in(const std::string&)
88  {
89  return *this;
90  }
91 
92  inline Logger& Logger::out(const std::string&)
93  {
94  return *this;
95  }
96 
97  inline std::string Logger::getLogModule() const {
98  return "";
99  }
100 
101  inline void Logger::startup() {
102  }
103 
104  inline void Logger::shutdown() {
105  }
106 
107  inline std::string Logger::getLogLine() {
108  return "";
109  }
110 
111  inline void Logger::setStdStream( std::ostream& ) {
112  }
113 
114  inline Logger& Logger::operator<<( const std::string& ) {
115  return *this;
116  }
117 
119  return *this;
120  }
121 
122  inline Logger& Logger::operator<<(std::ostream& (*pf)(std::ostream&))
123  {
124  return *this;
125  }
126 
127  inline void Logger::logflush() {
128  }
129 
130  inline void Logger::lognl() {
131  }
132 
133  inline void Logger::logendl() {
134  }
135 
136  inline void Logger::setLogLevel( LogLevel ) {
137  }
138 
139  inline Logger::LogLevel Logger::getLogLevel() const {
140  return Never;
141  }
142 #endif
143 
144 }
145 
146 #endif
Logger & out(const std::string &modname)
The counterpart of in().
Definition: Logger.cpp:423
std::string getLogModule() const
Get the name of the current Log generating Module.
Definition: Logger.cpp:432
LogLevel getLogLevel() const
Return the current output loglevel.
Definition: Logger.cpp:613
void shutdown()
Print a &#39;goodbye&#39; string in Info, Flush all streams and stop Logging.
Definition: Logger.cpp:494
static std::ostream & nl(std::ostream &__os)
Insert a newline &#39; &#39; in the ostream.
Definition: Logger.cpp:373
Logger & operator<<(const T &t)
Send (user defined) data into this logger.
Definition: Logger.inl:15
void logflush()
Flush log buffers.
Definition: Logger.cpp:573
A simple logging class to debug/ analyse what is going on in the Orocos system.
Definition: Logger.hpp:95
void mayLogFile(bool tf)
Toggles the flag if the logger may log to the file stream.
Definition: Logger.cpp:353
void startup()
Print a &#39;welcome&#39; string in Info and reset log timestamp.
Definition: Logger.cpp:444
std::string getLogLine()
This method gets all messages upto level Info and can be freely read by the user, removing the line f...
Definition: Logger.cpp:502
void disallowRealTime()
Disallow messages of the LogLevel &#39;RealTime&#39; to appear on the console.
Definition: Logger.cpp:362
void mayLogStdOut(bool tf)
Toggles the flag if the logger may log to the standard output stream.
Definition: Logger.cpp:349
static std::ostream & flush(std::ostream &__os)
Flush the output stream.
Definition: Logger.cpp:393
static std::ostream & endl(std::ostream &__os)
Definition: Logger.cpp:383
void lognl()
Add newline without flushing buffers.
Definition: Logger.cpp:594
In(const std::string &module)
Definition: Logger.cpp:403
LogLevel
Enumerate all log-levels from absolute silence to everything.
Definition: Logger.hpp:121
static Logger & log()
As Instance(), but more userfriendly.
Definition: Logger.cpp:117
void allowRealTime()
Allow messages of the LogLevel &#39;RealTime&#39; to appear on the console.
Definition: Logger.cpp:357
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:52
void setStdStream(std::ostream &stdos)
Set the standard output stream.
Definition: Logger.cpp:518
void logendl()
Add endl and flush buffers.
Definition: Logger.cpp:600
Logger & in(const std::string &modname)
Inform the Logger of the entry of a module.
Definition: Logger.cpp:414
void setLogLevel(LogLevel ll)
Set the loglevel of the outgoing (streamed) messages.
Definition: Logger.cpp:606
MutexLock is a scope based Monitor, protecting critical sections with a Mutex object through locking ...
Definition: MutexLock.hpp:51