RTI Routing Service Version 7.3.0
Logger.hpp
1/*
2 * (c) Copyright, Real-Time Innovations, 2017.
3 * All rights reserved.
4 *
5 * No duplications, whole or partial, manual or electronic, may be made
6 * without express written permission. Any such copies, or
7 * revisions thereof, must display this notice unaltered.
8 * This code contains trade secrets of Real-Time Innovations, Inc.
9 */
10
11#ifndef RTI_ROUTING_LOGGER_HPP_
12#define RTI_ROUTING_LOGGER_HPP_
13
14#include <dds/core/Reference.hpp>
15#include <rti/config/Logger.hpp>
16
17#include "routingservice/routingservice_log.h"
18#include "routingservice/routingservice_service.h"
19
20namespace rti { namespace routing {
21
22
30class Logger
31{
32public:
33
34 typedef rti::config::Verbosity Verbosity;
35 typedef rti::config::LogCategory LogCategory;
36 typedef rti::config::LoggerMode LoggerMode;
37 typedef rti::config::PrintFormat PrintFormat;
38
39 static Logger& instance()
40 {
41 static Logger singleton;
42 return singleton;
43 }
44
52 void service_verbosity(rti::config::Verbosity verbosity)
53 {
54 NDDS_Config_Logger_set_verbosity_by_service(
55 NDDS_Config_Logger_get_instance(),
56 NDDS_CONFIG_LOG_SERVICE_ROUTING,
57 static_cast<NDDS_Config_LogVerbosity>(verbosity.underlying()));
58 }
59
65 rti::config::Verbosity service_verbosity()
66 {
67 RTILogBitmap instrumentation_mask =
68 NDDS_Config_Logger_get_verbosity_by_service(
69 NDDS_Config_Logger_get_instance(),
70 NDDS_CONFIG_LOG_SERVICE_ROUTING);
71
72 return static_cast<rti::config::Verbosity::type>(instrumentation_mask);
73 }
74
87 void error(const std::string& msg)
88 {
89 this->error(msg.c_str());
90 }
91
95 void error(const char *msg)
96 {
97 this->message(rti::config::LogLevel::EXCEPTION, msg);
98 }
99
111 void warn(const std::string& msg)
112 {
113 this->warn(msg.c_str());
114 }
115
119 void warn(const char *msg)
120 {
121 this->message(rti::config::LogLevel::WARNING, msg);
122 }
123
135 void local(const std::string& msg)
136 {
137 this->local(msg.c_str());
138 }
139
143 void local(const char *msg)
144 {
145 this->message(rti::config::LogLevel::STATUS_LOCAL, msg);
146 }
147
159 void remote(const std::string& msg)
160 {
161 this->remote(msg.c_str());
162 }
163
167 void remote(const char *msg)
168 {
169 this->message(rti::config::LogLevel::STATUS_REMOTE, msg);
170 }
171
183 void debug(const std::string& msg)
184 {
185 this->debug(msg.c_str());
186 }
187
191 void debug(const char *msg)
192 {
193 this->message(rti::config::LogLevel::STATUS_ALL, msg);
194 }
195
196 virtual ~Logger()
197 {
198 }
199
200private:
201
202 void message(const rti::config::LogLevel& level, const char* msg)
203 {
204 RTI_RoutingServiceLogger_log(
205 static_cast<NDDS_Config_LogLevel> (level.underlying()),
206 "%s",
207 msg);
208 }
209
210 Logger()
211 {
212 }
213 // Disable copy
214 Logger(const Logger&);
215 Logger& operator=(const Logger&);
216};
217
218}}
219
220#endif // RTI_ROUTING_LOGGER_HPP_
The singleton type used to configure RTI Routing Service verbosity.
Definition: Logger.hpp:31
void warn(const char *msg)
overload of warn(const std::string& msg)
Definition: Logger.hpp:119
void warn(const std::string &msg)
Logs as message with WARNING level.
Definition: Logger.hpp:111
void debug(const std::string &msg)
Logs as message with WARNING level.
Definition: Logger.hpp:183
void error(const char *msg)
overload of error(const std::string& msg)
Definition: Logger.hpp:95
void debug(const char *msg)
overload of debug(const std::string& msg)
Definition: Logger.hpp:191
void error(const std::string &msg)
Logs as message with EXCEPTION level.
Definition: Logger.hpp:87
void remote(const char *msg)
overload of remote(const std::string& msg)
Definition: Logger.hpp:167
rti::config::Verbosity service_verbosity()
Getter for the same attribute.
Definition: Logger.hpp:65
void service_verbosity(rti::config::Verbosity verbosity)
Sets the verbosity for the log messages generated at the RTI Routing Service level.
Definition: Logger.hpp:52
void local(const char *msg)
overload of local(const std::string& msg)
Definition: Logger.hpp:143
void remote(const std::string &msg)
Logs as message with WARNING level.
Definition: Logger.hpp:159
void local(const std::string &msg)
Logs as message with WARNING level.
Definition: Logger.hpp:135