-
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.
Adding new cli parameters for configuring the logging. (#327)
* Adding new cli parameters for configuring the logging. cr https://code.amazon.com/reviews/CR-3728503 * Moving the external logger library from rcutils into rcl. Also automatic uncrustify. * Fixing issue with rebase * Temporarily switching the default to noop logger ext_lib while system dependency issue is solved for Windows/Mac. * Fixing the format2/3 xmllint issue. * style changes, and one actual fix Signed-off-by: William Woodall <[email protected]> * rename rc_logging* to rcl_logging* Signed-off-by: William Woodall <[email protected]> * Expand rcl_logging_configure API with allocator This is to make sure that this API is complete, and we can merge rcl#350 later without breaking the API at a later date. * update logging.c with new use of allocator in API * update init.c with new API changes * Switching back to va_list for output handlers. * address review comments Signed-off-by: William Woodall <[email protected]>
- Loading branch information
Showing
11 changed files
with
611 additions
and
9 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 RCL_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_rcl_logging_implementation var) | ||
|
||
# if logging implementation already specified or RCL_LOGGING_IMPLEMENTATION environment variable | ||
# is set then use that, otherwise default to using rcl_logging_noop | ||
if(NOT "${RCL_LOGGING_IMPLEMENTATION}" STREQUAL "") | ||
set(_logging_implementation "${RCL_LOGGING_IMPLEMENTATION}") | ||
elseif(NOT "$ENV{RCL_LOGGING_IMPLEMENTATION}" STREQUAL "") | ||
set(_logging_implementation "$ENV{RCL_LOGGING_IMPLEMENTATION}") | ||
else() | ||
set(_logging_implementation rcl_logging_noop) | ||
endif() | ||
|
||
# persist implementation decision in cache | ||
# if it was not determined dynamically | ||
set( | ||
RCL_LOGGING_IMPLEMENTATION "${_logging_implementation}" | ||
CACHE STRING "select rcl logging implementation to use" 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,77 @@ | ||
// 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_H_ | ||
#define RCL__LOGGING_H_ | ||
|
||
#include "rcl/allocator.h" | ||
#include "rcl/arguments.h" | ||
#include "rcl/macros.h" | ||
#include "rcl/types.h" | ||
#include "rcl/visibility_control.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
|
||
/// Configure 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 | Yes | ||
* Thread-Safe | No | ||
* Uses Atomics | No | ||
* Lock-Free | Yes | ||
* | ||
* \param global_args The global arguments for the system | ||
* \return `RCL_RET_OK` if successful, or | ||
* \return `RCL_RET_BAD_ALLOC` if allocating memory failed, or | ||
* \return `RCL_RET_ERR` if a general error occurs | ||
*/ | ||
RCL_PUBLIC | ||
RCL_WARN_UNUSED | ||
rcl_ret_t | ||
rcl_logging_configure( | ||
const rcl_arguments_t * global_args, | ||
const rcl_allocator_t * allocator); | ||
|
||
/** | ||
* This function should be called to tear down the logging setup by the configure function. | ||
* | ||
* <hr> | ||
* Attribute | Adherence | ||
* ------------------ | ------------- | ||
* Allocates Memory | No | ||
* Thread-Safe | No | ||
* Uses Atomics | No | ||
* Lock-Free | Yes | ||
* | ||
* \return `RCL_RET_OK` if successful. | ||
* \return `RCL_RET_ERR` if a general error occurs | ||
*/ | ||
RCL_PUBLIC | ||
RCL_WARN_UNUSED | ||
rcl_ret_t rcl_logging_fini(); | ||
|
||
#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,75 @@ | ||
// 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 "rcl/macros.h" | ||
#include "rcl/types.h" | ||
#include "rcl/visibility_control.h" | ||
|
||
/// Initialize the external logging library. | ||
/** | ||
* \param[in] 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 RCL_RET_OK if initialized successfully, or | ||
* \return RCL_RET_ERROR if an unspecified error occurs. | ||
*/ | ||
RCL_PUBLIC | ||
RCL_WARN_UNUSED | ||
rcl_ret_t | ||
rcl_logging_external_initialize(const char * config_file); | ||
|
||
/// Free the resources allocated for the external logging system. | ||
/** | ||
* This puts the system into a state equivalent to being uninitialized. | ||
* | ||
* \return RCL_RET_OK if successfully shutdown, or | ||
* \return RCL_RET_ERROR if an unspecified error occurs. | ||
*/ | ||
RCL_PUBLIC | ||
RCL_WARN_UNUSED | ||
rcl_ret_t | ||
rcl_logging_external_shutdown(); | ||
|
||
/// Log a message. | ||
/** | ||
* \param[in] severity The severity level of the message being logged. | ||
* \param[in] name The name of the logger, must either be a null terminated | ||
* c string or NULL. | ||
* If NULL or empty the root logger will be used. | ||
* \param[in] 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); | ||
|
||
/// Set the severity level for a logger. | ||
/** | ||
* This function 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[in] name The name of the logger. | ||
* Must be a NULL terminated c string or NULL. | ||
* \param[in] level The severity level to be used for the specified logger. | ||
* \return RCL_RET_OK if set successfully, or | ||
* \return RCL_RET_ERROR if an unspecified error occurs. | ||
*/ | ||
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
Oops, something went wrong.