Skip to content

Commit 2002205

Browse files
author
urmahp
committed
Renamed the log macros to more specific names.
This makes it less likely that the log macros with have same name as log macros in the application where this library is used.
1 parent 94db721 commit 2002205

File tree

16 files changed

+81
-81
lines changed

16 files changed

+81
-81
lines changed

include/ur_client_library/comm/bin_parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class BinParser
368368
*/
369369
void debug()
370370
{
371-
LOG_DEBUG("BinParser: %p - %p (%zu bytes)", buf_pos_, buf_end_, buf_end_ - buf_pos_);
371+
URCL_LOG_DEBUG("BinParser: %p - %p (%zu bytes)", buf_pos_, buf_end_, buf_end_ - buf_pos_);
372372
}
373373
};
374374

include/ur_client_library/comm/pipeline.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class Pipeline
267267
*/
268268
virtual ~Pipeline()
269269
{
270-
LOG_DEBUG("Destructing pipeline");
270+
URCL_LOG_DEBUG("Destructing pipeline");
271271
stop();
272272
}
273273

@@ -302,7 +302,7 @@ class Pipeline
302302
if (!running_)
303303
return;
304304

305-
LOG_DEBUG("Stopping pipeline! <%s>", name_.c_str());
305+
URCL_LOG_DEBUG("Stopping pipeline! <%s>", name_.c_str());
306306

307307
running_ = false;
308308

@@ -342,7 +342,7 @@ class Pipeline
342342

343343
void runProducer()
344344
{
345-
LOG_DEBUG("Starting up producer");
345+
URCL_LOG_DEBUG("Starting up producer");
346346
std::ifstream realtime_file("/sys/kernel/realtime", std::ios::in);
347347
bool has_realtime;
348348
realtime_file >> has_realtime;
@@ -363,7 +363,7 @@ class Pipeline
363363
int ret = pthread_setschedparam(this_thread, SCHED_FIFO, &params);
364364
if (ret != 0)
365365
{
366-
LOG_ERROR("Unsuccessful in setting producer thread realtime priority. Error code: %d", ret);
366+
URCL_LOG_ERROR("Unsuccessful in setting producer thread realtime priority. Error code: %d", ret);
367367
}
368368
// Now verify the change in thread priority
369369
int policy = 0;
@@ -376,24 +376,24 @@ class Pipeline
376376
// Check the correct policy was applied
377377
if (policy != SCHED_FIFO)
378378
{
379-
LOG_ERROR("Producer thread: Scheduling is NOT SCHED_FIFO!");
379+
URCL_LOG_ERROR("Producer thread: Scheduling is NOT SCHED_FIFO!");
380380
}
381381
else
382382
{
383-
LOG_INFO("Producer thread: SCHED_FIFO OK");
383+
URCL_LOG_INFO("Producer thread: SCHED_FIFO OK");
384384
}
385385

386386
// Print thread scheduling priority
387-
LOG_INFO("Thread priority is %d", params.sched_priority);
387+
URCL_LOG_INFO("Thread priority is %d", params.sched_priority);
388388
}
389389
else
390390
{
391-
LOG_ERROR("Could not get maximum thread priority for producer thread");
391+
URCL_LOG_ERROR("Could not get maximum thread priority for producer thread");
392392
}
393393
}
394394
else
395395
{
396-
LOG_WARN("No realtime capabilities found. Consider using a realtime system for better performance");
396+
URCL_LOG_WARN("No realtime capabilities found. Consider using a realtime system for better performance");
397397
}
398398
std::vector<std::unique_ptr<T>> products;
399399
while (running_)
@@ -409,13 +409,13 @@ class Pipeline
409409
{
410410
if (!queue_.tryEnqueue(std::move(p)))
411411
{
412-
LOG_ERROR("Pipeline producer overflowed! <%s>", name_.c_str());
412+
URCL_LOG_ERROR("Pipeline producer overflowed! <%s>", name_.c_str());
413413
}
414414
}
415415

416416
products.clear();
417417
}
418-
LOG_DEBUG("Pipeline producer ended! <%s>", name_.c_str());
418+
URCL_LOG_DEBUG("Pipeline producer ended! <%s>", name_.c_str());
419419
notifier_.stopped(name_);
420420
}
421421

@@ -442,7 +442,7 @@ class Pipeline
442442
}
443443
}
444444
consumer_->stopConsumer();
445-
LOG_DEBUG("Pipeline consumer ended! <%s>", name_.c_str());
445+
URCL_LOG_DEBUG("Pipeline consumer ended! <%s>", name_.c_str());
446446
notifier_.stopped(name_);
447447
}
448448
};

include/ur_client_library/comm/producer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class URProducer : public IProducer<T>
122122
if (stream_.closed())
123123
return false;
124124

125-
LOG_WARN("Failed to read from stream, reconnecting in %ld seconds...", timeout_.count());
125+
URCL_LOG_WARN("Failed to read from stream, reconnecting in %ld seconds...", timeout_.count());
126126
std::this_thread::sleep_for(timeout_);
127127

