Skip to content

Commit

Permalink
Revert "Implement logger interface"
Browse files Browse the repository at this point in the history
This reverts commit 60dd060.
The reason is that this commit introduced build problems on Windows and
there are some design decisions we should take a second look into.

Change-Id: Ia3e0da34b18e43fa593ec0eb2f4482bc18840ef5
  • Loading branch information
Rafael Telles authored and alinaliBQ committed Dec 13, 2023
1 parent 7379b8a commit 1cc2c62
Show file tree
Hide file tree
Showing 14 changed files with 0 additions and 1,304 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,6 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_definitions(NDEBUG)
endif()

add_compile_definitions(FMT_HEADER_ONLY)

include(ExternalProject)

message("Using spdlog from https://github.com/gabime/spdlog on tag v1.10.0")
ExternalProject_Add(
dep_spdlog
GIT_REPOSITORY "https://github.com/gabime/spdlog"
GIT_TAG "v1.10.0"
GIT_SHALLOW 1
UPDATE_COMMAND ""
PATCH_COMMAND ""
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/dep_spdlog-prefix/src/dep_spdlog-install
-DSPDLOG_BUILD_EXAMPLES=OFF
-DSPDLOG_BUILD_BENCH=OFF
-DSPDLOG_BUILD_TESTS=OFF
TEST_COMMAND ""
)

include_directories(${CMAKE_CURRENT_BINARY_DIR}/dep_spdlog-prefix/src/dep_spdlog/include)

# Fetch and include GTest
# Adapted from Google's documentation: https://google.github.io/googletest/quickstart-cmake.html#set-up-a-project
include(FetchContent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,14 @@
*/

#include "flight_sql_connection.h"
#include "odbcabstraction/utils.h"
#include <odbcabstraction/spd_logger.h>
#include <odbcabstraction/platform.h>
#include <odbcabstraction/utils.h>
#include <flight_sql/flight_sql_driver.h>


#define DEFAULT_MAXIMUM_FILE_SIZE 16777216

namespace driver {
namespace flight_sql {

using odbcabstraction::Connection;
using odbcabstraction::OdbcVersion;
using odbcabstraction::LogLevel;
using odbcabstraction::SPDLogger;

namespace {
LogLevel ToLogLevel(int64_t level) {
switch (level) {
case 0:
return LogLevel::TRACE;
case 1:
return LogLevel::DEBUG;
case 2:
return LogLevel::INFO;
case 3:
return LogLevel::WARN;
case 4:
return LogLevel::ERROR;
default:
return LogLevel::OFF;
}
}
}

FlightSqlDriver::FlightSqlDriver()
: diagnostics_("Apache Arrow", "Flight SQL", OdbcVersion::V_3),
Expand All @@ -58,52 +31,5 @@ odbcabstraction::Diagnostics &FlightSqlDriver::GetDiagnostics() {
void FlightSqlDriver::SetVersion(std::string version) {
version_ = std::move(version);
}

void FlightSqlDriver::RegisterLog(const std::string &configFileName) {
odbcabstraction::PropertyMap propertyMap;
driver::odbcabstraction::ReadConfigFile(propertyMap, configFileName);

auto log_enable_iterator = propertyMap.find(SPDLogger::LOG_ENABLED);

auto log_enabled = log_enable_iterator != propertyMap.end() ?
odbcabstraction::AsBool(log_enable_iterator->second) : false;

auto log_path_iterator = propertyMap.find(SPDLogger::LOG_PATH);

auto log_path =
log_path_iterator != propertyMap.end() ? log_path_iterator->second : "";

if (*log_enabled && !log_path.empty()) {
auto log_level_iterator = propertyMap.find(SPDLogger::LOG_LEVEL);

auto log_level =
log_level_iterator != propertyMap.end() ? std::stoi(log_level_iterator->second) : 1;

auto maximum_file_size_iterator = propertyMap.find(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(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, ToLogLevel(log_level));
odbcabstraction::Logger::SetInstance(std::move(logger));
} else {
std::unique_ptr<odbcabstraction::SPDLogger> logger (new odbcabstraction::SPDLogger());

logger->init(1, 1,
log_path, LogLevel::OFF);
odbcabstraction::Logger::SetInstance(std::move(logger));
}
}

} // namespace flight_sql
} // namespace driver
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class FlightSqlDriver : public odbcabstraction::Driver {
odbcabstraction::Diagnostics &GetDiagnostics() override;

void SetVersion(std::string version) override;

void RegisterLog(const std::string &configFileName) override;
};

}; // namespace flight_sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ add_library(odbcabstraction
include/odbcabstraction/diagnostics.h
include/odbcabstraction/error_codes.h
include/odbcabstraction/exceptions.h
include/odbcabstraction/logger.h
include/odbcabstraction/platform.h
include/odbcabstraction/spd_logger.h
include/odbcabstraction/types.h
include/odbcabstraction/utils.h
include/odbcabstraction/odbc_impl/AttributeUtils.h
Expand All @@ -34,11 +32,7 @@ add_library(odbcabstraction
diagnostics.cc
encoding.cc
exceptions.cc
logger.cc
spd_logger.cc
utils.cc
whereami.h
whereami.cc
odbc_impl/ODBCConnection.cc
odbc_impl/ODBCDescriptor.cc
odbc_impl/ODBCEnvironment.cc
Expand All @@ -51,7 +45,4 @@ set_target_properties(odbcabstraction
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>/lib
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>/lib
)

add_dependencies(odbcabstraction dep_spdlog)

target_link_libraries(odbcabstraction)

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class Driver {

/// \brief Sets the driver version.
virtual void SetVersion(std::string version) = 0;

/// \brief Register a log to be used by the system.
virtual void RegisterLog(const std::string &configFileName) = 0;
};

} // namespace odbcabstraction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@
#pragma once

#include <string>
#include <odbcabstraction/logger.h>
#include <odbcabstraction/spi/connection.h>

namespace driver {
namespace odbcabstraction {

typedef std::map<std::string, std::string>
PropertyMap;

using driver::odbcabstraction::Connection;

/// Parse a string value to a boolean.
Expand All @@ -40,8 +36,5 @@ boost::optional<bool> AsBool(const Connection::ConnPropertyMap& connPropertyMap,
/// \exception std::out_of_range exception from \link std::stoi \endlink
boost::optional<int32_t> AsInt32(int32_t min_value, const Connection::ConnPropertyMap& connPropertyMap,
const std::string& property_name);


void ReadConfigFile(PropertyMap &properties, const std::string &configFileName);
} // namespace odbcabstraction
} // namespace driver

This file was deleted.

Loading

0 comments on commit 1cc2c62

Please sign in to comment.