Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable logging level manipulation from rmw_fastrtps #156

Merged
merged 14 commits into from
Jan 18, 2018
Merged
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
52 changes: 52 additions & 0 deletions rmw_fastrtps_cpp/src/rmw_logging.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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 "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:
RMW_SET_ERROR_MSG("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