mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Allow creating logger instances on the Wine side
So we can log filterable messages from the Wine side. Will be used to warn about failed query interface calls.
This commit is contained in:
@@ -80,6 +80,25 @@ Logger Logger::create_from_environment(std::string prefix) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger Logger::create_wine_stderr() {
|
||||||
|
auto env = boost::this_process::environment();
|
||||||
|
std::string verbosity =
|
||||||
|
env[logging_verbosity_environment_variable].to_string();
|
||||||
|
|
||||||
|
Verbosity verbosity_level;
|
||||||
|
try {
|
||||||
|
verbosity_level = static_cast<Verbosity>(std::stoi(verbosity));
|
||||||
|
} catch (const std::invalid_argument&) {
|
||||||
|
verbosity_level = Verbosity::basic;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We're logging directly to `std::cerr` instead of to `/dev/stderr` because
|
||||||
|
// we want the STDERR redirection from the group host processes to still
|
||||||
|
// function here
|
||||||
|
return Logger(std::shared_ptr<std::ostream>(&std::cerr), verbosity_level,
|
||||||
|
"");
|
||||||
|
}
|
||||||
|
|
||||||
void Logger::log(const std::string& message) {
|
void Logger::log(const std::string& message) {
|
||||||
const auto current_time = std::chrono::system_clock::now();
|
const auto current_time = std::chrono::system_clock::now();
|
||||||
const std::time_t timestamp =
|
const std::time_t timestamp =
|
||||||
|
|||||||
@@ -85,6 +85,13 @@ class Logger {
|
|||||||
*/
|
*/
|
||||||
static Logger create_from_environment(std::string prefix = "");
|
static Logger create_from_environment(std::string prefix = "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a special logger instance that outputs directly to STDERR without
|
||||||
|
* any prefixes. This is used to be able to log filterable messages from the
|
||||||
|
* Wine side of things.
|
||||||
|
*/
|
||||||
|
static Logger create_wine_stderr();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a message to the log, prefixing it with a timestamp and this
|
* Write a message to the log, prefixing it with a timestamp and this
|
||||||
* logger's prefix string.
|
* logger's prefix string.
|
||||||
|
|||||||
Reference in New Issue
Block a user