-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving the external logger library from rcutils into rcl. Also automa…
…tic uncrustify.
- Loading branch information
Showing
11 changed files
with
358 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright 2018 Open Source Robotics Foundation, Inc. | ||
# | ||
# 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. | ||
|
||
# | ||
# Get the package name of the default logging implementation. | ||
# | ||
# Either selecting it using the variable RC_LOGGING_IMPLEMENTATION or | ||
# choosing a default from the available implementations. | ||
# | ||
# :param var: the output variable name containing the package name | ||
# :type var: string | ||
# | ||
macro(get_default_rc_logging_implementation var) | ||
|
||
# if logging implementation already specified or RC_LOGGING_IMPLEMENTATION environment variable | ||
# is set then use that, otherwise default to using rc_logging_log4cxx | ||
if(NOT "${RC_LOGGING_IMPLEMENTATION}" STREQUAL "") | ||
set(_logging_implementation "${RC_LOGGING_IMPLEMENTATION}") | ||
elseif(NOT "$ENV{RC_LOGGING_IMPLEMENTATION}" STREQUAL "") | ||
set(_logging_implementation "$ENV{RC_LOGGING_IMPLEMENTATION}") | ||
else() | ||
set(_logging_implementation rc_logging_log4cxx) | ||
endif() | ||
|
||
# persist implementation decision in cache | ||
# if it was not determined dynamically | ||
set( | ||
RC_LOGGING_IMPLEMENTATION "${_logging_implementation}" | ||
CACHE STRING "Select ROS middleware implementation to link against" FORCE | ||
) | ||
|
||
find_package("${_logging_implementation}" REQUIRED) | ||
|
||
set(${var} ${_logging_implementation}) | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2017 Open Source Robotics Foundation, Inc. | ||
// | ||
// 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. | ||
|
||
#ifndef RCL__LOGGING_H_ | ||
#define RCL__LOGGING_H_ | ||
|
||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdio.h> | ||
|
||
#include "rcl/allocator.h" | ||
#include "rcl/arguments.h" | ||
#include "rcl/error_handling.h" | ||
#include "rcl/types.h" | ||
#include "rcl/visibility_control.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
|
||
/// Configures the logging system. | ||
/** | ||
* This function should be called during the ROS initialization process. It will | ||
* add the enabled log output appenders to the root logger. | ||
* | ||
* <hr> | ||
* Attribute | Adherence | ||
* ------------------ | ------------- | ||
* Allocates Memory | No | ||
* Thread-Safe | No | ||
* Uses Atomics | No | ||
* Lock-Free | Yes | ||
* | ||
* \param global_args The global arguments for the system | ||
* \return `RCL_RET_OK` if successful. | ||
* \return `RCL_RET_ERR` if a general error occurs | ||
*/ | ||
RCL_PUBLIC | ||
rcl_ret_t rcl_logging_configure(const rcl_arguments_t * global_args); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // RCL__LOGGING_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2018 Open Source Robotics Foundation, Inc. | ||
// | ||
// 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. | ||
|
||
#ifndef RCL__LOGGING_EXTERNAL_INTERFACE_H_ | ||
#define RCL__LOGGING_EXTERNAL_INTERFACE_H_ | ||
|
||
#include <stdarg.h> | ||
#include "rcl/types.h" | ||
#include "rcl/visibility_control.h" | ||
|
||
|
||
/** | ||
* \brief Initializes the external logging library. | ||
* | ||
* \param config_file The location of a config file that the external logging library should use to configure itself. | ||
* If no config file is provided this will be set to an empty string. Must be a NULL terminated c string. | ||
* \return RC_EXTERNAL_LOGGING_RET_OK if initialized successfully or an error code if not. | ||
*/ | ||
RCL_PUBLIC | ||
rcl_ret_t rcl_logging_external_initialize(const char * config_file); | ||
|
||
/** | ||
* \brief Free the resources allocated for the external logging system. | ||
* This puts the system into a state equivalent to being uninitialized | ||
* | ||
* \return RC_EXTERNAL_LOGGING_RET_OK if successfully shutdown or an error code if not. | ||
*/ | ||
RCL_PUBLIC | ||
rcl_ret_t rcl_logging_external_shutdown(); | ||
|
||
/** | ||
* \brief Logs a message | ||
* | ||
* \param severity The severity level of the message being logged | ||
* \param name The name of the logger, must be a null terminated c string or NULL. If NULL or empty the root logger will | ||
* be used. | ||
* \param msg The message to be logged. Must be a null terminated c string. | ||
*/ | ||
RCL_PUBLIC | ||
void rcl_logging_external_log(int severity, const char * name, const char * msg); | ||
|
||
|
||
/** | ||
* \brief Set the severity level for a logger. | ||
* Sets the severity level for the specified logger. If the name provided is an empty string or NULL it will change the | ||
* level of the root logger. | ||
* | ||
* \param name The name of the logger. Must be a NULL terminated c string or NULL. | ||
* \param level - The severity level to be used for the specified logger | ||
* \return RC_EXTERNAL_LOGGING_RET_OK if set successfully or an error code if not. | ||
*/ | ||
RCL_PUBLIC | ||
rcl_ret_t rcl_logging_external_set_logger_level(const char * name, int level); | ||
|
||
#endif // RCL__LOGGING_EXTERNAL_INTERFACE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.