Dune::Copasi
Loading...
Searching...
No Matches
ostream_to_spdlog.hh
Go to the documentation of this file.
1#ifndef DUNE_COPASI_COMMON_OSTREAM_TO_SPDLOG_HH
2#define DUNE_COPASI_COMMON_OSTREAM_TO_SPDLOG_HH
3
5
6#include <spdlog/spdlog.h>
7
8#include <array>
9#include <iostream>
10
11namespace Dune::Copasi {
12
19[[nodiscard]] inline auto
21{
22 return std::array{ OStreamRedirect::make(std::cout, [](auto msg) { spdlog::info(msg); }),
23 OStreamRedirect::make(std::cerr, [](auto msg) { spdlog::critical(msg); }),
24 OStreamRedirect::make(std::clog, [](auto msg) { spdlog::debug(msg); }) };
25}
26
27} // namespace Dune::Copasi
28
29#endif // DUNE_COPASI_COMMON_OSTREAM_TO_SPDLOG_HH
static std::unique_ptr< OStreamRedirect > make(std::ostream &ostream, fu2::unique_function< void(std::string_view)> redirection, bool line_buffered=true)
RAII safe constructor of the redirection object While the object is alive, the output of ostream will...
Definition axis_names.hh:7
constexpr bool is_bitflags_v
Alias for Bitflag indicator.
Definition bit_flags.hh:24
auto ostream2spdlog()
Standard output redirection to spdlog.
Definition ostream_to_spdlog.hh:20