Skip to content

Commit

Permalink
Move log_named impl to cpp
Browse files Browse the repository at this point in the history
Signed-off-by: Yadunund <[email protected]>
  • Loading branch information
Yadunund committed Jul 1, 2024
1 parent c20ee54 commit afe1378
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
27 changes: 27 additions & 0 deletions rmw_zenoh_cpp/src/detail/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,31 @@ void Logger::set_log_level(RCUTILS_LOG_SEVERITY new_level)
{
threshold_level_ = new_level;
}

void Logger::log_named(
RCUTILS_LOG_SEVERITY level,
const char * name,
const char * message,
...) const
{
if (level >= this->threshold_level_) {
rcutils_time_point_value_t now;
rcutils_ret_t ret = rcutils_system_time_now(&now);
if (ret != RCUTILS_RET_OK) {
RCUTILS_SAFE_FWRITE_TO_STDERR("Failed to get timestamp while doing a console logging.\n");
return;
}
static rcutils_log_location_t log_location = {__func__, __FILE__, __LINE__};
va_list args;
va_start(args, message);
rcutils_logging_console_output_handler(
&log_location,
level,
name,
now,
message,
&args
);
}
}
} // namespace rmw_zenoh_cpp
23 changes: 1 addition & 22 deletions rmw_zenoh_cpp/src/detail/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,7 @@ class Logger
RCUTILS_LOG_SEVERITY level,
const char * name,
const char * message,
...) const
{
if (level >= threshold_level_) {
rcutils_time_point_value_t now;
rcutils_ret_t ret = rcutils_system_time_now(&now);
if (ret != RCUTILS_RET_OK) {
RCUTILS_SAFE_FWRITE_TO_STDERR("Failed to get timestamp while doing a console logging.\n");
return;
}
static rcutils_log_location_t log_location = {__func__, __FILE__, __LINE__};
va_list args;
va_start(args, message);
rcutils_logging_console_output_handler(
&log_location,
level,
name,
now,
message,
&args
);
}
}
...) const;

private:
RCUTILS_LOG_SEVERITY threshold_level_;
Expand Down

0 comments on commit afe1378

Please sign in to comment.