mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::log: Add console_quiet to suppress log messages to console.
This commit is contained in:
parent
cead127c73
commit
88a15924ed
2 changed files with 27 additions and 0 deletions
|
@ -99,6 +99,12 @@ void notice(const char *fmt, ...) AFP(1, 2);
|
||||||
void info(const char *fmt, ...) AFP(1, 2);
|
void info(const char *fmt, ...) AFP(1, 2);
|
||||||
void debug(const char *fmt, ...) AFP(1, 2);
|
void debug(const char *fmt, ...) AFP(1, 2);
|
||||||
|
|
||||||
|
struct console_quiet
|
||||||
|
{
|
||||||
|
console_quiet(const bool &showmsg = true);
|
||||||
|
~console_quiet();
|
||||||
|
};
|
||||||
|
|
||||||
void flush();
|
void flush();
|
||||||
void close();
|
void close();
|
||||||
void open();
|
void open();
|
||||||
|
|
|
@ -49,6 +49,10 @@ std::array<bool, num_of<facility>()> file_out;
|
||||||
std::array<bool, num_of<facility>()> console_out;
|
std::array<bool, num_of<facility>()> console_out;
|
||||||
std::array<bool, num_of<facility>()> console_err;
|
std::array<bool, num_of<facility>()> console_err;
|
||||||
|
|
||||||
|
// Suppression state (for struct console_quiet)
|
||||||
|
std::array<bool, num_of<facility>()> quieted_out;
|
||||||
|
std::array<bool, num_of<facility>()> quieted_err;
|
||||||
|
|
||||||
// Logfile name and device
|
// Logfile name and device
|
||||||
std::array<const char *, num_of<facility>()> fname;
|
std::array<const char *, num_of<facility>()> fname;
|
||||||
std::array<std::ofstream, num_of<facility>()> file;
|
std::array<std::ofstream, num_of<facility>()> file;
|
||||||
|
@ -178,6 +182,23 @@ catch(const std::exception &e)
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log::console_quiet::console_quiet(const bool &showmsg)
|
||||||
|
{
|
||||||
|
if(showmsg)
|
||||||
|
notice("Log messages are now quieted at the console");
|
||||||
|
|
||||||
|
std::copy(begin(console_out), end(console_out), begin(quieted_out));
|
||||||
|
std::copy(begin(console_err), end(console_err), begin(quieted_err));
|
||||||
|
std::fill(begin(console_out), end(console_out), false);
|
||||||
|
std::fill(begin(console_err), end(console_err), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
log::console_quiet::~console_quiet()
|
||||||
|
{
|
||||||
|
std::copy(begin(quieted_out), end(quieted_out), begin(console_out));
|
||||||
|
std::copy(begin(quieted_err), end(quieted_err), begin(console_err));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
log::debug(const char *const fmt,
|
log::debug(const char *const fmt,
|
||||||
...)
|
...)
|
||||||
|
|
Loading…
Reference in a new issue