Verified Commit 993de9e0 authored by Liam Keegan's avatar Liam Keegan
Browse files

Add support for fmt v8

parent 1795c4b5
Pipeline #37893 passed with stage
in 3 minutes and 35 seconds
......@@ -7,8 +7,11 @@
#include <string>
#include <string_view>
#if FMT_VERSION < 80000
#include <fmt/posix.h>
#else
#include <fmt/os.h>
#endif
#include <dune/logging/patternformatsink.hh>
namespace Dune::Logging {
......
......@@ -75,7 +75,7 @@ namespace Dune::Logging {
* This class is produced by the _fmt literal when DUNE_LOGGING_CHECK_FORMAT_STRINGS is disabled.
*/
struct format_string_view
: std::string_view
: fmt::string_view
{
#ifndef DOXYGEN
......@@ -83,7 +83,7 @@ namespace Dune::Logging {
constexpr format_string_view() = default;
constexpr format_string_view(const char* s, std::size_t size)
: std::string_view(s,size)
: fmt::string_view(s,size)
{}
#endif
......
......@@ -33,7 +33,7 @@ namespace Dune::Logging {
);
}
void LoggerBackend::handle(const Logger& logger, LogLevel level, int indent, std::string_view format, fmt::format_args args)
void LoggerBackend::handle(const Logger& logger, LogLevel level, int indent, fmt::string_view format, fmt::format_args args)
{
if (not _enabled or _sinks.empty())
return;
......@@ -49,7 +49,11 @@ namespace Dune::Logging {
constexpr auto indent_template = " "sv;
buffer.append(begin(indent_template),begin(indent_template) + indent);
fmt::vformat_to(buffer, format, args);
fmt::
#if FMT_VERSION >= 80000
detail::
#endif
vformat_to(buffer, format, args);
auto msg = LogMessage(logger,level,indent,{buffer.data(),buffer.size()},time,time - _startup_time);
......@@ -83,7 +87,7 @@ namespace Dune::Logging {
_backend->_enabled = false;
}
void Logger::handle(LogLevel level, int indent, std::string_view format, fmt::format_args args) const
void Logger::handle(LogLevel level, int indent, fmt::string_view format, fmt::format_args args) const
{
DUNE_LOGGING_CHECK_LOGGER(level > LogLevel::off);
DUNE_LOGGING_CHECK_LOGGER(_backend && "This logger has no backend attached");
......
......@@ -416,7 +416,7 @@ namespace Dune::Logging {
* we don't want to duplicate at every log site, as this would unnecessarily bloat the code and
* make disabled log calls very expensive.
*/
void handle(LogLevel level, int indent, std::string_view format, fmt::format_args args) const;
void handle(LogLevel level, int indent, fmt::string_view format, fmt::format_args args) const;
LogLevel _level = LogLevel::all;
int _indent = 0;
......
......@@ -31,7 +31,7 @@ namespace Dune::Logging {
friend class Logging;
// This method is defined in logger.cc to allow inlining into Logger::handle()
void handle(const Logger& logger, LogLevel level, int indent, std::string_view format, fmt::format_args args);
void handle(const Logger& logger, LogLevel level, int indent, fmt::string_view format, fmt::format_args args);
bool _enabled = true;
LogMessage::Time _startup_time;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment