diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-08-24 18:44:51 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-08-24 18:44:51 +0200 |
commit | ad38bc6ecb80ddeb562841b33258dd53659b1da6 (patch) | |
tree | e02e9c3ff760554fd87f70df0e18b88594091a48 /backend/genesys/error.cpp | |
parent | 9c23ed018d72eed2554f4f9cff1ae6e6bb0cd479 (diff) |
New upstream version 1.0.31upstream/1.0.31
Diffstat (limited to 'backend/genesys/error.cpp')
-rw-r--r-- | backend/genesys/error.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/backend/genesys/error.cpp b/backend/genesys/error.cpp index 6c921c1..46d79c9 100644 --- a/backend/genesys/error.cpp +++ b/backend/genesys/error.cpp @@ -45,6 +45,7 @@ #include "error.h" #include <cstdarg> +#include <cstdlib> namespace genesys { @@ -212,4 +213,32 @@ void DebugMessageHelper::vlog(unsigned level, const char* format, ...) DBG(level, "%s: %s\n", func_, msg.c_str()); } +enum class LogImageDataStatus +{ + NOT_SET, + ENABLED, + DISABLED +}; + +static LogImageDataStatus s_log_image_data_setting = LogImageDataStatus::NOT_SET; + +LogImageDataStatus dbg_read_log_image_data_setting() +{ + auto* setting = std::getenv("SANE_DEBUG_GENESYS_IMAGE"); + if (!setting) + return LogImageDataStatus::DISABLED; + auto setting_int = std::strtol(setting, nullptr, 10); + if (setting_int == 0) + return LogImageDataStatus::DISABLED; + return LogImageDataStatus::ENABLED; +} + +bool dbg_log_image_data() +{ + if (s_log_image_data_setting == LogImageDataStatus::NOT_SET) { + s_log_image_data_setting = dbg_read_log_image_data_setting(); + } + return s_log_image_data_setting == LogImageDataStatus::ENABLED; +} + } // namespace genesys |