alinaliBQ commented on code in PR #47645:
URL: https://github.com/apache/arrow/pull/47645#discussion_r2388908983
##########
cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_driver.cc:
##########
@@ -63,45 +53,36 @@ odbcabstraction::Diagnostics&
FlightSqlDriver::GetDiagnostics() { return diagnos
void FlightSqlDriver::SetVersion(std::string version) { version_ =
std::move(version); }
void FlightSqlDriver::RegisterLog() {
- odbcabstraction::PropertyMap propertyMap;
- driver::odbcabstraction::ReadConfigFile(propertyMap, CONFIG_FILE_NAME);
-
- auto log_enable_iterator = propertyMap.find(SPDLogger::LOG_ENABLED);
- auto log_enabled = log_enable_iterator != propertyMap.end()
- ? odbcabstraction::AsBool(log_enable_iterator->second)
- : false;
- if (!log_enabled) {
+ std::string log_level_str = arrow::internal::GetEnvVar(kODBCLogLevel)
+ .Map(arrow::internal::AsciiToLower)
+ .Map(arrow::internal::TrimString)
+ .ValueOr("");
+ if (log_level_str.empty()) {
return;
}
- auto log_path_iterator = propertyMap.find(SPDLogger::LOG_PATH);
- auto log_path = log_path_iterator != propertyMap.end() ?
log_path_iterator->second : "";
- if (log_path.empty()) {
- return;
+ auto log_level = ArrowLogLevel::ARROW_DEBUG;
+
+ if (log_level_str == "fatal") {
+ log_level = ArrowLogLevel::ARROW_FATAL;
+ } else if (log_level_str == "error") {
+ log_level = ArrowLogLevel::ARROW_ERROR;
+ } else if (log_level_str == "warning") {
+ log_level = ArrowLogLevel::ARROW_WARNING;
+ } else if (log_level_str == "info") {
+ log_level = ArrowLogLevel::ARROW_INFO;
+ } else if (log_level_str == "debug") {
+ log_level = ArrowLogLevel::ARROW_DEBUG;
+ } else if (log_level_str == "trace") {
+ log_level = ArrowLogLevel::ARROW_TRACE;
}
- auto log_level_iterator = propertyMap.find(SPDLogger::LOG_LEVEL);
- auto log_level = ToLogLevel(log_level_iterator != propertyMap.end()
- ? std::stoi(log_level_iterator->second)
- : 1);
- if (log_level == odbcabstraction::LogLevel_OFF) {
- return;
+ // Enable driver logging. Log files are not supported on Windows yet, since
GLOG is not
+ // tested fully on Windows.
+ // Info log level is enabled by default.
+ if (log_level != ArrowLogLevel::ARROW_INFO) {
Review Comment:
I agree that let's revisit this later. We do want to enable all kinds of
logging. This condition is actually more for tests, I found that the enable log
command was called multiple times, so I added this condition in hopes to reduce
the number of times the logging starts.
##########
cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_driver.cc:
##########
@@ -63,45 +53,36 @@ odbcabstraction::Diagnostics&
FlightSqlDriver::GetDiagnostics() { return diagnos
void FlightSqlDriver::SetVersion(std::string version) { version_ =
std::move(version); }
void FlightSqlDriver::RegisterLog() {
- odbcabstraction::PropertyMap propertyMap;
- driver::odbcabstraction::ReadConfigFile(propertyMap, CONFIG_FILE_NAME);
-
- auto log_enable_iterator = propertyMap.find(SPDLogger::LOG_ENABLED);
- auto log_enabled = log_enable_iterator != propertyMap.end()
- ? odbcabstraction::AsBool(log_enable_iterator->second)
- : false;
- if (!log_enabled) {
+ std::string log_level_str = arrow::internal::GetEnvVar(kODBCLogLevel)
+ .Map(arrow::internal::AsciiToLower)
+ .Map(arrow::internal::TrimString)
+ .ValueOr("");
+ if (log_level_str.empty()) {
return;
}
- auto log_path_iterator = propertyMap.find(SPDLogger::LOG_PATH);
- auto log_path = log_path_iterator != propertyMap.end() ?
log_path_iterator->second : "";
- if (log_path.empty()) {
- return;
+ auto log_level = ArrowLogLevel::ARROW_DEBUG;
+
+ if (log_level_str == "fatal") {
+ log_level = ArrowLogLevel::ARROW_FATAL;
+ } else if (log_level_str == "error") {
+ log_level = ArrowLogLevel::ARROW_ERROR;
+ } else if (log_level_str == "warning") {
+ log_level = ArrowLogLevel::ARROW_WARNING;
+ } else if (log_level_str == "info") {
+ log_level = ArrowLogLevel::ARROW_INFO;
+ } else if (log_level_str == "debug") {
+ log_level = ArrowLogLevel::ARROW_DEBUG;
+ } else if (log_level_str == "trace") {
+ log_level = ArrowLogLevel::ARROW_TRACE;
}
- auto log_level_iterator = propertyMap.find(SPDLogger::LOG_LEVEL);
- auto log_level = ToLogLevel(log_level_iterator != propertyMap.end()
- ? std::stoi(log_level_iterator->second)
- : 1);
- if (log_level == odbcabstraction::LogLevel_OFF) {
- return;
+ // Enable driver logging. Log files are not supported on Windows yet, since
GLOG is not
+ // tested fully on Windows.
+ // Info log level is enabled by default.
+ if (log_level != ArrowLogLevel::ARROW_INFO) {
Review Comment:
I agree that let's revisit this later. We do want to enable all kinds of
logging. This condition is actually more for tests, not for disabling logging.
I found that the enable log command was called multiple times, so I added this
condition in hopes to reduce the number of times the logging starts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]