Skip to content

Commit

Permalink
Replace glog with boost.log
Browse files Browse the repository at this point in the history
 - Investigate alternative logging frameworks to glog: Boost.Log.
 - Implement in Shared/Logger.{h,cpp}
 - Support both file and console (std::clog) sinks.
 - Replaced #include <glog/logging.h> with #include "Shared/Logger.h"
 - Removed logging from Calcite destructor which caused problems on shutdown.
 - Move std::ostream operator<<() overloads into their namespaces to allow for ADL.
 - Print Boost version in cmake.
 - Don't log when __CUDACC__ is defined.
 - Move always_assert.h logic into Logger.h and delete file.
 - Move unreachable.h logic into Logger.h and delete file.
 - Fix casting in numerous places. Warnings were previously suppressed by glog.
  • Loading branch information
mattpulver authored and andrewseidl committed Jun 20, 2019
1 parent 6206a6d commit cf7e1fc
Show file tree
Hide file tree
Showing 186 changed files with 1,207 additions and 723 deletions.
2 changes: 0 additions & 2 deletions Analyzer/Analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
#include "../Shared/sql_type_to_string.h"
#include "../Shared/sql_window_function_to_string.h"
#include "../Shared/sqltypes.h"
#include "../Shared/unreachable.h"
#include "RangeTableEntry.h"

#include <glog/logging.h>
#include <algorithm>
#include <cstring>
#include <iostream>
Expand Down
4 changes: 3 additions & 1 deletion Analyzer/Analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#ifndef ANALYZER_H
#define ANALYZER_H

#include <glog/logging.h>
#include "../Shared/Logger.h"

#include <cstdint>
#include <iostream>
#include <list>
Expand All @@ -33,6 +34,7 @@
#include <type_traits>
#include <utility>
#include <vector>

#include "../Shared/sqldefs.h"
#include "../Shared/sqltypes.h"

Expand Down
2 changes: 1 addition & 1 deletion Archive/S3Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/
#include "S3Archive.h"
#include <glog/logging.h>
#include <atomic>
#include <boost/filesystem.hpp>
#include "Shared/Logger.h"

#include <aws/core/Aws.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
Expand Down
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ if(PREFER_STATIC_LIBS)
endif()

set(CUDA_USE_STATIC_CUDA_RUNTIME ON CACHE STRING "Use static CUDA runtime")
else()
add_definitions("-DBOOST_LOG_DYN_LINK")
endif()

option(ENABLE_JAVA_REMOTE_DEBUG "Enable Java Remote Debug" OFF )
Expand Down Expand Up @@ -109,6 +111,11 @@ else()
set(MAPD_PACKAGE_FLAGS "${MAPD_PACKAGE_FLAGS}-cpu")
endif()

option(SUPPRESS_NULL_LOGGER_DEPRECATION_WARNINGS "Suppress NullLogger deprecated warnings.")
if (SUPPRESS_NULL_LOGGER_DEPRECATION_WARNINGS)
add_definitions("-DSUPPRESS_NULL_LOGGER_DEPRECATION_WARNINGS")
endif()

option(ENABLE_CUDA_KERNEL_DEBUG "Enable debugging symbols for CUDA device Kernels" OFF)

option(ENABLE_JIT_DEBUG "Enable debugging symbols for the JIT" OFF)
Expand Down Expand Up @@ -155,6 +162,7 @@ if(ENABLE_FOLLY)
else()
include_directories(${Folly_INCLUDE_DIRS})
add_definitions("-DHAVE_FOLLY")
list(APPEND Folly_LIBRARIES ${Glog_LIBRARIES})
endif()
endif()

Expand All @@ -168,7 +176,7 @@ set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
if(APPLE OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.6 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 3.6))
OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9))
find_package( Boost COMPONENTS filesystem program_options regex system timer REQUIRED QUIET )
find_package( Boost COMPONENTS log log_setup filesystem program_options regex system thread timer REQUIRED )
else()
message(FATAL_ERROR, "GCC v4.9 or clang v3.6 (or newer) is required")
endif()
Expand Down Expand Up @@ -564,9 +572,9 @@ add_custom_target(rerun_cmake ALL
)
add_dependencies(omnisci_server rerun_cmake)

