Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Agüero <[email protected]>
  • Loading branch information
caguero committed Aug 16, 2024
1 parent 6144605 commit 55eb7a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions log/include/gz/utils/log/SplitSink.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
#ifndef GZ_UTILS_LOG_SPLITSINK_HH_
#define GZ_UTILS_LOG_SPLITSINK_HH_

#include <memory>
#include <mutex>
#include <string>
#include <utility>
#include <vector>

#include <spdlog/details/log_msg.h>
Expand Down Expand Up @@ -114,7 +116,7 @@ class SplitRingBufferSink: public spdlog::sinks::base_sink<Mutex>
/// \brief No copy constructor.
public: SplitRingBufferSink(const SplitRingBufferSink &) = delete;

/// \brief No asignment operator.
/// \brief No asignment operator.
public: SplitRingBufferSink &operator=(const SplitRingBufferSink &) = delete;

/// \brief ToDo.
Expand Down Expand Up @@ -177,7 +179,7 @@ class SplitRingBufferSink: public spdlog::sinks::base_sink<Mutex>
}

/// \brief Set the logging pattern.
/// \param[in] _pattern The logging pattern.
/// \param[in] _pattern The logging pattern.
protected: void set_pattern_(const std::string &_pattern) override
{
this->set_formatter_(
Expand Down
16 changes: 9 additions & 7 deletions log/src/SplitSink_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
/////////////////////////////////////////////////
TEST(SplitConsoleSink, foo)
{
auto split_sink = std::make_shared<gz::utils::log::SplitConsoleSinkMt>();
auto splitSink = std::make_shared<gz::utils::log::SplitConsoleSinkMt>();

spdlog::logger logger("split_sink", {split_sink});
spdlog::logger logger("split_sink", {splitSink});
logger.set_level(spdlog::level::trace);

logger.trace("trace");
Expand All @@ -39,10 +39,12 @@ TEST(SplitConsoleSink, foo)
/////////////////////////////////////////////////
TEST(SplitRingBufferSink, foo)
{
auto split_sink = std::make_shared<gz::utils::log::SplitRingBufferSinkMt<100>>();
auto split_sink_console = std::make_shared<gz::utils::log::SplitConsoleSinkMt>();
auto splitSink =
std::make_shared<gz::utils::log::SplitRingBufferSinkMt<100>>();
auto splitSinkConsole =
std::make_shared<gz::utils::log::SplitConsoleSinkMt>();

spdlog::logger logger("split_sink", {split_sink, split_sink_console});
spdlog::logger logger("split_sink", {splitSink, splitSinkConsole});
logger.set_level(spdlog::level::trace);

logger.trace("trace");
Expand All @@ -53,14 +55,14 @@ TEST(SplitRingBufferSink, foo)
logger.critical("critical");

{
auto logs = split_sink->last_raw_stdout();
auto logs = splitSink->last_raw_stdout();
EXPECT_EQ(logs[0].payload, "trace");
EXPECT_EQ(logs[1].payload, "debug");
EXPECT_EQ(logs[2].payload, "info");
}

{
auto logs = split_sink->last_raw_stderr();
auto logs = splitSink->last_raw_stderr();
EXPECT_EQ(logs[0].payload, "warn");
EXPECT_EQ(logs[1].payload, "error");
EXPECT_EQ(logs[2].payload, "critical");
Expand Down

0 comments on commit 55eb7a5

Please sign in to comment.