1#ifndef __LOGGER_CONSOLE_HPP__
2#define __LOGGER_CONSOLE_HPP__
4#include <common/logger.hpp>
8#include <source_location>
31 void debug(std::string_view message)
noexcept final;
33 void print(std::string_view prefix,
34 std::string_view message)
noexcept final;
35 void alert(std::string_view prefix,
36 std::string_view message)
noexcept final;
38 void error(std::string_view message,
39 std::source_location location
40 = std::source_location::current()) noexcept final;
42 void raw_log(std::string_view message) noexcept final;
96 class RedirectGuard :
public std::enable_shared_from_this<RedirectGuard>
~Console() override=default
Console & operator=(const Console &)=delete
void error(std::string_view message, std::source_location location=std::source_location::current()) noexcept final
Log an error message with optional location details.
Definition logger.cpp:240
void toggle_error() noexcept final
Toggle the error logging behavior on or off.
Definition logger.cpp:291
void toggle_print() noexcept final
Toggle the print logging behavior on or off.
Definition logger.cpp:279
void toggle_alert() noexcept final
Toggle the alert logging behavior on or off.
Definition logger.cpp:285
void alert(std::string_view prefix, std::string_view message) noexcept final
Log an alert message with a prefix.
Definition logger.cpp:227
std::ostream & err_output
Definition console.hpp:58
void debug(std::string_view message) noexcept final
Log a debug message.
Definition logger.cpp:201
Console & operator=(Console &&)=delete
void raw_log(std::string_view message) noexcept final
Log a raw message with no additional formatting.
Definition logger.cpp:255
bool do_flush
Definition console.hpp:60
void print(std::string_view prefix, std::string_view message) noexcept final
Log a regular print message with a prefix.
Definition logger.cpp:214
void toggle_all() noexcept final
Toggle all logging types on or off.
Definition logger.cpp:273
uint32_t flags
Definition console.hpp:56
Console()
Definition logger.cpp:182
std::ostream & output
Definition console.hpp:57
void toggle_debug() noexcept final
Toggle the debug logging behavior on or off.
Definition logger.cpp:266
Console(const Console &)=delete
Console(Console &&)=delete
std::shared_ptr< bool > active_flag
Definition console.hpp:117
RedirectHandle redirect_to_file()
Definition logger.cpp:90
void restore()
Definition logger.cpp:123
bool has_been_redirected
Definition console.hpp:112
std::optional< std::string > getCapturedOutput() const
Definition logger.cpp:151
std::stringstream buffer
Definition console.hpp:114
RedirectGuard()
Definition logger.cpp:58
int original_stdout_fd
Definition console.hpp:115
std::streambuf * coutbuf
Definition console.hpp:113
RedirectHandle redirect()
Definition logger.cpp:63
friend class RedirectHandle
Definition console.hpp:110
RedirectionType type
Definition console.hpp:93
RedirectHandle(RedirectHandle &&)=default
RedirectHandle & operator=(const RedirectHandle &)=delete
std::shared_ptr< RedirectGuard > owner_ptr
Definition console.hpp:90
std::shared_ptr< bool > active_flag
Definition console.hpp:91
RedirectHandle(const RedirectHandle &)=delete
bool owns_guard
Definition console.hpp:92
RedirectHandle(std::shared_ptr< RedirectGuard > owner, std::shared_ptr< bool > active_flag, bool owns, RedirectionType _type)
Definition logger.cpp:49
RedirectHandle & operator=(RedirectHandle &&)=default
Definition impl_post_process.hpp:11
RedirectionType
Definition console.hpp:66
@ File
Definition console.hpp:68
@ Buffer
Definition console.hpp:67