13#ifndef COMMON_LOGGING_H
14#define COMMON_LOGGING_H
26# include "utils/log.h"
29namespace toolx::logging {
36 static std::atomic<bool> verbose{
false };
55inline void messageHandler(QtMsgType type,
const QMessageLogContext &,
const QString &message)
57 const char *level =
"error";
76 const bool isError = (type == QtCriticalMsg || type == QtFatalMsg);
78 const QByteArray text = message.toLocal8Bit();
79 std::fprintf(stderr,
"[%s] %s\n", level, text.constData());
82 if (type == QtFatalMsg) {
99 if (!verbose && !qEnvironmentVariableIsSet(
"LIBVA_MESSAGING_LEVEL")) {
100 qputenv(
"LIBVA_MESSAGING_LEVEL",
"0");
104 std::cout.rdbuf(std::cerr.rdbuf());
106 ::mediax::SetLogLevel(verbose ? ::mediax::LogLevel::kInfo : ::mediax::LogLevel::kQuiet);
117 for (
int i = 1; i < argc; ++i) {
118 const QByteArray arg(argv[i]);
119 if (arg ==
"--verbose") {
bool verboseRequested(int argc, char *argv[])
Is –verbose in the command line (-v prints the version instead).
Definition logging.h:115
std::atomic< bool > & verboseFlag()
Storage for the verbose flag.
Definition logging.h:34
bool isVerbose()
Is verbose output enabled (-v / –verbose).
Definition logging.h:43
void configure(bool verbose)
Apply the logging policy, call once at start up before any library is initialised.
Definition logging.h:93
void messageHandler(QtMsgType type, const QMessageLogContext &, const QString &message)
Qt message handler, writes to stderr only.
Definition logging.h:55