Skip to content

Commit

Permalink
Change macro parameter name
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com>
  • Loading branch information
BMarchi committed Oct 2, 2019
1 parent 77d0072 commit e1b4344
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions include/rcutils/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ extern "C"
#define RCUTILS_NS_TO_MS(nanoseconds) (nanoseconds / (1000LL * 1000LL))
/// Convenience macro to convert nanoseconds to microseconds.
#define RCUTILS_NS_TO_US(nanoseconds) (nanoseconds / 1000LL)
/// Convenience macro to reference the function for system time.
#define RCUTILS_STEADY_TIME rcutils_steady_time_now

/// A single point in time, measured in nanoseconds since the Unix epoch.
typedef int64_t rcutils_time_point_value_t;
Expand Down
4 changes: 2 additions & 2 deletions rcutils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@
skipfirst_doc_lines = [
'The first log call is being ignored but all subsequent calls are being processed.']
throttle_params = OrderedDict((
('time_source_type', 'Function that returns rcutils_ret_t and expects a '
('time_source', 'Function that returns rcutils_ret_t and expects a '
'rcutils_time_point_value_t pointer.'),
('duration', 'The duration of the throttle interval'),
))
throttle_args = {
'condition_before': 'RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration)',
'condition_before': 'RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source, duration)',
'condition_after': 'RCUTILS_LOG_CONDITION_THROTTLE_AFTER'}
throttle_doc_lines = [
'Log calls are being ignored if the last logged message is not longer ago than the specified '
Expand Down
4 changes: 2 additions & 2 deletions resource/logging_macros.h.em
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ typedef bool (* RclLogFilter)();
* \def RCUTILS_LOG_CONDITION_THROTTLE_BEFORE
* A macro initializing and checking the `throttle` condition.
*/
#define RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) { \
#define RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source, duration) { \
static rcutils_duration_value_t __rcutils_logging_duration = RCUTILS_MS_TO_NS((rcutils_duration_value_t)duration); \
static rcutils_time_point_value_t __rcutils_logging_last_logged = 0; \
rcutils_time_point_value_t __rcutils_logging_now = 0; \
bool __rcutils_logging_condition = true; \
if (time_source_type(&__rcutils_logging_now) != RCUTILS_RET_OK) { \
if (time_source(&__rcutils_logging_now) != RCUTILS_RET_OK) { \
rcutils_log( \
&__rcutils_logging_location, RCUTILS_LOG_SEVERITY_ERROR, "", \
"%s() at %s:%d getting current steady time failed\n", \
Expand Down
4 changes: 2 additions & 2 deletions test/test_logging_macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ TEST_F(TestLoggingMacros, test_logging_throttle) {
auto is_before_throttle_end =
((std::chrono::system_clock::now() - start) < throttle_time);
RCUTILS_LOG_ERROR_THROTTLE(
rcutils_steady_time_now, throttle_time.count(), first ? "first" : "other");
RCUTILS_STEADY_TIME, throttle_time.count(), first ? "first" : "other");
first = false;
auto is_still_before_throttle_end =
((std::chrono::system_clock::now() - start) < throttle_time);
Expand Down Expand Up @@ -185,7 +185,7 @@ TEST_F(TestLoggingMacros, test_logging_skipfirst_throttle) {
auto is_before_throttle_end =
((std::chrono::system_clock::now() - start) < throttle_time);
RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE(
rcutils_steady_time_now, throttle_time.count(), first ? "first" : "other");
RCUTILS_STEADY_TIME, throttle_time.count(), first ? "first" : "other");
first = false;
auto is_still_before_throttle_end =
((std::chrono::system_clock::now() - start) < throttle_time);
Expand Down

0 comments on commit e1b4344

Please sign in to comment.