默认参数日志控制输出

This commit is contained in:
gb 2022-11-10 11:09:16 +08:00
parent 4277129106
commit 860f603aa0
3 changed files with 22 additions and 10 deletions

View File

@ -1653,7 +1653,7 @@ int hg_scanner_239::get_sleep_time(int& getime)
getime = val; getime = val;
save_sleeptime_type_ = true; save_sleeptime_type_ = true;
} }
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "get_sleep_time %d= %s\n", val,hg_scanner_err_name(ret)); VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "get_sleep_time = %d with %s\n", val,hg_scanner_err_name(ret));
return ret; return ret;
} }

View File

@ -1143,7 +1143,7 @@ bool hg_sane_middleware::get_current_value(scanner_handle handle, int option, vo
return ret; return ret;
} }
void* hg_sane_middleware::get_default_value(scanner_handle handle, int option, int* bytes) void* hg_sane_middleware::get_default_value(scanner_handle handle, int option, int* bytes, bool log)
{ {
std::string val(get_option_json(handle, option)); std::string val(get_option_json(handle, option));
void* data = nullptr; void* data = nullptr;
@ -1163,7 +1163,10 @@ void* hg_sane_middleware::get_default_value(scanner_handle handle, int option, i
memcpy(data, &v, sizeof(v)); memcpy(data, &v, sizeof(v));
if (bytes) if (bytes)
*bytes = sizeof(SANE_Bool); *bytes = sizeof(SANE_Bool);
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "option %d(%s) default value is: %s\n", option, title.c_str(), v ? "true" : "false"); if (log)
{
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "option %d(%s) default value is: %s\n", option, title.c_str(), v ? "true" : "false");
}
} }
else if (val == "int") else if (val == "int")
{ {
@ -1174,7 +1177,10 @@ void* hg_sane_middleware::get_default_value(scanner_handle handle, int option, i
memcpy(data, &v, sizeof(v)); memcpy(data, &v, sizeof(v));
if (bytes) if (bytes)
*bytes = sizeof(v); *bytes = sizeof(v);
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "option %d(%s) default value is: %d\n", option, title.c_str(), v); if (log)
{
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "option %d(%s) default value is: %d\n", option, title.c_str(), v);
}
} }
else if (val == "float") else if (val == "float")
{ {
@ -1187,7 +1193,10 @@ void* hg_sane_middleware::get_default_value(scanner_handle handle, int option, i
*bytes = sizeof(sd); *bytes = sizeof(sd);
memcpy(data, &sd, sizeof(sd)); memcpy(data, &sd, sizeof(sd));
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "option %d(%s) default value is: %f\n", option, title.c_str(), v); if (log)
{
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "option %d(%s) default value is: %f\n", option, title.c_str(), v);
}
} }
else if (val == "string") else if (val == "string")
{ {
@ -1203,7 +1212,10 @@ void* hg_sane_middleware::get_default_value(scanner_handle handle, int option, i
strcpy((char*)data, val.c_str()); strcpy((char*)data, val.c_str());
if (bytes) if (bytes)
*bytes = val.length(); *bytes = val.length();
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "option %d(%s) default value is: %s\n", option, title.c_str(), (char*)data); if (log)
{
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "option %d(%s) default value is: %s\n", option, title.c_str(), (char*)data);
}
} }
else else
{ {
@ -1562,14 +1574,14 @@ bool hg_sane_middleware::get_cur_value(SANE_Handle handle, int option, void* val
return get_current_value(h, option, value, type); return get_current_value(h, option, value, type);
} }
void* hg_sane_middleware::get_def_value(SANE_Handle handle, int option, int* bytes) void* hg_sane_middleware::get_def_value(SANE_Handle handle, int option, int* bytes, bool log)
{ {
scanner_handle h = find_openning_device(handle); scanner_handle h = find_openning_device(handle);
if (!h) if (!h)
return NULL; return NULL;
return get_default_value(h, option, bytes); return get_default_value(h, option, bytes, log);
} }
SANE_Status hg_sane_middleware::io_control(SANE_Handle h, unsigned long code, void* data, unsigned* len) SANE_Status hg_sane_middleware::io_control(SANE_Handle h, unsigned long code, void* data, unsigned* len)
{ {

View File

@ -83,7 +83,7 @@ class hg_sane_middleware
void reload_current_value(scanner_handle handle, std::vector<std::string>* changed = NULL); void reload_current_value(scanner_handle handle, std::vector<std::string>* changed = NULL);
bool get_current_value(scanner_handle handle, int option, void* value, SANE_Value_Type* type = NULL); bool get_current_value(scanner_handle handle, int option, void* value, SANE_Value_Type* type = NULL);
void* get_default_value(scanner_handle handle, int option, int* bytes = nullptr); // caller should call local_utility::free_memory to free the returned value void* get_default_value(scanner_handle handle, int option, int* bytes = nullptr, bool log = false); // caller should call local_utility::free_memory to free the returned value
/// <summary> /// <summary>
/// 关联项处理 /// 关联项处理
@ -189,7 +189,7 @@ public:
SANE_Option_Descriptor* get_option_descriptor(SANE_Handle h, SANE_Int option); SANE_Option_Descriptor* get_option_descriptor(SANE_Handle h, SANE_Int option);
SANE_Status set_option(SANE_Handle h, SANE_Int option, SANE_Action action, void* value, SANE_Int* after_do); SANE_Status set_option(SANE_Handle h, SANE_Int option, SANE_Action action, void* value, SANE_Int* after_do);
bool get_cur_value(SANE_Handle handle, int option, void* value, SANE_Value_Type* type = NULL); // SANE_type bool get_cur_value(SANE_Handle handle, int option, void* value, SANE_Value_Type* type = NULL); // SANE_type
void* get_def_value(SANE_Handle handle, int option, int* bytes = nullptr); // caller should call local_utility::free_memory to free the returned value, SANE_type void* get_def_value(SANE_Handle handle, int option, int* bytes = nullptr, bool log = false); // caller should call local_utility::free_memory to free the returned value, SANE_type
// extension ... // extension ...
SANE_Status io_control(SANE_Handle h, unsigned long code, void* data, unsigned* len); SANE_Status io_control(SANE_Handle h, unsigned long code, void* data, unsigned* len);