#ifndef INC_SRT_VERBOSE_HPP
#define INC_SRT_VERBOSE_HPP
#include <iostream>
#if SRT_ENABLE_VERBOSE_LOCK
#include <mutex>
#endif
namespace Verbose
{
extern bool on;
extern std::ostream* cverb;
struct LogNoEol { LogNoEol() {} };
#if SRT_ENABLE_VERBOSE_LOCK
struct LogLock { LogLock() {} };
#endif
class Log
{
bool noeol = false;
#if SRT_ENABLE_VERBOSE_LOCK
bool lockline = false;
#endif
void* operator new(size_t);
public:
template <class V>
Log& operator<<(const V& arg)
{
if (on)
(*cverb) << arg;
return *this;
}
Log& operator<<(LogNoEol);
#if SRT_ENABLE_VERBOSE_LOCK
Log& operator<<(LogLock);
#endif
~Log();
};
class ErrLog: public Log
{
public:
template <class V>
ErrLog& operator<<(const V& arg)
{
if (on)
(*cverb) << arg;
else
std::cerr << arg;
return *this;
}
};
}
inline Verbose::Log Verb() { return Verbose::Log(); }
inline Verbose::ErrLog Verror() { return Verbose::ErrLog(); }
static const Verbose::LogNoEol VerbNoEOL;
#if SRT_ENABLE_VERBOSE_LOCK
static const Verbose::LogLock VerbLock;
#endif
#endif