notes.h
#ifndef WREPORT_NOTES_H
#define WREPORT_NOTES_H
#include <iosfwd>
#ifndef WREPORT_PRINTF_ATTRS
#define WREPORT_PRINTF_ATTRS(a, b) __attribute__ ((format(printf, a, b)))
#endif
namespace wreport {
namespace notes {
void set_target(std::ostream& out);
std::ostream* get_target();
bool logs() throw ();
std::ostream& log() throw ();
void logf(const char* fmt, ...) WREPORT_PRINTF_ATTRS(1, 2);
struct Collect
{
std::ostream* old;
Collect(std::ostream& out)
{
old = get_target();
set_target(out);
}
~Collect()
{
set_target(*old);
}
};
}
}
#endif
wreport::notes
Collect notes about unusual things that happen during processing.
Definition notes.h:18
wreport::notes::log
std::ostream & log()
Output stream to send notes to.
wreport::notes::get_target
std::ostream * get_target()
Get the current target stream for notes.
wreport::notes::set_target
void set_target(std::ostream &out)
Set the target stream where the notes are sent.
wreport::notes::logf
void logf(const char *fmt,...) WREPORT_PRINTF_ATTRS(1
printf-style logging
wreport::notes::logs
bool logs()
Return true if there is any target to which notes are sent.
wreport
String functions.
Definition benchmark.h:13
wreport::notes::Collect
RAII way to temporarily set a notes target.
Definition notes.h:42
wreport::notes::Collect::old
std::ostream * old
Old target stream to be restored whemn the object goes out of scope.
Definition notes.h:46
wreport::notes::Collect::Collect
Collect(std::ostream &out)
Direct notes to out for the lifetime of the object.
Definition notes.h:49