mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 09:09:35 +08:00
Fix usage of ranges and to_hex in the same compile unit
When trying to use spdlog/fmt/bin_to_hex.h in the same compile unit as spdlog/fmt/bundled/ranges.h you got a compile error because there was a multiple definitions for iterable classes. This fix renames the begin() and end() getters in dump_info into getBegin()/getEnd() in order to avoid this collision. Added an example of ranges in example.cpp to show that it actually works (an to_hex example was already there)
This commit is contained in:
@@ -14,6 +14,7 @@ void rotating_example();
|
||||
void daily_example();
|
||||
void async_example();
|
||||
void binary_example();
|
||||
void vector_example();
|
||||
void stopwatch_example();
|
||||
void trace_example();
|
||||
void multi_sink_example();
|
||||
@@ -73,6 +74,7 @@ int main(int, char *[])
|
||||
daily_example();
|
||||
async_example();
|
||||
binary_example();
|
||||
vector_example();
|
||||
multi_sink_example();
|
||||
user_defined_example();
|
||||
err_handler_example();
|
||||
@@ -188,6 +190,15 @@ void binary_example()
|
||||
// logger->info("hexdump style, 20 chars per line {:a}", spdlog::to_hex(buf, 20));
|
||||
}
|
||||
|
||||
// Log a vector of numbers
|
||||
|
||||
#include "spdlog/fmt/bundled/ranges.h"
|
||||
void vector_example()
|
||||
{
|
||||
std::vector<int> vec = {1, 2, 3};
|
||||
spdlog::info("Vector example: {}", vec);
|
||||
}
|
||||
|
||||
// Compile time log levels.
|
||||
// define SPDLOG_ACTIVE_LEVEL to required level (e.g. SPDLOG_LEVEL_TRACE)
|
||||
void trace_example()
|
||||
|
Reference in New Issue
Block a user