Skip to content

Commit

Permalink
Enable logging level manipulation from rmw_fastrtps (#156)
Browse files Browse the repository at this point in the history
* Fastrtps supports rich logging facilities, which could be used on any ros2 development.

* To enable the same, enable setting log levels from rmw_fastrtps layers,
* Add generic logging level parameters to 'rmw.h' which would be used by other
  layers above like rcl/rclcpp.
* Hide DDS specific implementation inside rmw_fastrtps.

Signed-off-by: Sriram Raghunathan <sriram.max@gmail.com>

* The changes follow the discussions

ros2/rmw#124

* The API defined is used to set the logging level particular to the DDS
implementation.
* This change is specific to DDS type Fast-RTPS.
* The file is named as rmw_configure since we could write API's of type
  'system level config setting' types here.

Signed-off-by: Sriram Raghunathan <rsriram7@visteon.com>

* Rename file from rmw_fastrtps_configure to rmw_logging, which follows the patterns being used already.

like rmw_node, rmw_publisher..

Signed-off-by: Sriram Raghunathan <sriram.max@gmail.com>

* - Fix, coding errors.
- Renmae API to suite ros styles

Signed-off-by: Sriram Raghunathan <sriram.max@gmail.com>

* Fix ament_cpplint warnings

Signed-off-by: Sriram Raghunathan <sriram.max@gmail.com>

* Remove utility function to create a 'error' returnable API for setting logging

Signed-off-by: Sriram Raghunathan <rsriram7@visteon.com>

* Fix, logging msg bug.

* Modify logging mapping for type 'debug' from warning to info.

Signed-off-by: Sriram Raghunathan <rsriram7@visteon.com>

* order log levels, use different local variable name, include unknown severity in error message

* Fix error due to parameterized logging

* Fix code style issues from uncrustify
  • Loading branch information
sriramster authored and dirk-thomas committed Jan 18, 2018
1 parent 1175657 commit 0149205
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
1 change: 1 addition & 0 deletions rmw_fastrtps_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ add_library(rmw_fastrtps_cpp
src/identifier.cpp
src/namespace_prefix.cpp
src/qos.cpp
src/rmw_logging.cpp
src/rmw_client.cpp
src/rmw_compare_gids_equal.cpp
src/rmw_count.cpp
Expand Down
54 changes: 54 additions & 0 deletions rmw_fastrtps_cpp/src/rmw_logging.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "rmw/rmw.h"
#include "rmw/error_handling.h"

#include "rcutils/logging_macros.h"

#include "fastrtps/log/Log.h"

extern "C"
{
using eprosima::fastrtps::Log;

rmw_ret_t
rmw_set_log_severity(rmw_log_severity_t severity)
{
Log::Kind log_kind;

switch (severity) {
case RMW_LOG_SEVERITY_DEBUG:
// fall through
case RMW_LOG_SEVERITY_INFO:
log_kind = Log::Kind::Info;
break;
case RMW_LOG_SEVERITY_WARN:
log_kind = Log::Kind::Warning;
break;
case RMW_LOG_SEVERITY_ERROR:
// fall through
case RMW_LOG_SEVERITY_FATAL:
log_kind = Log::Kind::Error;
break;
default:
RCUTILS_LOG_ERROR("Unknown logging severity type %d", severity);
return RMW_RET_ERROR;
}

eprosima::fastrtps::Log::SetVerbosity(log_kind);

return RMW_RET_OK;
}
} // extern "C"
2 changes: 0 additions & 2 deletions rmw_fastrtps_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ create_node(
return nullptr;
}

eprosima::fastrtps::Log::SetVerbosity(eprosima::fastrtps::Log::Error);

// Declare everything before beginning to create things.
rmw_guard_condition_t * graph_guard_condition = nullptr;
CustomParticipantInfo * node_impl = nullptr;
Expand Down

0 comments on commit 0149205

Please sign in to comment.