128128
if (stream_.connect())

include/ur_client_library/comm/script_sender.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class ScriptSender
8383
}
8484
if (requestRead())
8585
{
86-
LOG_INFO("Robot requested program");
86+
URCL_LOG_INFO("Robot requested program");
8787
sendProgram();
8888
}
8989
server_.disconnectClient();
@@ -105,12 +105,12 @@ class ScriptSender
105105
}
106106
else
107107
{
108-
LOG_WARN("Received unexpected message on script request port ");
108+
URCL_LOG_WARN("Received unexpected message on script request port ");
109109
}
110110
}
111111
else
112112
{
113-
LOG_WARN("Could not read on script request port");
113+
URCL_LOG_WARN("Could not read on script request port");
114114
}
115115
return false;
116116
}
@@ -123,11 +123,11 @@ class ScriptSender
123123

124124
if (server_.write(data, len, written))
125125
{
126-
LOG_INFO("Sent program to robot");
126+
URCL_LOG_INFO("Sent program to robot");
127127
}
128128
else
129129
{
130-
LOG_ERROR("Could not send program to robot");
130+
URCL_LOG_ERROR("Could not send program to robot");
131131
}
132132
}
133133
};

include/ur_client_library/comm/shell_consumer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ShellConsumer : public IConsumer<T>
5858
*/
5959
virtual bool consume(std::shared_ptr<T> product)
6060
{
61-
LOG_INFO("%s", product->toString().c_str());
61+
URCL_LOG_INFO("%s", product->toString().c_str());
6262
return true;
6363
}
6464

include/ur_client_library/comm/stream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class URStream : public TCPSocket
6868
*/
6969
void disconnect()
7070
{
71-
LOG_DEBUG("Disconnecting from %s:%d", host_.c_str(), port_);
71+
URCL_LOG_DEBUG("Disconnecting from %s:%d", host_.c_str(), port_);
7272
TCPSocket::close();
7373
}
7474

@@ -141,7 +141,7 @@ bool URStream<T>::read(uint8_t* buf, const size_t buf_len, size_t& total)
141141
remainder = T::HeaderType::getPackageLength(buf);
142142
if (remainder >= (buf_len - sizeof(typename T::HeaderType::_package_size_type)))
143143
{
144-
LOG_ERROR("Packet size %zd is larger than buffer %zu, discarding.", remainder, buf_len);
144+
URCL_LOG_ERROR("Packet size %zd is larger than buffer %zu, discarding.", remainder, buf_len);
145145
return false;
146146
}
147147
initial = false;

include/ur_client_library/log.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@
2222
#ifdef ROS_BUILD
2323
#include <console_bridge/console.h>
2424

25-
#define LOG_DEBUG CONSOLE_BRIDGE_logDebug
26-
#define LOG_WARN CONSOLE_BRIDGE_logWarn
27-
#define LOG_INFO CONSOLE_BRIDGE_logInform
28-
#define LOG_ERROR CONSOLE_BRIDGE_logError
29-
#define LOG_FATAL CONSOLE_BRIDGE_logError
25+
#define URCL_LOG_DEBUG CONSOLE_BRIDGE_logDebug
26+
#define URCL_LOG_WARN CONSOLE_BRIDGE_logWarn
27+
#define URCL_LOG_INFO CONSOLE_BRIDGE_logInform
28+
#define URCL_LOG_ERROR CONSOLE_BRIDGE_logError
29+
#define URCL_LOG_FATAL CONSOLE_BRIDGE_logError
3030

3131
#else
3232

33-
#define LOG_DEBUG(format, ...) printf("[DEBUG]: " format "\n", ##__VA_ARGS__)
34-
#define LOG_WARN(format, ...) printf("[WARNING]: " format "\n", ##__VA_ARGS__)
35-
#define LOG_INFO(format, ...) printf("[INFO]: " format "\n", ##__VA_ARGS__)
36-
#define LOG_ERROR(format, ...) printf("[ERROR]: " format "\n", ##__VA_ARGS__)
37-
#define LOG_FATAL(format, ...) printf("[FATAL]: " format "\n", ##__VA_ARGS__)
33+
#define URCL_LOG_DEBUG(format, ...) printf("[DEBUG]: " format "\n", ##__VA_ARGS__)
34+
#define URCL_LOG_WARN(format, ...) printf("[WARNING]: " format "\n", ##__VA_ARGS__)
35+
#define URCL_LOG_INFO(format, ...) printf("[INFO]: " format "\n", ##__VA_ARGS__)
36+
#define URCL_LOG_ERROR(format, ...) printf("[ERROR]: " format "\n", ##__VA_ARGS__)
37+
#define URCL_LOG_FATAL(format, ...) printf("[FATAL]: " format "\n", ##__VA_ARGS__)
3838

3939
#endif

