Skip to content

Commit

Permalink
The changes follow the discussions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sriram Raghunathan committed Oct 25, 2017
1 parent a4899fb commit e1eba0f
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions rmw_fastrtps_cpp/src/rmw_fastrtps_configure.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// 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 "fastrtps/log/Log.h"
Expand All @@ -6,26 +20,37 @@ extern "C"
{
using eprosima::fastrtps::Log;

eprosima::fastrtps::Log::Kind rmw_convert_severity_fastrtps(rmw_log_level_t level)
eprosima::fastrtps::Log::Kind rmw_convert_severity_type(rmw_log_severity_t severity)
{
switch(level)
switch(severity)
{
case RMW_LOG_LEVEL_ERROR:
return Log::Kind::Error;
case RMW_LOG_LEVEL_WARNING:
case RMW_LOG_SEVERITY_WARN:
return Log::Kind::Warning;
case RMW_LOG_LEVEL_INFO:
case RMW_LOG_SEVERITY_INFO:
return Log::Kind::Info;
/* Fast-RTPS supports the following logging 'Kind's.
* Error : Max priority
* Warning : Medium priority
* Info : Low priority
* From rmw logging severity there are FATAL & DEBUG types as well
* We map them to ERROR type of Fast-RTPS which has maximum priority
*/
case RMW_LOG_SEVERITY_ERROR:
case RMW_LOG_SEVERITY_FATAL:
case RMW_LOG_SEVERITY_DEBUG:
return Log::Kind::Error;
default:
//Fallback to Info if undefined types
return Log::Kind::Info;
}
}

void
rmw_setup_fastrtps(rmw_log_level_t level)
rmw_ret_t
rmw_set_log_severity(rmw_log_severity_t severity)
{
Log::Kind lvl = rmw_convert_severity_fastrtps(level);
eprosima::fastrtps::Log::SetVerbosity(lvl);
}
Log::Kind _severity = rmw_convert_severity_type(severity);
eprosima::fastrtps::Log::SetVerbosity(_severity);

return RMW_RET_OK;
}
} // extern "C"

0 comments on commit e1eba0f

Please sign in to comment.