1
0
mirror of https://github.com/luanti-org/minetestmapper.git synced 2025-10-07 22:35:21 +02:00

Add flag to enable verbose output

This commit is contained in:
sfan5
2025-03-05 20:19:36 +01:00
parent e982efe94e
commit 4ba09ec532
12 changed files with 114 additions and 48 deletions

40
src/log.h Normal file
View File

@@ -0,0 +1,40 @@
#pragma once
#include <iostream>
#include <utility>
// Forwards to an ostream, optionally
class StreamProxy {
public:
StreamProxy(std::ostream *os) : m_os(os) {}
template<typename T>
StreamProxy &operator<<(T &&arg)
{
if (m_os)
*m_os << std::forward<T>(arg);
return *this;
}
StreamProxy &operator<<(std::ostream &(*func)(std::ostream&))
{
if (m_os)
*m_os << func;
return *this;
}
private:
std::ostream *m_os;
};
/// Error and warning output, forwards to std::cerr
extern StreamProxy errorstream;
/// Verbose output, might forward to std::cerr
extern StreamProxy verbosestream;
/**
* Configure log streams defined in this file.
* @param verbose enable verbose output
* @note not thread-safe!
*/
void configure_log_streams(bool verbose);