forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Replace spdlogs with Arrow Internal Logging
#104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6a1d493
Switch to use Arrow's logging
alinaliBQ 7be4440
Remove spdlog
alinaliBQ 74eebe3
Adhere to Arrow's logging
alinaliBQ f77bfda
Use Arrow Log to enable logging
alinaliBQ fca9832
Add `ARROW_USE_GLOG OFF` back
alinaliBQ 79fa39b
Add logging README
alinaliBQ 7345021
register kernel function conditionally
alinaliBQ c4c1bfc
Remove log files support
alinaliBQ fca3447
Address todos for PR
alinaliBQ 6f90723
Put whereami back
alinaliBQ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,46 +20,45 @@ | |
| #include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h" | ||
| #include "arrow/flight/sql/odbc/flight_sql/utils.h" | ||
| #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h" | ||
| #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spd_logger.h" | ||
| #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h" | ||
| #include "arrow/util/io_util.h" | ||
| #include "arrow/util/logging.h" | ||
|
|
||
| #define DEFAULT_MAXIMUM_FILE_SIZE 16777216 | ||
| #define CONFIG_FILE_NAME "arrow-odbc.ini" | ||
| #define CONFIG_FILE_PATH "CONFIG_FILE_PATH" | ||
| #define ODBC_LOG_LEVEL "ARROW_ODBC_LOG_LEVEL" | ||
|
|
||
| namespace driver { | ||
| namespace flight_sql { | ||
|
|
||
| using odbcabstraction::Connection; | ||
| using odbcabstraction::LogLevel; | ||
| using odbcabstraction::OdbcVersion; | ||
| using odbcabstraction::SPDLogger; | ||
| using arrow::util::ArrowLogLevel; | ||
|
|
||
| namespace { | ||
| LogLevel ToLogLevel(int64_t level) { | ||
| /// Return the corresponding ArrowLogLevel. Debug level is returned by default. | ||
| ArrowLogLevel ToLogLevel(int64_t level) { | ||
| switch (level) { | ||
| case -2: | ||
| return ArrowLogLevel::ARROW_TRACE; | ||
| case -1: | ||
| return ArrowLogLevel::ARROW_DEBUG; | ||
| case 0: | ||
| return LogLevel::LogLevel_TRACE; | ||
| return ArrowLogLevel::ARROW_INFO; | ||
| case 1: | ||
| return LogLevel::LogLevel_DEBUG; | ||
| return ArrowLogLevel::ARROW_WARNING; | ||
| case 2: | ||
| return LogLevel::LogLevel_INFO; | ||
| return ArrowLogLevel::ARROW_ERROR; | ||
| case 3: | ||
| return LogLevel::LogLevel_WARN; | ||
| case 4: | ||
| return LogLevel::LogLevel_ERROR; | ||
| return ArrowLogLevel::ARROW_FATAL; | ||
| default: | ||
| return LogLevel::LogLevel_OFF; | ||
| return ArrowLogLevel::ARROW_DEBUG; | ||
| } | ||
| } | ||
| } // namespace | ||
|
|
||
| namespace driver { | ||
| namespace flight_sql { | ||
|
|
||
| using odbcabstraction::Connection; | ||
| using odbcabstraction::OdbcVersion; | ||
|
|
||
| FlightSqlDriver::FlightSqlDriver() | ||
| : diagnostics_("Apache Arrow", "Flight SQL", OdbcVersion::V_3), version_("0.9.0.0") { | ||
| RegisterLog(); | ||
| // Register Kernel functions to library | ||
| ThrowIfNotOK(arrow::compute::Initialize()); | ||
| RegisterComputeKernels(); | ||
| } | ||
|
|
||
| std::shared_ptr<Connection> FlightSqlDriver::CreateConnection(OdbcVersion odbc_version) { | ||
|
|
@@ -70,53 +69,27 @@ odbcabstraction::Diagnostics& FlightSqlDriver::GetDiagnostics() { return diagnos | |
|
|
||
| void FlightSqlDriver::SetVersion(std::string version) { version_ = std::move(version); } | ||
|
|
||
| void FlightSqlDriver::RegisterLog() { | ||
| std::string config_path = arrow::internal::GetEnvVar(CONFIG_FILE_PATH).ValueOr(""); | ||
| if (config_path.empty()) { | ||
| return; | ||
| } | ||
|
|
||
| odbcabstraction::PropertyMap propertyMap; | ||
| driver::odbcabstraction::ReadConfigFile(propertyMap, config_path, CONFIG_FILE_NAME); | ||
|
|
||
| auto log_enable_iterator = propertyMap.find(std::string(SPDLogger::LOG_ENABLED)); | ||
| auto log_enabled = log_enable_iterator != propertyMap.end() | ||
| ? odbcabstraction::AsBool(log_enable_iterator->second) | ||
| : false; | ||
| if (!log_enabled.get()) { | ||
| return; | ||
| } | ||
| void FlightSqlDriver::RegisterComputeKernels() { | ||
| auto registry = arrow::compute::GetFunctionRegistry(); | ||
|
|
||
| auto log_path_iterator = propertyMap.find(std::string(SPDLogger::LOG_PATH)); | ||
| auto log_path = log_path_iterator != propertyMap.end() ? log_path_iterator->second : ""; | ||
| if (log_path.empty()) { | ||
| return; | ||
| // strptime is one of the required compute functions | ||
| auto strptime_func = registry->GetFunction("strptime"); | ||
| if (!strptime_func.ok()) { | ||
| // Register Kernel functions to library | ||
| ThrowIfNotOK(arrow::compute::Initialize()); | ||
| } | ||
| } | ||
|
Comment on lines
-85
to
+81
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function resolves the kernel registry issue |
||
|
|
||
| auto log_level_iterator = propertyMap.find(std::string(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) { | ||
| void FlightSqlDriver::RegisterLog() { | ||
| std::string log_level_str = arrow::internal::GetEnvVar(ODBC_LOG_LEVEL).ValueOr(""); | ||
| if (log_level_str.empty()) { | ||
| return; | ||
| } | ||
| auto log_level = ToLogLevel(std::stoi(log_level_str)); | ||
|
|
||
| auto maximum_file_size_iterator = | ||
| propertyMap.find(std::string(SPDLogger::MAXIMUM_FILE_SIZE)); | ||
| auto maximum_file_size = maximum_file_size_iterator != propertyMap.end() | ||
| ? std::stoi(maximum_file_size_iterator->second) | ||
| : DEFAULT_MAXIMUM_FILE_SIZE; | ||
|
|
||
| auto maximum_file_quantity_iterator = | ||
| propertyMap.find(std::string(SPDLogger::FILE_QUANTITY)); | ||
| auto maximum_file_quantity = maximum_file_quantity_iterator != propertyMap.end() | ||
| ? std::stoi(maximum_file_quantity_iterator->second) | ||
| : 1; | ||
|
|
||
| std::unique_ptr<odbcabstraction::SPDLogger> logger(new odbcabstraction::SPDLogger()); | ||
|
|
||
| logger->init(maximum_file_quantity, maximum_file_size, log_path, log_level); | ||
| odbcabstraction::Logger::SetInstance(std::move(logger)); | ||
| // Enable driver logging. Log files are not supported on Windows yet, since GLOG is not | ||
| // tested fully on Windows. | ||
| arrow::util::ArrowLog::StartArrowLog("arrow-flight-sql-odbc", log_level); | ||
| } | ||
|
|
||
| } // namespace flight_sql | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main file to review