Skip to content

Commit

Permalink
drop custom prefix option (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud authored Feb 24, 2023
1 parent af8344b commit 1b59cb0
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 1,761 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ jobs:
defaults:
run:
shell: bash
name: Emscripten-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}
name: Emscripten-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
runs-on: ubuntu-latest
container: emscripten/emsdk
strategy:
fail-fast: true
matrix:
build_type: [Release, Debug]
extra: [no-custom-prefix, custom-prefix]
lib: [static]
std: [98, 11, 14, 17, 20]

Expand Down Expand Up @@ -49,7 +48,6 @@ jobs:
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install \
-DCMAKE_RANLIB=$(which emranlib) \
-DWITH_CUSTOM_PREFIX=${{matrix.extra == 'custom-prefix'}} \
-G Ninja \
-Werror
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ jobs:
defaults:
run:
shell: bash
name: GCC-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}
name: GCC-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
build_type: [Release, Debug]
extra: [no-custom-prefix, custom-prefix]
lib: [shared, static]
std: [98, 11, 14, 17, 20]

Expand Down Expand Up @@ -74,7 +73,6 @@ jobs:
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install \
-DWITH_CUSTOM_PREFIX=${{matrix.extra == 'custom-prefix'}} \
-G Ninja \
-Werror
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
build-msvc:
name: ${{matrix.msvc}}-${{matrix.arch}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}
name: ${{matrix.msvc}}-${{matrix.arch}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
runs-on: ${{matrix.os}}
defaults:
run:
Expand All @@ -17,7 +17,6 @@ jobs:
matrix:
arch: [Win32, x64]
build_type: [Debug, Release]
extra: [no-custom-prefix, custom-prefix]
lib: [shared, static]
msvc: [VS-16-2019, VS-17-2022]
# Visual Studio 17 2022 does not support C++11 and older language standard
Expand Down Expand Up @@ -106,7 +105,6 @@ jobs:
-DCMAKE_EXE_LINKER_FLAGS_RELEASE='/INCREMENTAL:NO /DEBUG' `
-DCMAKE_INSTALL_PREFIX:PATH=./install `
-DCMAKE_MSVC_RUNTIME_LIBRARY='MultiThreaded$<$<CONFIG:Debug>:Debug>DLL' `
-DWITH_CUSTOM_PREFIX=${{matrix.extra == 'custom-prefix'}} `
-G "${{matrix.generator}}" `
-Werror
Expand All @@ -129,18 +127,17 @@ jobs:
--target install
build-mingw:
name: ${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}
name: ${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
runs-on: windows-2022
env:
BUILDDIR: 'build_${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}'
BUILDDIR: 'build_${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}'
defaults:
run:
shell: msys2 {0}
strategy:
fail-fast: true
matrix:
build_type: [Debug]
extra: [no-custom-prefix, custom-prefix]
lib: [shared, static]
std: [98, 11, 14, 17, 20]
sys: [mingw32, mingw64]
Expand Down Expand Up @@ -183,7 +180,6 @@ jobs:
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_INSTALL_PREFIX:PATH=./install \
-DWITH_CUSTOM_PREFIX=${{matrix.extra == 'custom-prefix'}} \
-G Ninja \
-Werror
Expand Down
26 changes: 0 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ include (GNUInstallDirs)
option (BUILD_SHARED_LIBS "Build shared libraries" ON)
option (PRINT_UNSYMBOLIZED_STACK_TRACES
"Print file offsets in traces instead of symbolizing" OFF)
option (WITH_CUSTOM_PREFIX "Enable support for user-generated message prefixes" ON)
option (WITH_GFLAGS "Use gflags" ON)
option (WITH_GTEST "Use Google Test" ON)
option (WITH_PKGCONFIG "Enable pkg-config support" ON)
Expand Down Expand Up @@ -694,10 +693,6 @@ if (CYGWIN OR WIN32)
target_compile_definitions (glog PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES)
endif (CYGWIN OR WIN32)

if (WITH_CUSTOM_PREFIX)
target_compile_definitions (glog PUBLIC GLOG_CUSTOM_PREFIX_SUPPORT)
endif (WITH_CUSTOM_PREFIX)

set_target_properties (glog PROPERTIES PUBLIC_HEADER "${GLOG_PUBLIC_H}")

target_include_directories (glog BEFORE PUBLIC
Expand Down Expand Up @@ -781,27 +776,6 @@ if (BUILD_TESTING)

target_link_libraries (logging_unittest PRIVATE ${_GLOG_TEST_LIBS})

if (WITH_CUSTOM_PREFIX)
add_executable (logging_custom_prefix_unittest
src/logging_custom_prefix_unittest.cc
)

target_link_libraries (logging_custom_prefix_unittest PRIVATE ${_GLOG_TEST_LIBS})

add_test (NAME logging_custom_prefix
COMMAND logging_custom_prefix_unittest)

# FIXME: Skip flaky test
set_tests_properties (logging_custom_prefix PROPERTIES SKIP_REGULAR_EXPRESSION
"Check failed: time_ns within LogTimes::LOG_PERIOD_TOL_NS of LogTimes::LOG_PERIOD_NS")

if (APPLE)
# FIXME: Skip flaky test
set_property (TEST logging_custom_prefix APPEND PROPERTY SKIP_REGULAR_EXPRESSION
"unexpected new.*PASS\nTest with golden file failed. We'll try to show the diff:")
endif (APPLE)
endif (WITH_CUSTOM_PREFIX)

add_executable (stl_logging_unittest
src/stl_logging_unittest.cc
)
Expand Down
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,7 @@ Custom Log Prefix Format
~~~~~~~~~~~~~~~~~~~~~~~~

glog supports changing the format of the prefix attached to log messages by
receiving a user-provided callback to be used to generate such strings. That
feature must be enabled at compile time by the ``WITH_CUSTOM_PREFIX`` flag.
receiving a user-provided callback to be used to generate such strings.

For each log entry, the callback will be invoked with a ``LogMessageInfo``
struct containing the severity, filename, line number, thread ID, and time of
Expand Down
2 changes: 0 additions & 2 deletions bazel/glog.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
"-DHAVE_CXX11_NULLPTR_T",
"-DHAVE_STDINT_H",
"-DHAVE_STRING_H",
"-DGLOG_CUSTOM_PREFIX_SUPPORT",
"-I%s/glog_internal" % gendir,
] + (["-DHAVE_LIB_GFLAGS"] if with_gflags else [])

Expand Down Expand Up @@ -205,7 +204,6 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
"cleanup_with_absolute_prefix",
"cleanup_with_relative_prefix",
# "demangle", # Broken
# "logging_custom_prefix", # Broken
# "logging", # Broken
# "mock-log", # Broken
# "signalhandler", # Pointless
Expand Down
5 changes: 0 additions & 5 deletions src/glog/logging.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ struct GLOG_EXPORT LogMessageTime {
void CalcGmtOffset();
};

#ifdef GLOG_CUSTOM_PREFIX_SUPPORT
struct LogMessageInfo {
explicit LogMessageInfo(const char* const severity_,
const char* const filename_,
Expand All @@ -175,8 +174,6 @@ struct LogMessageInfo {

typedef void(*CustomPrefixCallback)(std::ostream& s, const LogMessageInfo& l, void* data);

#endif

@ac_google_end_namespace@


Expand Down Expand Up @@ -632,11 +629,9 @@ DECLARE_bool(log_utc_time);
// specified by argv0 in log outputs.
GLOG_EXPORT void InitGoogleLogging(const char* argv0);

#ifdef GLOG_CUSTOM_PREFIX_SUPPORT
GLOG_EXPORT void InitGoogleLogging(const char* argv0,
CustomPrefixCallback prefix_callback,
void* prefix_callback_data = NULL);
#endif

// Check if google's logging library has been initialized.
GLOG_EXPORT bool IsGoogleLoggingInitialized();
Expand Down
8 changes: 0 additions & 8 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,12 @@ static bool SendEmailInternal(const char*dest, const char *subject,
base::Logger::~Logger() {
}

#ifdef GLOG_CUSTOM_PREFIX_SUPPORT
namespace {
// Optional user-configured callback to print custom prefixes.
CustomPrefixCallback custom_prefix_callback = NULL;
// User-provided data to pass to the callback:
void* custom_prefix_callback_data = NULL;
}
#endif

namespace {

Expand Down Expand Up @@ -1687,9 +1685,7 @@ void LogMessage::Init(const char* file,
std::ios saved_fmt(NULL);
saved_fmt.copyfmt(stream());
stream().fill('0');
#ifdef GLOG_CUSTOM_PREFIX_SUPPORT
if (custom_prefix_callback == NULL) {
#endif
stream() << LogSeverityNames[severity][0];
if (FLAGS_log_year_in_prefix) {
stream() << setw(4) << 1900 + logmsgtime_.year();
Expand All @@ -1706,7 +1702,6 @@ void LogMessage::Init(const char* file,
<< static_cast<unsigned int>(GetTID()) << setfill('0')
<< ' '
<< data_->basename_ << ':' << data_->line_ << "] ";
#ifdef GLOG_CUSTOM_PREFIX_SUPPORT
} else {
custom_prefix_callback(
stream(),
Expand All @@ -1717,7 +1712,6 @@ void LogMessage::Init(const char* file,
);
stream() << " ";
}
#endif
stream().copyfmt(saved_fmt);
}
data_->num_prefix_chars_ = data_->stream_.pcount();
Expand Down Expand Up @@ -2649,15 +2643,13 @@ void InitGoogleLogging(const char* argv0) {
glog_internal_namespace_::InitGoogleLoggingUtilities(argv0);
}

#ifdef GLOG_CUSTOM_PREFIX_SUPPORT
void InitGoogleLogging(const char* argv0,
CustomPrefixCallback prefix_callback,
void* prefix_callback_data) {
custom_prefix_callback = prefix_callback;
custom_prefix_callback_data = prefix_callback_data;
InitGoogleLogging(argv0);
}
#endif

void ShutdownGoogleLogging() {
glog_internal_namespace_::ShutdownGoogleLoggingUtilities();
Expand Down
Loading

0 comments on commit 1b59cb0

Please sign in to comment.