target_link_libraries(omnisci_server mapd_thrift thrift_handler ${MAPD_LIBRARIES} ${Boost_LIBRARIES} ${Glog_LIBRARIES} ${CMAKE_DL_LIBS} ${CUDA_LIBRARIES} ${LLVM_LINKER_FLAGS} ${PROFILER_LIBS} ${CURSES_LIBRARIES} ${ZLIB_LIBRARIES})
target_link_libraries(omnisci_server mapd_thrift thrift_handler ${MAPD_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${CUDA_LIBRARIES} ${LLVM_LINKER_FLAGS} ${PROFILER_LIBS} ${CURSES_LIBRARIES} ${ZLIB_LIBRARIES})

target_link_libraries(initdb mapd_thrift DataMgr ${MAPD_LIBRARIES} ${Boost_LIBRARIES} ${Glog_LIBRARIES} ${CMAKE_DL_LIBS} ${CUDA_LIBRARIES} ${LLVM_LINKER_FLAGS} ${CURSES_LIBRARIES} ${ZLIB_LIBRARIES})
target_link_libraries(initdb mapd_thrift DataMgr ${MAPD_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${CUDA_LIBRARIES} ${LLVM_LINKER_FLAGS} ${CURSES_LIBRARIES} ${ZLIB_LIBRARIES})

macro(set_dpkg_arch arch_in arch_out)
if("${arch_in}" STREQUAL "x86_64")
Expand Down
16 changes: 7 additions & 9 deletions Calcite/Calcite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
*/

#include "Calcite.h"
#include <glog/logging.h>
#include <thread>
#include <utility>
#include "Catalog/Catalog.h"
#include "Shared/ConfigResolve.h"
#include "Shared/Logger.h"
#include "Shared/mapd_shared_ptr.h"
#include "Shared/mapdpath.h"
#include "Shared/measure.h"
#include "Shared/unreachable.h"

#include "Shared/fixautotools.h"

Expand Down Expand Up @@ -459,6 +458,7 @@ TPlanResult Calcite::processImpl(
LOG(FATAL)
<< "Error occurred trying to communicate with calcite server, the error was: '"
<< ex.what() << "', omnisci_server restart will be required";
return ret; // satisfy return-type warning
}
} else {
LOG(INFO) << "Not routing to Calcite, server is not up";
Expand Down Expand Up @@ -505,24 +505,22 @@ std::string Calcite::getUserDefinedFunctionWhitelist() {
return "";
}

void Calcite::close_calcite_server() {
void Calcite::close_calcite_server(bool log) {
if (server_available_) {
LOG(INFO) << "Shutting down Calcite server";
LOG_IF(INFO, log) << "Shutting down Calcite server";
try {
std::pair<mapd::shared_ptr<CalciteServerClient>, mapd::shared_ptr<TTransport>>
clientP = get_client(remote_calcite_port_);
clientP.first->shutdown();
clientP.second->close();
} catch (const std::exception& e) {
LOG(ERROR) << "Error shutting down Calcite server: " << e.what();
std::cerr << "Error shutting down Calcite server: " << e.what();
}
LOG(INFO) << "shut down Calcite";
LOG_IF(INFO, log) << "shut down Calcite";
server_available_ = false;
}
}

Calcite::~Calcite() {
LOG(INFO) << "Destroy Calcite Class";
close_calcite_server();
LOG(INFO) << "End of Calcite Destructor ";
close_calcite_server(false);
}
2 changes: 1 addition & 1 deletion Calcite/Calcite.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Calcite {
std::string getExtensionFunctionWhitelist();
std::string getUserDefinedFunctionWhitelist();
void updateMetadata(std::string catalog, std::string table);
void close_calcite_server();
void close_calcite_server(bool log = true);
virtual ~Calcite();

std::string& get_session_prefix() { return session_prefix_; }
Expand Down
2 changes: 1 addition & 1 deletion Catalog/DBObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#ifndef DBOBJECT_H
#define DBOBJECT_H

#include <glog/logging.h>
#include <string>
#include <unordered_set>
#include "Shared/Logger.h"

namespace Catalog_Namespace {
class Catalog;
Expand Down
2 changes: 1 addition & 1 deletion Catalog/Grantee.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

#include "DBObject.h"

#include <glog/logging.h>
#include <boost/algorithm/string.hpp>
#include <boost/make_unique.hpp>
#include <map>
#include <string>
#include <unordered_set>
#include "Shared/Logger.h"

class User;
class Role;
Expand Down
7 changes: 3 additions & 4 deletions Catalog/SessionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ std::string SessionInfo::public_session_id() const {
return ss.str();
}

} // namespace Catalog_Namespace

std::ostream& operator<<(std::ostream& os,
const Catalog_Namespace::SessionInfo& session_info) {
std::ostream& operator<<(std::ostream& os, const SessionInfo& session_info) {
os << session_info.get_public_session_id();
return os;
}

} // namespace Catalog_Namespace
5 changes: 2 additions & 3 deletions Catalog/SessionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ class SessionInfo {
std::string public_session_id() const;
};

} // namespace Catalog_Namespace
std::ostream& operator<<(std::ostream& os, const SessionInfo& session_info);

std::ostream& operator<<(std::ostream& os,
const Catalog_Namespace::SessionInfo& session_info);
} // namespace Catalog_Namespace

#endif /* SESSION_INFO_H */
2 changes: 1 addition & 1 deletion Catalog/SharedDictionaryValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <memory>

#include "../Shared/unreachable.h"
#include "Shared/Logger.h"

const Parser::SharedDictionaryDef compress_reference_path(
Parser::SharedDictionaryDef cur_node,
Expand Down
2 changes: 1 addition & 1 deletion CudaMgr/CudaMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

#include "CudaMgr.h"
#include <cuda_runtime.h>
#include <glog/logging.h>
#include <algorithm>
#include <cassert>
#include <iostream>
#include <stdexcept>
#include "Shared/Logger.h"

namespace CudaMgr_Namespace {

Expand Down
2 changes: 1 addition & 1 deletion CudaMgr/CudaMgrNoCuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#include <glog/logging.h>
#include "CudaMgr.h"
#include "Shared/Logger.h"

namespace CudaMgr_Namespace {

Expand Down
6 changes: 3 additions & 3 deletions DataMgr/AbstractBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#ifndef DATAMGR_MEMORY_ABSTRACTBUFFER_H
#define DATAMGR_MEMORY_ABSTRACTBUFFER_H

#include <glog/logging.h>
#include "../Shared/sqltypes.h"
#include "../Shared/types.h"
#include "Encoder.h"
#include "MemoryLevel.h"
#include "Shared/Logger.h"
#include "Shared/sqltypes.h"
#include "Shared/types.h"

#ifdef BUFFER_MUTEX
#include <boost/thread/locks.hpp>
Expand Down
3 changes: 2 additions & 1 deletion DataMgr/ArrayNoneEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#ifndef ARRAY_NONE_ENCODER_H
#define ARRAY_NONE_ENCODER_H

#include <glog/logging.h>
#include "Shared/Logger.h"

#include <cassert>
#include <cstring>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion DataMgr/BufferMgr/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
//
// Copyright (c) 2014 MapD Technologies, Inc. All rights reserved.
//
#include <glog/logging.h>
#include <cassert>
#include <stdexcept>

#include "Buffer.h"
#include "BufferMgr.h"
#include "Shared/Logger.h"

namespace Buffer_Namespace {

Expand Down
2 changes: 1 addition & 1 deletion DataMgr/BufferMgr/BufferMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
*/
#include "BufferMgr.h"
#include "Buffer.h"
#include "Shared/Logger.h"
#include "Shared/measure.h"

#include <glog/logging.h>
#include <algorithm>
#include <iomanip>
#include <limits>
Expand Down
2 changes: 1 addition & 1 deletion DataMgr/BufferMgr/CpuBufferMgr/CpuBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/

#include "CpuBuffer.h"
#include <glog/logging.h>
#include <cassert>
#include <cstring>
#include "../../../CudaMgr/CudaMgr.h"
#include "Shared/Logger.h"

namespace Buffer_Namespace {

Expand Down
1 change: 0 additions & 1 deletion DataMgr/BufferMgr/CpuBufferMgr/CpuBufferMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

#include "CpuBufferMgr.h"
#include <glog/logging.h>
#include "../../../CudaMgr/CudaMgr.h"
#include "CpuBuffer.h"

Expand Down
2 changes: 1 addition & 1 deletion DataMgr/BufferMgr/GpuCudaBufferMgr/GpuCudaBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

#include "GpuCudaBuffer.h"
#include "../../../CudaMgr/CudaMgr.h"
#include "Shared/Logger.h"

#include <glog/logging.h>
#include <cassert>

namespace Buffer_Namespace {
Expand Down
2 changes: 1 addition & 1 deletion DataMgr/BufferMgr/GpuCudaBufferMgr/GpuCudaBufferMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/

#include "GpuCudaBufferMgr.h"
#include <glog/logging.h>
#include "../../../CudaMgr/CudaMgr.h"
#include "GpuCudaBuffer.h"
#include "Shared/Logger.h"
//#include "../CudaUtils.h"

namespace Buffer_Namespace {
Expand Down
2 changes: 1 addition & 1 deletion DataMgr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(datamgr_source_files

add_library(DataMgr ${datamgr_source_files})

target_link_libraries(DataMgr CudaMgr Shared ${Boost_THREAD_LIBRARY} ${Glog_LIBRARIES})
target_link_libraries(DataMgr CudaMgr Shared ${Boost_THREAD_LIBRARY})

option(ENABLE_CRASH_CORRUPTION_TEST "Enable crash using SIGUSR2 during page deletion to faster and affirmative test/repro db corruption" OFF)
if(ENABLE_CRASH_CORRUPTION_TEST)
Expand Down
2 changes: 1 addition & 1 deletion DataMgr/ChunkMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <cstddef>
#include "../Shared/sqltypes.h"

#include <glog/logging.h>
#include "Shared/Logger.h"

struct ChunkStats {
Datum min;
Expand Down
5 changes: 3 additions & 2 deletions DataMgr/DateDaysEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#ifndef DATE_DAYS_ENCODER_H
#define DATE_DAYS_ENCODER_H

#include <glog/logging.h>
#include "Shared/Logger.h"

#include <iostream>
#include <memory>
#include "AbstractBuffer.h"
Expand Down Expand Up @@ -154,4 +155,4 @@ class DateDaysEncoder : public Encoder {

}; // DateDaysEncoder

#endif // DATE_DAYS_ENCODER_H
#endif // DATE_DAYS_ENCODER_H
2 changes: 1 addition & 1 deletion DataMgr/Encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/

#include "Encoder.h"
#include <glog/logging.h>
#include "ArrayNoneEncoder.h"
#include "DateDaysEncoder.h"
#include "FixedLengthArrayNoneEncoder.h"
#include "FixedLengthEncoder.h"
#include "NoneEncoder.h"
#include "Shared/Logger.h"
#include "StringNoneEncoder.h"

Encoder* Encoder::Create(Data_Namespace::AbstractBuffer* buffer,
Expand Down
1 change: 0 additions & 1 deletion DataMgr/FileMgr/FileBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

#include "FileBuffer.h"
#include <glog/logging.h>
#include <future>
#include <map>
#include <thread>
Expand Down
Loading

0 comments on commit cf7e1fc

Please sign in to comment.