A modern c++20 logging solution which can either log to a ROS2 backend or be used standalone
It provides a compat header with the old MELO style logging macros.
The contents are licensed under the BSD-3-Clause license.
Images in this repository are to be licensed separately if you want to use them for any other usecase than forking this repository. Please open an issue in order to get in touch with us.
All dependencies with their corresponding version are listed in the repos.list.
| Name | Description | License |
|---|---|---|
| spdglog | A very versatile c++ logging library | MIT |
#include "duatic_message_logger/log.hpp"
...
logging::debug() << "Test" << std::endl;
logging::info() << "Test" << std::endl;
logging::warning() << "Test" << std::endl;
logging::error() << "Test" << std::endl;
logging::fatal() << "Test" << std::endl;
See fmt for all formatting options
#include "duatic_message_logger/log.hpp"
...
logging::debug("Debug {}", 1);
logging::info("Info {}", 1);
logging::warning("Warning {}", 1);
logging::error("Error {}", 1);
logging::fatal("Fatal {}", 1);#include "duatic_message_logger/log.hpp"
...
// Create a custom sink + logger (spdlog style)
auto sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
sink->set_color_mode(spdlog::color_mode::always);
sink->set_pattern("[%^%l%$] [%Y-%m-%d %H:%M:%S.%e] [%n]: %v");
spdlog::logger logger{ "custom", sink };
// and use it in the streaming style
logging::debug(logger) << "Test debug"
<< "test" << std::endl;
logging::info(logger) << "Test info";
logging::warning(logger) << "Test warning";
logging::error(logger) << "Test error";
logging::fatal(logger) << "Test fatal";See fmt for all formatting options
#include "duatic_message_logger/log.hpp"
...
// Create a custom sink + logger (spdlog style)
auto sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
sink->set_color_mode(spdlog::color_mode::always);
sink->set_pattern("[%^%l%$] [%Y-%m-%d %H:%M:%S.%e] [%n]: %v");
spdlog::logger logger{ "custom", sink };
// and use it in the streaming style
logging::debug(logger, "Debug {}", 1);
logging::info(logger, "Info {}", 1);
logging::warning(logger, "Warning {}", 1);
logging::error(logger, "Error {}", 1);
logging::fatal(logger, "Fatal {}", 1);Do not use this - this is for compatibility only.
The message_logger packet is implemented as drop in replacement.
#include "message_logger/message_logger.hpp"
...
MELO_INFO("{}", 1);
MELO_INFO_STREAM("ABC" << 1);Use this in case the logging namespace is too general for you
// we include a different header
#include "duatic_message_logger/logging.hpp"
...
// call with the full namespace
duatic::message_logger::debug("Debug {}", 1);
Please see the Contributing guide