include/ur_client_library/primary/primary_parser.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ class PrimaryParser : public comm::Parser<PrimaryPackage>
6767
{
6868
if (!bp.checkSize(sizeof(uint32_t)))
6969
{
70-
LOG_ERROR("Failed to read sub-package length, there's likely a parsing error");
70+
URCL_LOG_ERROR("Failed to read sub-package length, there's likely a parsing error");
7171
return false;
7272
}
7373
uint32_t sub_size = bp.peek<uint32_t>();
7474
if (!bp.checkSize(static_cast<size_t>(sub_size)))
7575
{
76-
LOG_WARN("Invalid sub-package size of %" PRIu32 " received!", sub_size);
76+
URCL_LOG_WARN("Invalid sub-package size of %" PRIu32 " received!", sub_size);
7777
return false;
7878
}
7979

@@ -95,15 +95,15 @@ class PrimaryParser : public comm::Parser<PrimaryPackage>
9595

9696
if (!packet->parseWith(sbp))
9797
{
98-
LOG_ERROR("Sub-package parsing of type %d failed!", static_cast<int>(type));
98+
URCL_LOG_ERROR("Sub-package parsing of type %d failed!", static_cast<int>(type));
9999
return false;
100100
}
101101

102102
results.push_back(std::move(packet));
103103

104104
if (!sbp.empty())
105105
{
106-
LOG_ERROR("Sub-package of type %d was not parsed completely!", static_cast<int>(type));
106+
URCL_LOG_ERROR("Sub-package of type %d was not parsed completely!", static_cast<int>(type));
107107
sbp.debug();
108108
return false;
109109
}
@@ -125,7 +125,7 @@ class PrimaryParser : public comm::Parser<PrimaryPackage>
125125
std::unique_ptr<PrimaryPackage> packet(messageFromType(message_type, timestamp, source));
126126
if (!packet->parseWith(bp))
127127
{
128-
LOG_ERROR("Package parsing of type %d failed!", static_cast<int>(message_type));
128+
URCL_LOG_ERROR("Package parsing of type %d failed!", static_cast<int>(message_type));
129129
return false;
130130
}
131131

@@ -136,7 +136,7 @@ class PrimaryParser : public comm::Parser<PrimaryPackage>
136136

137137
default:
138138
{
139-
LOG_DEBUG("Invalid robot package type recieved: %u", static_cast<uint8_t>(type));
139+
URCL_LOG_DEBUG("Invalid robot package type recieved: %u", static_cast<uint8_t>(type));
140140
bp.consume();
141141
return true;
142142
}

include/ur_client_library/rtde/rtde_parser.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class RTDEParser : public comm::Parser<RTDEPackage>
7575

7676
if (!bp.checkSize(size - sizeof(size) - sizeof(type)))
7777
{
78-
LOG_ERROR("Buffer len shorter than expected packet length");
78+
URCL_LOG_ERROR("Buffer len shorter than expected packet length");
7979
return false;
8080
}
8181

@@ -87,7 +87,7 @@ class RTDEParser : public comm::Parser<RTDEPackage>
8787

8888
if (!package->parseWith(bp))
8989
{
90-
LOG_ERROR("Package parsing of type %d failed!", static_cast<int>(type));
90+
URCL_LOG_ERROR("Package parsing of type %d failed!", static_cast<int>(type));
9191
return false;
9292
}
9393
results.push_back(std::move(package));
@@ -98,7 +98,7 @@ class RTDEParser : public comm::Parser<RTDEPackage>
9898
std::unique_ptr<RTDEPackage> package(packageFromType(type));
9999
if (!package->parseWith(bp))
100100
{
101-
LOG_ERROR("Package parsing of type %d failed!", static_cast<int>(type));
101+
URCL_LOG_ERROR("Package parsing of type %d failed!", static_cast<int>(type));
102102
return false;
103103
}
104104

@@ -108,7 +108,7 @@ class RTDEParser : public comm::Parser<RTDEPackage>
108108
}
109109
if (!bp.empty())
110110
{
111-
LOG_ERROR("Package of type %d was not parsed completely!", static_cast<int>(type));
111+
URCL_LOG_ERROR("Package of type %d was not parsed completely!", static_cast<int>(type));
112112
bp.debug();
113113
return false;
114114
}

src/comm/server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ std::string URServer::getIP()
4848

4949
if (res < 0)
5050
{
51-
LOG_ERROR("Could not get local IP");
51+
URCL_LOG_ERROR("Could not get local IP");
5252
return std::string();
5353
}
5454

@@ -90,7 +90,7 @@ bool URServer::accept()
9090
int retry = 0;
9191
while ((client_fd = ::accept(getSocketFD(), &addr, &addr_len)) == -1)
9292
{
93-
LOG_ERROR("Accepting socket connection failed. (errno: %d)", errno);
93+
URCL_LOG_ERROR("Accepting socket connection failed. (errno: %d)", errno);
9494
if (retry++ >= 5)
9595
return false;
9696
}

0 commit comments

Comments
 (0)