
* Add Logger class and give one to nodes * Try to improve compiler errors when non-Logger is passed to macros * Add define for 'disabling' loggers * Add/update tests * Linter fix * Documentation * Windows fix * Move free functions to source file (windows was upset) * Fix windows by changing prototype ordering * Store node logger in NodeBase * Windows is not happy with this EXPECT_ANY_THROW * Move get_logger to a NodeLogger interface * Move Logger into 'logger' namespace * Move helper function for macro errors into macro header * Remove 'logger' namespace * Return type on separate line * Update copyright year * Give lifecycle nodes a logger * Add test for lifecycle node logger Move the default_state_machine tests to another file because having different test fixtures was causing init to be called twice. * Switch to static_assert for logger check * global ns scope in macro calls just in case * Revert "Add test for lifecycle node logger" (make diff smaller) demos use the loggers and we don't test other node stuff in lifecycle_node * Update for rcutils function name change * Add reference to Node::get_logger() in doxygen * Rename NodeLoggerInterface to NodeLoggingInterface
35 lines
1.3 KiB
C++
35 lines
1.3 KiB
C++
// 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.
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <string>
|
|
|
|
#include "rclcpp/logger.hpp"
|
|
#include "rclcpp/logging.hpp"
|
|
|
|
TEST(TestLogger, factory_functions) {
|
|
rclcpp::Logger logger = rclcpp::get_logger("test_logger");
|
|
EXPECT_STREQ("test_logger", logger.get_name());
|
|
rclcpp::Logger logger_copy = rclcpp::Logger(logger);
|
|
EXPECT_STREQ("test_logger", logger_copy.get_name());
|
|
}
|
|
|
|
TEST(TestLogger, hierarchy) {
|
|
rclcpp::Logger logger = rclcpp::get_logger("test_logger");
|
|
rclcpp::Logger sublogger = logger.get_child("child");
|
|
EXPECT_STREQ("test_logger.child", sublogger.get_name());
|
|
rclcpp::Logger subsublogger = sublogger.get_child("grandchild");
|
|
EXPECT_STREQ("test_logger.child.grandchild", subsublogger.get_name());
|
|
}
|