feat: make headers self-contained (#1030)
This commit is contained in:
parent
dfce35c97c
commit
8775a454c1
1
.github/workflows/linux.yml
vendored
1
.github/workflows/linux.yml
vendored
@ -128,7 +128,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd build_${{matrix.build_type}}
|
cd build_${{matrix.build_type}}
|
||||||
gcovr -r .. . -s --xml coverage.xml
|
gcovr -r .. . -s --xml coverage.xml
|
||||||
cd ..
|
|
||||||
|
|
||||||
- name: Upload Coverage to Codecov
|
- name: Upload Coverage to Codecov
|
||||||
if: matrix.build_type == 'Debug'
|
if: matrix.build_type == 'Debug'
|
||||||
|
|||||||
2
.github/workflows/macos.yml
vendored
2
.github/workflows/macos.yml
vendored
@ -63,8 +63,8 @@ jobs:
|
|||||||
if: matrix.build_type == 'Debug'
|
if: matrix.build_type == 'Debug'
|
||||||
run: |
|
run: |
|
||||||
cd build_${{matrix.build_type}}
|
cd build_${{matrix.build_type}}
|
||||||
|
rm -r Tests/
|
||||||
gcovr -r .. . -s --cobertura coverage.xml
|
gcovr -r .. . -s --cobertura coverage.xml
|
||||||
cd ..
|
|
||||||
|
|
||||||
- name: Upload Coverage to Codecov
|
- name: Upload Coverage to Codecov
|
||||||
if: matrix.build_type == 'Debug'
|
if: matrix.build_type == 'Debug'
|
||||||
|
|||||||
1
.github/workflows/windows.yml
vendored
1
.github/workflows/windows.yml
vendored
@ -231,7 +231,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd build_${{matrix.build_type}}
|
cd build_${{matrix.build_type}}
|
||||||
gcovr -r .. . -s --cobertura coverage.xml
|
gcovr -r .. . -s --cobertura coverage.xml
|
||||||
cd ..
|
|
||||||
|
|
||||||
- name: Upload Coverage to Codecov
|
- name: Upload Coverage to Codecov
|
||||||
if: matrix.build_type == 'Debug'
|
if: matrix.build_type == 'Debug'
|
||||||
|
|||||||
@ -354,6 +354,8 @@ set (GLOG_PUBLIC_H
|
|||||||
src/glog/platform.h
|
src/glog/platform.h
|
||||||
src/glog/raw_logging.h
|
src/glog/raw_logging.h
|
||||||
src/glog/stl_logging.h
|
src/glog/stl_logging.h
|
||||||
|
src/glog/types.h
|
||||||
|
src/glog/flags.h
|
||||||
src/glog/vlog_is_on.h
|
src/glog/vlog_is_on.h
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -363,6 +365,7 @@ set (GLOG_SRCS
|
|||||||
src/base/googleinit.h
|
src/base/googleinit.h
|
||||||
src/demangle.cc
|
src/demangle.cc
|
||||||
src/demangle.h
|
src/demangle.h
|
||||||
|
src/flags.cc
|
||||||
src/logging.cc
|
src/logging.cc
|
||||||
src/raw_logging.cc
|
src/raw_logging.cc
|
||||||
src/signalhandler.cc
|
src/signalhandler.cc
|
||||||
@ -787,10 +790,6 @@ if (BUILD_TESTING)
|
|||||||
PROPERTIES WILL_FAIL ON
|
PROPERTIES WILL_FAIL ON
|
||||||
)
|
)
|
||||||
|
|
||||||
set (_glog_TEST_ENVIRONMENT
|
|
||||||
glog_ROOT=${glog_BINARY_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_test (NAME log_severity_constants COMMAND ${CMAKE_CTEST_COMMAND}
|
add_test (NAME log_severity_constants COMMAND ${CMAKE_CTEST_COMMAND}
|
||||||
--build-config $<CONFIG>
|
--build-config $<CONFIG>
|
||||||
--build-and-test
|
--build-and-test
|
||||||
@ -804,9 +803,9 @@ if (BUILD_TESTING)
|
|||||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||||
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
||||||
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
|
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
|
||||||
|
-Dglog_DIR=${glog_BINARY_DIR}
|
||||||
)
|
)
|
||||||
set_tests_properties (log_severity_constants PROPERTIES
|
set_tests_properties (log_severity_constants PROPERTIES
|
||||||
ENVIRONMENT "${_glog_TEST_ENVIRONMENT}"
|
|
||||||
PASS_REGULAR_EXPRESSION "COMPACT_GOOGLE_LOG_[1-3]"
|
PASS_REGULAR_EXPRESSION "COMPACT_GOOGLE_LOG_[1-3]"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -823,9 +822,7 @@ if (BUILD_TESTING)
|
|||||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||||
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
||||||
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
|
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
|
||||||
)
|
-Dglog_DIR=${glog_BINARY_DIR}
|
||||||
set_tests_properties (log_severity_conversion PROPERTIES
|
|
||||||
ENVIRONMENT "${_glog_TEST_ENVIRONMENT}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
@ -842,13 +839,75 @@ if (BUILD_TESTING)
|
|||||||
)
|
)
|
||||||
else (CMAKE_COMPILER_IS_GNUCXX)
|
else (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
message (AUTHOR_WARNING
|
message (AUTHOR_WARNING
|
||||||
"Unsuuported C++ compiler ${CMAKE_CXX_COMPILER_ID}: "
|
"Unsupported C++ compiler ${CMAKE_CXX_COMPILER_ID}: "
|
||||||
"log_severity_conversion test will be disabled"
|
"log_severity_conversion test will be disabled"
|
||||||
)
|
)
|
||||||
set_tests_properties (log_severity_conversion DISABLED ON)
|
set_tests_properties (log_severity_conversion DISABLED ON)
|
||||||
endif (CMAKE_COMPILER_IS_GNUCXX)
|
endif (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
|
||||||
unset (_glog_TEST_ENVIRONMENT)
|
add_test (NAME includes_logging COMMAND ${CMAKE_CTEST_COMMAND}
|
||||||
|
--build-config $<CONFIG>
|
||||||
|
--build-and-test
|
||||||
|
"${glog_SOURCE_DIR}/src/includes_unittest"
|
||||||
|
"${glog_BINARY_DIR}/Tests/includes_logging"
|
||||||
|
--build-generator ${CMAKE_GENERATOR}
|
||||||
|
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
|
||||||
|
--build-target glog_includes_logging
|
||||||
|
--build-options
|
||||||
|
-DCMAKE_BUILD_TYPE=$<CONFIG>
|
||||||
|
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||||
|
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
||||||
|
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
|
||||||
|
-Dglog_DIR=${glog_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_test (NAME includes_vlog_is_on COMMAND ${CMAKE_CTEST_COMMAND}
|
||||||
|
--build-config $<CONFIG>
|
||||||
|
--build-and-test
|
||||||
|
"${glog_SOURCE_DIR}/src/includes_unittest"
|
||||||
|
"${glog_BINARY_DIR}/Tests/includes_vlog_is_on"
|
||||||
|
--build-generator ${CMAKE_GENERATOR}
|
||||||
|
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
|
||||||
|
--build-target glog_includes_vlog_is_on
|
||||||
|
--build-options
|
||||||
|
-DCMAKE_BUILD_TYPE=$<CONFIG>
|
||||||
|
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||||
|
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
||||||
|
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
|
||||||
|
-Dglog_DIR=${glog_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_test (NAME includes_raw_logging COMMAND ${CMAKE_CTEST_COMMAND}
|
||||||
|
--build-config $<CONFIG>
|
||||||
|
--build-and-test
|
||||||
|
"${glog_SOURCE_DIR}/src/includes_unittest"
|
||||||
|
"${glog_BINARY_DIR}/Tests/includes_raw_logging"
|
||||||
|
--build-generator ${CMAKE_GENERATOR}
|
||||||
|
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
|
||||||
|
--build-target glog_includes_raw_logging
|
||||||
|
--build-options
|
||||||
|
-DCMAKE_BUILD_TYPE=$<CONFIG>
|
||||||
|
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||||
|
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
||||||
|
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
|
||||||
|
-Dglog_DIR=${glog_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_test (NAME includes_stl_logging COMMAND ${CMAKE_CTEST_COMMAND}
|
||||||
|
--build-config $<CONFIG>
|
||||||
|
--build-and-test
|
||||||
|
"${glog_SOURCE_DIR}/src/includes_unittest"
|
||||||
|
"${glog_BINARY_DIR}/Tests/includes_stl_logging"
|
||||||
|
--build-generator ${CMAKE_GENERATOR}
|
||||||
|
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
|
||||||
|
--build-target glog_includes_stl_logging
|
||||||
|
--build-options
|
||||||
|
-DCMAKE_BUILD_TYPE=$<CONFIG>
|
||||||
|
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||||
|
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
||||||
|
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
|
||||||
|
-Dglog_DIR=${glog_BINARY_DIR}
|
||||||
|
)
|
||||||
endif (BUILD_TESTING)
|
endif (BUILD_TESTING)
|
||||||
|
|
||||||
install (TARGETS glog
|
install (TARGETS glog
|
||||||
|
|||||||
@ -166,6 +166,7 @@ def glog_library(with_gflags = 1, **kwargs):
|
|||||||
"src/base/googleinit.h",
|
"src/base/googleinit.h",
|
||||||
"src/demangle.cc",
|
"src/demangle.cc",
|
||||||
"src/demangle.h",
|
"src/demangle.h",
|
||||||
|
"src/flags.cc",
|
||||||
"src/logging.cc",
|
"src/logging.cc",
|
||||||
"src/raw_logging.cc",
|
"src/raw_logging.cc",
|
||||||
"src/signalhandler.cc",
|
"src/signalhandler.cc",
|
||||||
@ -184,11 +185,13 @@ def glog_library(with_gflags = 1, **kwargs):
|
|||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}),
|
}),
|
||||||
hdrs = [
|
hdrs = [
|
||||||
|
"src/glog/flags.h",
|
||||||
"src/glog/log_severity.h",
|
"src/glog/log_severity.h",
|
||||||
"src/glog/logging.h",
|
"src/glog/logging.h",
|
||||||
"src/glog/platform.h",
|
"src/glog/platform.h",
|
||||||
"src/glog/raw_logging.h",
|
"src/glog/raw_logging.h",
|
||||||
"src/glog/stl_logging.h",
|
"src/glog/stl_logging.h",
|
||||||
|
"src/glog/types.h",
|
||||||
"src/glog/vlog_is_on.h",
|
"src/glog/vlog_is_on.h",
|
||||||
],
|
],
|
||||||
# https://github.com/google/glog/issues/837: Replacing
|
# https://github.com/google/glog/issues/837: Replacing
|
||||||
@ -251,10 +254,13 @@ def glog_library(with_gflags = 1, **kwargs):
|
|||||||
native.cc_library(
|
native.cc_library(
|
||||||
name = "strip_include_prefix_hack",
|
name = "strip_include_prefix_hack",
|
||||||
hdrs = [
|
hdrs = [
|
||||||
|
"src/glog/flags.h",
|
||||||
"src/glog/log_severity.h",
|
"src/glog/log_severity.h",
|
||||||
"src/glog/logging.h",
|
"src/glog/logging.h",
|
||||||
|
"src/glog/platform.h",
|
||||||
"src/glog/raw_logging.h",
|
"src/glog/raw_logging.h",
|
||||||
"src/glog/stl_logging.h",
|
"src/glog/stl_logging.h",
|
||||||
|
"src/glog/types.h",
|
||||||
"src/glog/vlog_is_on.h",
|
"src/glog/vlog_is_on.h",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
exclude = src/.*_unittest\.cc
|
exclude = src/.*_unittest\.cc
|
||||||
exclude = src/googletest\.h
|
exclude = src/googletest\.h
|
||||||
exclude = src/mock-log\.h
|
exclude = src/mock-log\.h
|
||||||
|
exclude-directories = Tests/
|
||||||
exclude-throw-branches = yes
|
exclude-throw-branches = yes
|
||||||
exclude-unreachable-branches = yes
|
exclude-unreachable-branches = yes
|
||||||
filter = .*/glog/.*\.h
|
filter = .*/glog/.*\.h
|
||||||
|
|||||||
157
src/flags.cc
Normal file
157
src/flags.cc
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
// Copyright (c) 2024, Google Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "glog/flags.h"
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "base/commandlineflags.h"
|
||||||
|
#include "glog/log_severity.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// Compute the default value for --log_dir
|
||||||
|
static const char* DefaultLogDir() {
|
||||||
|
constexpr const char* const names[]{"GOOGLE_LOG_DIR", "TEST_TMPDIR"};
|
||||||
|
for (const char* const name : names) {
|
||||||
|
const char* const env = std::getenv(name);
|
||||||
|
if (env != nullptr && env[0] != '\0') {
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BoolFromEnv(const char* varname, bool defval) {
|
||||||
|
const char* const valstr = getenv(varname);
|
||||||
|
if (!valstr) {
|
||||||
|
return defval;
|
||||||
|
}
|
||||||
|
return std::memchr("tTyY1\0", valstr[0], 6) != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
GLOG_DEFINE_bool(timestamp_in_logfile_name,
|
||||||
|
BoolFromEnv("GOOGLE_TIMESTAMP_IN_LOGFILE_NAME", true),
|
||||||
|
"put a timestamp at the end of the log file name");
|
||||||
|
GLOG_DEFINE_bool(logtostderr, BoolFromEnv("GOOGLE_LOGTOSTDERR", false),
|
||||||
|
"log messages go to stderr instead of logfiles");
|
||||||
|
GLOG_DEFINE_bool(alsologtostderr, BoolFromEnv("GOOGLE_ALSOLOGTOSTDERR", false),
|
||||||
|
"log messages go to stderr in addition to logfiles");
|
||||||
|
GLOG_DEFINE_bool(colorlogtostderr, false,
|
||||||
|
"color messages logged to stderr (if supported by terminal)");
|
||||||
|
GLOG_DEFINE_bool(colorlogtostdout, false,
|
||||||
|
"color messages logged to stdout (if supported by terminal)");
|
||||||
|
GLOG_DEFINE_bool(logtostdout, BoolFromEnv("GOOGLE_LOGTOSTDOUT", false),
|
||||||
|
"log messages go to stdout instead of logfiles");
|
||||||
|
#ifdef GLOG_OS_LINUX
|
||||||
|
GLOG_DEFINE_bool(
|
||||||
|
drop_log_memory, true,
|
||||||
|
"Drop in-memory buffers of log contents. "
|
||||||
|
"Logs can grow very quickly and they are rarely read before they "
|
||||||
|
"need to be evicted from memory. Instead, drop them from memory "
|
||||||
|
"as soon as they are flushed to disk.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// By default, errors (including fatal errors) get logged to stderr as
|
||||||
|
// well as the file.
|
||||||
|
//
|
||||||
|
// The default is ERROR instead of FATAL so that users can see problems
|
||||||
|
// when they run a program without having to look in another file.
|
||||||
|
DEFINE_int32(stderrthreshold, google::GLOG_ERROR,
|
||||||
|
"log messages at or above this level are copied to stderr in "
|
||||||
|
"addition to logfiles. This flag obsoletes --alsologtostderr.");
|
||||||
|
|
||||||
|
GLOG_DEFINE_string(alsologtoemail, "",
|
||||||
|
"log messages go to these email addresses "
|
||||||
|
"in addition to logfiles");
|
||||||
|
GLOG_DEFINE_bool(log_file_header, true,
|
||||||
|
"Write the file header at the start of each log file");
|
||||||
|
GLOG_DEFINE_bool(log_prefix, true,
|
||||||
|
"Prepend the log prefix to the start of each log line");
|
||||||
|
GLOG_DEFINE_bool(log_year_in_prefix, true,
|
||||||
|
"Include the year in the log prefix");
|
||||||
|
GLOG_DEFINE_int32(minloglevel, 0,
|
||||||
|
"Messages logged at a lower level than this don't "
|
||||||
|
"actually get logged anywhere");
|
||||||
|
GLOG_DEFINE_int32(logbuflevel, 0,
|
||||||
|
"Buffer log messages logged at this level or lower"
|
||||||
|
" (-1 means don't buffer; 0 means buffer INFO only;"
|
||||||
|
" ...)");
|
||||||
|
GLOG_DEFINE_int32(logbufsecs, 30,
|
||||||
|
"Buffer log messages for at most this many seconds");
|
||||||
|
|
||||||
|
GLOG_DEFINE_int32(logcleansecs, 60 * 5, // every 5 minutes
|
||||||
|
"Clean overdue logs every this many seconds");
|
||||||
|
|
||||||
|
GLOG_DEFINE_int32(logemaillevel, 999,
|
||||||
|
"Email log messages logged at this level or higher"
|
||||||
|
" (0 means email all; 3 means email FATAL only;"
|
||||||
|
" ...)");
|
||||||
|
GLOG_DEFINE_string(logmailer, "", "Mailer used to send logging email");
|
||||||
|
|
||||||
|
GLOG_DEFINE_int32(logfile_mode, 0664, "Log file mode/permissions.");
|
||||||
|
|
||||||
|
GLOG_DEFINE_string(
|
||||||
|
log_dir, DefaultLogDir(),
|
||||||
|
"If specified, logfiles are written into this directory instead "
|
||||||
|
"of the default logging directory.");
|
||||||
|
GLOG_DEFINE_string(log_link, "",
|
||||||
|
"Put additional links to the log "
|
||||||
|
"files in this directory");
|
||||||
|
|
||||||
|
GLOG_DEFINE_uint32(max_log_size, 1800,
|
||||||
|
"approx. maximum log file size (in MB). A value of 0 will "
|
||||||
|
"be silently overridden to 1.");
|
||||||
|
|
||||||
|
GLOG_DEFINE_bool(stop_logging_if_full_disk, false,
|
||||||
|
"Stop attempting to log to disk if the disk is full.");
|
||||||
|
|
||||||
|
GLOG_DEFINE_string(log_backtrace_at, "",
|
||||||
|
"Emit a backtrace when logging at file:linenum.");
|
||||||
|
|
||||||
|
GLOG_DEFINE_bool(log_utc_time, false, "Use UTC time for logging.");
|
||||||
|
|
||||||
|
GLOG_DEFINE_int32(v, 0,
|
||||||
|
"Show all VLOG(m) messages for m <= this."
|
||||||
|
" Overridable by --vmodule.");
|
||||||
|
|
||||||
|
GLOG_DEFINE_string(
|
||||||
|
vmodule, "",
|
||||||
|
"per-module verbose level."
|
||||||
|
" Argument is a comma-separated list of <module name>=<log level>."
|
||||||
|
" <module name> is a glob pattern, matched against the filename base"
|
||||||
|
" (that is, name ignoring .cc/.h./-inl.h)."
|
||||||
|
" <log level> overrides any value given by --v.");
|
||||||
|
|
||||||
|
GLOG_DEFINE_bool(symbolize_stacktrace, true,
|
||||||
|
"Symbolize the stack trace in the tombstone");
|
||||||
187
src/glog/flags.h
Normal file
187
src/glog/flags.h
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
// Copyright (c) 2024, Google Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef GLOG_FLAGS_H
|
||||||
|
#define GLOG_FLAGS_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#if defined(GLOG_USE_GFLAGS)
|
||||||
|
# include <gflags/gflags.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLOG_USE_GLOG_EXPORT)
|
||||||
|
# include "glog/export.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "glog/platform.h"
|
||||||
|
#include "glog/types.h"
|
||||||
|
|
||||||
|
#pragma push_macro("DECLARE_VARIABLE")
|
||||||
|
#pragma push_macro("DECLARE_bool")
|
||||||
|
#pragma push_macro("DECLARE_string")
|
||||||
|
#pragma push_macro("DECLARE_int32")
|
||||||
|
#pragma push_macro("DECLARE_uint32")
|
||||||
|
|
||||||
|
#ifdef DECLARE_VARIABLE
|
||||||
|
# undef DECLARE_VARIABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DECLARE_bool
|
||||||
|
# undef DECLARE_bool
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DECLARE_string
|
||||||
|
# undef DECLARE_string
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DECLARE_int32
|
||||||
|
# undef DECLARE_int32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DECLARE_uint32
|
||||||
|
# undef DECLARE_uint32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DECLARE_VARIABLE
|
||||||
|
# define DECLARE_VARIABLE(type, shorttype, name, tn) \
|
||||||
|
namespace fL##shorttype { \
|
||||||
|
extern GLOG_EXPORT type FLAGS_##name; \
|
||||||
|
} \
|
||||||
|
using fL##shorttype::FLAGS_##name
|
||||||
|
|
||||||
|
// bool specialization
|
||||||
|
# define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name, bool)
|
||||||
|
|
||||||
|
// int32 specialization
|
||||||
|
# define DECLARE_int32(name) DECLARE_VARIABLE(google::int32, I, name, int32)
|
||||||
|
|
||||||
|
# if !defined(DECLARE_uint32)
|
||||||
|
// uint32 specialization
|
||||||
|
# define DECLARE_uint32(name) \
|
||||||
|
DECLARE_VARIABLE(google::uint32, U, name, uint32)
|
||||||
|
# endif // !defined(DECLARE_uint32) && !defined(GLOG_USE_GFLAGS)
|
||||||
|
|
||||||
|
// Special case for string, because we have to specify the namespace
|
||||||
|
// std::string, which doesn't play nicely with our FLAG__namespace hackery.
|
||||||
|
# define DECLARE_string(name) \
|
||||||
|
namespace fLS { \
|
||||||
|
extern GLOG_EXPORT std::string& FLAGS_##name; \
|
||||||
|
} \
|
||||||
|
using fLS::FLAGS_##name
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DECLARE_int32(logemaillevel);
|
||||||
|
DECLARE_int32(logcleansecs);
|
||||||
|
|
||||||
|
#ifdef GLOG_OS_LINUX
|
||||||
|
DECLARE_bool(drop_log_memory);
|
||||||
|
#endif
|
||||||
|
DECLARE_string(alsologtoemail);
|
||||||
|
DECLARE_string(log_backtrace_at);
|
||||||
|
|
||||||
|
// Set whether appending a timestamp to the log file name
|
||||||
|
DECLARE_bool(timestamp_in_logfile_name);
|
||||||
|
|
||||||
|
// Set whether log messages go to stdout instead of logfiles
|
||||||
|
DECLARE_bool(logtostdout);
|
||||||
|
|
||||||
|
// Set color messages logged to stdout (if supported by terminal).
|
||||||
|
DECLARE_bool(colorlogtostdout);
|
||||||
|
|
||||||
|
// Set whether log messages go to stderr instead of logfiles
|
||||||
|
DECLARE_bool(logtostderr);
|
||||||
|
|
||||||
|
// Set whether log messages go to stderr in addition to logfiles.
|
||||||
|
DECLARE_bool(alsologtostderr);
|
||||||
|
|
||||||
|
// Set color messages logged to stderr (if supported by terminal).
|
||||||
|
DECLARE_bool(colorlogtostderr);
|
||||||
|
|
||||||
|
// Log messages at a level >= this flag are automatically sent to
|
||||||
|
// stderr in addition to log files.
|
||||||
|
DECLARE_int32(stderrthreshold);
|
||||||
|
|
||||||
|
// Set whether the log file header should be written upon creating a file.
|
||||||
|
DECLARE_bool(log_file_header);
|
||||||
|
|
||||||
|
// Set whether the log prefix should be prepended to each line of output.
|
||||||
|
DECLARE_bool(log_prefix);
|
||||||
|
|
||||||
|
// Set whether the year should be included in the log prefix.
|
||||||
|
DECLARE_bool(log_year_in_prefix);
|
||||||
|
|
||||||
|
// Log messages at a level <= this flag are buffered.
|
||||||
|
// Log messages at a higher level are flushed immediately.
|
||||||
|
DECLARE_int32(logbuflevel);
|
||||||
|
|
||||||
|
// Sets the maximum number of seconds which logs may be buffered for.
|
||||||
|
DECLARE_int32(logbufsecs);
|
||||||
|
|
||||||
|
// Log suppression level: messages logged at a lower level than this
|
||||||
|
// are suppressed.
|
||||||
|
DECLARE_int32(minloglevel);
|
||||||
|
|
||||||
|
// If specified, logfiles are written into this directory instead of the
|
||||||
|
// default logging directory.
|
||||||
|
DECLARE_string(log_dir);
|
||||||
|
|
||||||
|
// Set the log file mode.
|
||||||
|
DECLARE_int32(logfile_mode);
|
||||||
|
|
||||||
|
// Sets the path of the directory into which to put additional links
|
||||||
|
// to the log files.
|
||||||
|
DECLARE_string(log_link);
|
||||||
|
|
||||||
|
DECLARE_int32(v); // in vlog_is_on.cc
|
||||||
|
|
||||||
|
DECLARE_string(vmodule); // also in vlog_is_on.cc
|
||||||
|
|
||||||
|
// Sets the maximum log file size (in MB).
|
||||||
|
DECLARE_uint32(max_log_size);
|
||||||
|
|
||||||
|
// Sets whether to avoid logging to the disk if the disk is full.
|
||||||
|
DECLARE_bool(stop_logging_if_full_disk);
|
||||||
|
|
||||||
|
// Use UTC time for logging
|
||||||
|
DECLARE_bool(log_utc_time);
|
||||||
|
|
||||||
|
// Mailer used to send logging email
|
||||||
|
DECLARE_string(logmailer);
|
||||||
|
|
||||||
|
DECLARE_bool(symbolize_stacktrace);
|
||||||
|
|
||||||
|
#pragma pop_macro("DECLARE_VARIABLE")
|
||||||
|
#pragma pop_macro("DECLARE_bool")
|
||||||
|
#pragma pop_macro("DECLARE_string")
|
||||||
|
#pragma pop_macro("DECLARE_int32")
|
||||||
|
#pragma pop_macro("DECLARE_uint32")
|
||||||
|
|
||||||
|
#endif // GLOG_FLAGS_H
|
||||||
@ -30,6 +30,12 @@
|
|||||||
#ifndef BASE_LOG_SEVERITY_H__
|
#ifndef BASE_LOG_SEVERITY_H__
|
||||||
#define BASE_LOG_SEVERITY_H__
|
#define BASE_LOG_SEVERITY_H__
|
||||||
|
|
||||||
|
#if defined(GLOG_USE_GLOG_EXPORT)
|
||||||
|
# include "glog/export.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
|
||||||
// The recommended semantics of the log levels are as follows:
|
// The recommended semantics of the log levels are as follows:
|
||||||
//
|
//
|
||||||
// INFO:
|
// INFO:
|
||||||
@ -113,4 +119,6 @@ enum { DEBUG_MODE = 1 };
|
|||||||
# define IF_DEBUG_MODE(x) x
|
# define IF_DEBUG_MODE(x) x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
} // namespace google
|
||||||
|
|
||||||
#endif // BASE_LOG_SEVERITY_H__
|
#endif // BASE_LOG_SEVERITY_H__
|
||||||
|
|||||||
@ -36,6 +36,7 @@
|
|||||||
#ifndef GLOG_LOGGING_H
|
#ifndef GLOG_LOGGING_H
|
||||||
#define GLOG_LOGGING_H
|
#define GLOG_LOGGING_H
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@ -51,16 +52,13 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(GLOG_USE_GLOG_EXPORT)
|
||||||
# define GLOG_MSVC_PUSH_DISABLE_WARNING(n) \
|
# include "glog/export.h"
|
||||||
__pragma(warning(push)) __pragma(warning(disable : n))
|
|
||||||
# define GLOG_MSVC_POP_WARNING() __pragma(warning(pop))
|
|
||||||
#else
|
|
||||||
# define GLOG_MSVC_PUSH_DISABLE_WARNING(n)
|
|
||||||
# define GLOG_MSVC_POP_WARNING()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "glog/flags.h"
|
||||||
#include "glog/platform.h"
|
#include "glog/platform.h"
|
||||||
|
#include "glog/types.h"
|
||||||
|
|
||||||
#if defined(__has_attribute)
|
#if defined(__has_attribute)
|
||||||
# if __has_attribute(used)
|
# if __has_attribute(used)
|
||||||
@ -72,31 +70,11 @@
|
|||||||
# define GLOG_USED
|
# define GLOG_USED
|
||||||
#endif // !defined(GLOG_USED)
|
#endif // !defined(GLOG_USED)
|
||||||
|
|
||||||
#if defined(GLOG_USE_GLOG_EXPORT)
|
#include "glog/log_severity.h"
|
||||||
# include "glog/export.h"
|
#include "glog/vlog_is_on.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
// We care a lot about number of bits things take up. Unfortunately,
|
|
||||||
// systems define their bit-specific ints in a lot of different ways.
|
|
||||||
// We use our own way, and have a typedef to get there.
|
|
||||||
// Note: these commands below may look like "#if 1" or "#if 0", but
|
|
||||||
// that's because they were constructed that way at ./configure time.
|
|
||||||
// Look at logging.h.in to see how they're calculated (based on your config).
|
|
||||||
#include <cstdint> // the normal place uint16_t is defined
|
|
||||||
|
|
||||||
#if defined(GLOG_USE_GFLAGS)
|
|
||||||
# include <gflags/gflags.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
|
|
||||||
typedef std::int32_t int32;
|
|
||||||
typedef std::uint32_t uint32;
|
|
||||||
typedef std::int64_t int64;
|
|
||||||
typedef std::uint64_t uint64;
|
|
||||||
|
|
||||||
struct GLOG_EXPORT LogMessageTime {
|
struct GLOG_EXPORT LogMessageTime {
|
||||||
LogMessageTime();
|
LogMessageTime();
|
||||||
explicit LogMessageTime(std::chrono::system_clock::time_point now);
|
explicit LogMessageTime(std::chrono::system_clock::time_point now);
|
||||||
@ -364,129 +342,6 @@ typedef void (*CustomPrefixCallback)(std::ostream& s, const LogMessageInfo& l,
|
|||||||
// synchronized. Hence, use caution when comparing the low bits of
|
// synchronized. Hence, use caution when comparing the low bits of
|
||||||
// timestamps from different machines.
|
// timestamps from different machines.
|
||||||
|
|
||||||
#pragma push_macro("DECLARE_VARIABLE")
|
|
||||||
#pragma push_macro("DECLARE_bool")
|
|
||||||
#pragma push_macro("DECLARE_string")
|
|
||||||
#pragma push_macro("DECLARE_int32")
|
|
||||||
#pragma push_macro("DECLARE_uint32")
|
|
||||||
|
|
||||||
#ifdef DECLARE_VARIABLE
|
|
||||||
# undef DECLARE_VARIABLE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DECLARE_bool
|
|
||||||
# undef DECLARE_bool
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DECLARE_string
|
|
||||||
# undef DECLARE_string
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DECLARE_int32
|
|
||||||
# undef DECLARE_int32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DECLARE_uint32
|
|
||||||
# undef DECLARE_uint32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DECLARE_VARIABLE
|
|
||||||
# define DECLARE_VARIABLE(type, shorttype, name, tn) \
|
|
||||||
namespace fL##shorttype { \
|
|
||||||
extern GLOG_EXPORT type FLAGS_##name; \
|
|
||||||
} \
|
|
||||||
using fL##shorttype::FLAGS_##name
|
|
||||||
|
|
||||||
// bool specialization
|
|
||||||
# define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name, bool)
|
|
||||||
|
|
||||||
// int32 specialization
|
|
||||||
# define DECLARE_int32(name) DECLARE_VARIABLE(google::int32, I, name, int32)
|
|
||||||
|
|
||||||
# if !defined(DECLARE_uint32)
|
|
||||||
// uint32 specialization
|
|
||||||
# define DECLARE_uint32(name) \
|
|
||||||
DECLARE_VARIABLE(google::uint32, U, name, uint32)
|
|
||||||
# endif // !defined(DECLARE_uint32) && !defined(GLOG_USE_GFLAGS)
|
|
||||||
|
|
||||||
// Special case for string, because we have to specify the namespace
|
|
||||||
// std::string, which doesn't play nicely with our FLAG__namespace hackery.
|
|
||||||
# define DECLARE_string(name) \
|
|
||||||
namespace fLS { \
|
|
||||||
extern GLOG_EXPORT std::string& FLAGS_##name; \
|
|
||||||
} \
|
|
||||||
using fLS::FLAGS_##name
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set whether appending a timestamp to the log file name
|
|
||||||
DECLARE_bool(timestamp_in_logfile_name);
|
|
||||||
|
|
||||||
// Set whether log messages go to stdout instead of logfiles
|
|
||||||
DECLARE_bool(logtostdout);
|
|
||||||
|
|
||||||
// Set color messages logged to stdout (if supported by terminal).
|
|
||||||
DECLARE_bool(colorlogtostdout);
|
|
||||||
|
|
||||||
// Set whether log messages go to stderr instead of logfiles
|
|
||||||
DECLARE_bool(logtostderr);
|
|
||||||
|
|
||||||
// Set whether log messages go to stderr in addition to logfiles.
|
|
||||||
DECLARE_bool(alsologtostderr);
|
|
||||||
|
|
||||||
// Set color messages logged to stderr (if supported by terminal).
|
|
||||||
DECLARE_bool(colorlogtostderr);
|
|
||||||
|
|
||||||
// Log messages at a level >= this flag are automatically sent to
|
|
||||||
// stderr in addition to log files.
|
|
||||||
DECLARE_int32(stderrthreshold);
|
|
||||||
|
|
||||||
// Set whether the log file header should be written upon creating a file.
|
|
||||||
DECLARE_bool(log_file_header);
|
|
||||||
|
|
||||||
// Set whether the log prefix should be prepended to each line of output.
|
|
||||||
DECLARE_bool(log_prefix);
|
|
||||||
|
|
||||||
// Set whether the year should be included in the log prefix.
|
|
||||||
DECLARE_bool(log_year_in_prefix);
|
|
||||||
|
|
||||||
// Log messages at a level <= this flag are buffered.
|
|
||||||
// Log messages at a higher level are flushed immediately.
|
|
||||||
DECLARE_int32(logbuflevel);
|
|
||||||
|
|
||||||
// Sets the maximum number of seconds which logs may be buffered for.
|
|
||||||
DECLARE_int32(logbufsecs);
|
|
||||||
|
|
||||||
// Log suppression level: messages logged at a lower level than this
|
|
||||||
// are suppressed.
|
|
||||||
DECLARE_int32(minloglevel);
|
|
||||||
|
|
||||||
// If specified, logfiles are written into this directory instead of the
|
|
||||||
// default logging directory.
|
|
||||||
DECLARE_string(log_dir);
|
|
||||||
|
|
||||||
// Set the log file mode.
|
|
||||||
DECLARE_int32(logfile_mode);
|
|
||||||
|
|
||||||
// Sets the path of the directory into which to put additional links
|
|
||||||
// to the log files.
|
|
||||||
DECLARE_string(log_link);
|
|
||||||
|
|
||||||
DECLARE_int32(v); // in vlog_is_on.cc
|
|
||||||
|
|
||||||
DECLARE_string(vmodule); // also in vlog_is_on.cc
|
|
||||||
|
|
||||||
// Sets the maximum log file size (in MB).
|
|
||||||
DECLARE_uint32(max_log_size);
|
|
||||||
|
|
||||||
// Sets whether to avoid logging to the disk if the disk is full.
|
|
||||||
DECLARE_bool(stop_logging_if_full_disk);
|
|
||||||
|
|
||||||
// Use UTC time for logging
|
|
||||||
DECLARE_bool(log_utc_time);
|
|
||||||
|
|
||||||
// Mailer used to send logging email
|
|
||||||
DECLARE_string(logmailer);
|
|
||||||
|
|
||||||
// Log messages below the GOOGLE_STRIP_LOG level will be compiled away for
|
// Log messages below the GOOGLE_STRIP_LOG level will be compiled away for
|
||||||
// security reasons. See LOG(severtiy) below.
|
// security reasons. See LOG(severtiy) below.
|
||||||
|
|
||||||
@ -615,10 +470,6 @@ DECLARE_string(logmailer);
|
|||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
|
|
||||||
// They need the definitions of integer types.
|
|
||||||
#include "glog/log_severity.h"
|
|
||||||
#include "glog/vlog_is_on.h"
|
|
||||||
|
|
||||||
// Initialize google's logging library. You will see the program name
|
// Initialize google's logging library. You will see the program name
|
||||||
// specified by argv0 in log outputs.
|
// specified by argv0 in log outputs.
|
||||||
GLOG_EXPORT void InitGoogleLogging(const char* argv0);
|
GLOG_EXPORT void InitGoogleLogging(const char* argv0);
|
||||||
@ -1030,34 +881,9 @@ DECLARE_CHECK_STROP_IMPL(strcasecmp, false)
|
|||||||
#define LOG_CURRENT_TIME LOG_EVERY_N_VARNAME(currentTime_, __LINE__)
|
#define LOG_CURRENT_TIME LOG_EVERY_N_VARNAME(currentTime_, __LINE__)
|
||||||
#define LOG_PREVIOUS_TIME LOG_EVERY_N_VARNAME(previousTime_, __LINE__)
|
#define LOG_PREVIOUS_TIME LOG_EVERY_N_VARNAME(previousTime_, __LINE__)
|
||||||
|
|
||||||
#if defined(__has_feature)
|
|
||||||
# if __has_feature(thread_sanitizer)
|
|
||||||
# define GLOG_SANITIZE_THREAD 1
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(GLOG_SANITIZE_THREAD) && defined(__SANITIZE_THREAD__) && \
|
|
||||||
__SANITIZE_THREAD__
|
|
||||||
# define GLOG_SANITIZE_THREAD 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLOG_SANITIZE_THREAD)
|
|
||||||
# define GLOG_IFDEF_THREAD_SANITIZER(X) X
|
|
||||||
#else
|
|
||||||
# define GLOG_IFDEF_THREAD_SANITIZER(X)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLOG_SANITIZE_THREAD)
|
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
// We need to identify the static variables as "benign" races
|
|
||||||
// to avoid noisy reports from TSAN.
|
|
||||||
extern "C" void AnnotateBenignRaceSized(const char* file, int line,
|
|
||||||
const volatile void* mem, size_t size,
|
|
||||||
const char* description);
|
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SOME_KIND_OF_LOG_EVERY_T(severity, seconds) \
|
#define SOME_KIND_OF_LOG_EVERY_T(severity, seconds) \
|
||||||
constexpr std::chrono::nanoseconds LOG_TIME_PERIOD = \
|
constexpr std::chrono::nanoseconds LOG_TIME_PERIOD = \
|
||||||
@ -1835,10 +1661,4 @@ GLOG_EXPORT void InstallFailureWriter(void (*writer)(const char* data,
|
|||||||
|
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
#pragma pop_macro("DECLARE_VARIABLE")
|
|
||||||
#pragma pop_macro("DECLARE_bool")
|
|
||||||
#pragma pop_macro("DECLARE_string")
|
|
||||||
#pragma pop_macro("DECLARE_int32")
|
|
||||||
#pragma pop_macro("DECLARE_uint32")
|
|
||||||
|
|
||||||
#endif // GLOG_LOGGING_H
|
#endif // GLOG_LOGGING_H
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2008, Google Inc.
|
// Copyright (c) 2024, Google Inc.
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2006, Google Inc.
|
// Copyright (c) 2024, Google Inc.
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@ -36,18 +36,15 @@
|
|||||||
#ifndef GLOG_RAW_LOGGING_H
|
#ifndef GLOG_RAW_LOGGING_H
|
||||||
#define GLOG_RAW_LOGGING_H
|
#define GLOG_RAW_LOGGING_H
|
||||||
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
namespace google {
|
|
||||||
#include "glog/log_severity.h"
|
#include "glog/log_severity.h"
|
||||||
#include "glog/logging.h"
|
|
||||||
#include "glog/vlog_is_on.h"
|
#include "glog/vlog_is_on.h"
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(GLOG_USE_GLOG_EXPORT)
|
||||||
# pragma GCC diagnostic push
|
# include "glog/export.h"
|
||||||
# pragma GCC diagnostic ignored "-Wvariadic-macros"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
|
||||||
// This is similar to LOG(severity) << format... and VLOG(level) << format..,
|
// This is similar to LOG(severity) << format... and VLOG(level) << format..,
|
||||||
// but
|
// but
|
||||||
// * it is to be used ONLY by low-level modules that can't use normal LOG()
|
// * it is to be used ONLY by low-level modules that can't use normal LOG()
|
||||||
@ -154,10 +151,6 @@ namespace google {
|
|||||||
|
|
||||||
#endif // NDEBUG
|
#endif // NDEBUG
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
# pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Stub log function used to work around for unused variable warnings when
|
// Stub log function used to work around for unused variable warnings when
|
||||||
// building with STRIP_LOG > 0.
|
// building with STRIP_LOG > 0.
|
||||||
static inline void RawLogStub__(int /* ignored */, ...) {}
|
static inline void RawLogStub__(int /* ignored */, ...) {}
|
||||||
|
|||||||
@ -36,8 +36,8 @@
|
|||||||
// CHECK_EQ(v1, v2);
|
// CHECK_EQ(v1, v2);
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef UTIL_GTL_STL_LOGGING_INL_H_
|
#ifndef GLOG_STL_LOGGING_H
|
||||||
#define UTIL_GTL_STL_LOGGING_INL_H_
|
#define GLOG_STL_LOGGING_H
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <list>
|
#include <list>
|
||||||
@ -165,4 +165,4 @@ namespace std {
|
|||||||
using ::operator<<;
|
using ::operator<<;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // UTIL_GTL_STL_LOGGING_INL_H_
|
#endif // GLOG_STL_LOGGING_H
|
||||||
|
|||||||
81
src/glog/types.h
Normal file
81
src/glog/types.h
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
|
||||||
|
// Copyright (c) 2024, Google Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef GLOG_TYPES_H
|
||||||
|
#define GLOG_TYPES_H
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
|
||||||
|
using int32 = std::int32_t;
|
||||||
|
using uint32 = std::uint32_t;
|
||||||
|
using int64 = std::int64_t;
|
||||||
|
using uint64 = std::uint64_t;
|
||||||
|
|
||||||
|
} // namespace google
|
||||||
|
|
||||||
|
#if defined(__has_feature)
|
||||||
|
# if __has_feature(thread_sanitizer)
|
||||||
|
# define GLOG_SANITIZE_THREAD 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(GLOG_SANITIZE_THREAD) && defined(__SANITIZE_THREAD__) && \
|
||||||
|
__SANITIZE_THREAD__
|
||||||
|
# define GLOG_SANITIZE_THREAD 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLOG_SANITIZE_THREAD)
|
||||||
|
# define GLOG_IFDEF_THREAD_SANITIZER(X) X
|
||||||
|
#else
|
||||||
|
# define GLOG_IFDEF_THREAD_SANITIZER(X)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# define GLOG_MSVC_PUSH_DISABLE_WARNING(n) \
|
||||||
|
__pragma(warning(push)) __pragma(warning(disable : n))
|
||||||
|
# define GLOG_MSVC_POP_WARNING() __pragma(warning(pop))
|
||||||
|
#else
|
||||||
|
# define GLOG_MSVC_PUSH_DISABLE_WARNING(n)
|
||||||
|
# define GLOG_MSVC_POP_WARNING()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLOG_SANITIZE_THREAD)
|
||||||
|
// We need to identify the static variables as "benign" races
|
||||||
|
// to avoid noisy reports from TSAN.
|
||||||
|
extern "C" void AnnotateBenignRaceSized(const char* file, int line,
|
||||||
|
const volatile void* mem, size_t size,
|
||||||
|
const char* description);
|
||||||
|
#endif // defined(GLOG_SANITIZE_THREAD)
|
||||||
|
|
||||||
|
#endif // GLOG_TYPES_H
|
||||||
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2023, Google Inc.
|
// Copyright (c) 2024, Google Inc.
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@ -58,12 +58,17 @@
|
|||||||
// CAVEAT: --vmodule functionality is not available in non gcc compilers.
|
// CAVEAT: --vmodule functionality is not available in non gcc compilers.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BASE_VLOG_IS_ON_H_
|
#ifndef GLOG_VLOG_IS_ON_H
|
||||||
#define BASE_VLOG_IS_ON_H_
|
#define GLOG_VLOG_IS_ON_H
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
#include "glog/log_severity.h"
|
#if defined(GLOG_USE_GLOG_EXPORT)
|
||||||
|
# include "glog/export.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "glog/flags.h"
|
||||||
|
#include "glog/types.h"
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
// We emit an anonymous static int* variable at every VLOG_IS_ON(n) site.
|
// We emit an anonymous static int* variable at every VLOG_IS_ON(n) site.
|
||||||
@ -89,6 +94,8 @@
|
|||||||
# define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel))
|
# define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
|
||||||
// Set VLOG(_IS_ON) level for module_pattern to log_level.
|
// Set VLOG(_IS_ON) level for module_pattern to log_level.
|
||||||
// This lets us dynamically control what is normally set by the --vmodule flag.
|
// This lets us dynamically control what is normally set by the --vmodule flag.
|
||||||
// Returns the level that previously applied to module_pattern.
|
// Returns the level that previously applied to module_pattern.
|
||||||
@ -102,7 +109,7 @@ extern GLOG_EXPORT int SetVLOGLevel(const char* module_pattern, int log_level);
|
|||||||
// Various declarations needed for VLOG_IS_ON above: =========================
|
// Various declarations needed for VLOG_IS_ON above: =========================
|
||||||
|
|
||||||
struct SiteFlag {
|
struct SiteFlag {
|
||||||
google::int32* level;
|
int32* level;
|
||||||
const char* base_name;
|
const char* base_name;
|
||||||
std::size_t base_len;
|
std::size_t base_len;
|
||||||
SiteFlag* next;
|
SiteFlag* next;
|
||||||
@ -116,9 +123,10 @@ struct SiteFlag {
|
|||||||
// verbose_level is the argument to VLOG_IS_ON
|
// verbose_level is the argument to VLOG_IS_ON
|
||||||
// We will return the return value for VLOG_IS_ON
|
// We will return the return value for VLOG_IS_ON
|
||||||
// and if possible set *site_flag appropriately.
|
// and if possible set *site_flag appropriately.
|
||||||
extern GLOG_EXPORT bool InitVLOG3__(google::SiteFlag* site_flag,
|
extern GLOG_EXPORT bool InitVLOG3__(SiteFlag* site_flag,
|
||||||
google::int32* site_default,
|
int32* site_default,
|
||||||
const char* fname,
|
const char* fname,
|
||||||
google::int32 verbose_level);
|
int32 verbose_level);
|
||||||
|
} // namespace google
|
||||||
|
|
||||||
#endif // BASE_VLOG_IS_ON_H_
|
#endif // GLOG_VLOG_IS_ON_H
|
||||||
|
|||||||
16
src/includes_unittest/CMakeLists.txt
Normal file
16
src/includes_unittest/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
cmake_minimum_required (VERSION 3.16)
|
||||||
|
project (glog_includes LANGUAGES CXX)
|
||||||
|
|
||||||
|
find_package (glog REQUIRED NO_MODULE)
|
||||||
|
|
||||||
|
add_executable (glog_includes_logging glog_includes_logging.cc)
|
||||||
|
target_link_libraries (glog_includes_logging PRIVATE glog::glog)
|
||||||
|
|
||||||
|
add_executable (glog_includes_vlog_is_on glog_includes_vlog_is_on.cc)
|
||||||
|
target_link_libraries (glog_includes_vlog_is_on PRIVATE glog::glog)
|
||||||
|
|
||||||
|
add_executable (glog_includes_raw_logging glog_includes_raw_logging.cc)
|
||||||
|
target_link_libraries (glog_includes_raw_logging PRIVATE glog::glog)
|
||||||
|
|
||||||
|
add_executable (glog_includes_stl_logging glog_includes_stl_logging.cc)
|
||||||
|
target_link_libraries (glog_includes_stl_logging PRIVATE glog::glog)
|
||||||
39
src/includes_unittest/glog_includes_logging.cc
Normal file
39
src/includes_unittest/glog_includes_logging.cc
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (c) 2024, Google Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// Author: Sergiu Deitsch
|
||||||
|
|
||||||
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
LOG(INFO) << "info";
|
||||||
|
LOG(WARNING) << "warning";
|
||||||
|
LOG(ERROR) << "error";
|
||||||
|
LOG(FATAL) << "fatal";
|
||||||
|
}
|
||||||
39
src/includes_unittest/glog_includes_raw_logging.cc
Normal file
39
src/includes_unittest/glog_includes_raw_logging.cc
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (c) 2024, Google Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// Author: Sergiu Deitsch
|
||||||
|
|
||||||
|
#include <glog/raw_logging.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
RAW_LOG(INFO, "info");
|
||||||
|
RAW_LOG(WARNING, "warning");
|
||||||
|
RAW_LOG(ERROR, "error");
|
||||||
|
RAW_LOG(FATAL, "fatal");
|
||||||
|
}
|
||||||
34
src/includes_unittest/glog_includes_stl_logging.cc
Normal file
34
src/includes_unittest/glog_includes_stl_logging.cc
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) 2024, Google Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// Author: Sergiu Deitsch
|
||||||
|
|
||||||
|
#include <glog/stl_logging.h>
|
||||||
|
|
||||||
|
int main() {}
|
||||||
34
src/includes_unittest/glog_includes_vlog_is_on.cc
Normal file
34
src/includes_unittest/glog_includes_vlog_is_on.cc
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) 2024, Google Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// Author: Sergiu Deitsch
|
||||||
|
|
||||||
|
#include <glog/vlog_is_on.h>
|
||||||
|
|
||||||
|
int main() { VLOG_IS_ON(0); }
|
||||||
105
src/logging.cc
105
src/logging.cc
@ -44,8 +44,6 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/commandlineflags.h" // to get the program name
|
|
||||||
#include "base/googleinit.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "glog/raw_logging.h"
|
#include "glog/raw_logging.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
@ -131,109 +129,6 @@ using std::fdopen;
|
|||||||
// There is no thread annotation support.
|
// There is no thread annotation support.
|
||||||
#define EXCLUSIVE_LOCKS_REQUIRED(mu)
|
#define EXCLUSIVE_LOCKS_REQUIRED(mu)
|
||||||
|
|
||||||
static bool BoolFromEnv(const char* varname, bool defval) {
|
|
||||||
const char* const valstr = getenv(varname);
|
|
||||||
if (!valstr) {
|
|
||||||
return defval;
|
|
||||||
}
|
|
||||||
return memchr("tTyY1\0", valstr[0], 6) != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLOG_DEFINE_bool(timestamp_in_logfile_name,
|
|
||||||
BoolFromEnv("GOOGLE_TIMESTAMP_IN_LOGFILE_NAME", true),
|
|
||||||
"put a timestamp at the end of the log file name");
|
|
||||||
GLOG_DEFINE_bool(logtostderr, BoolFromEnv("GOOGLE_LOGTOSTDERR", false),
|
|
||||||
"log messages go to stderr instead of logfiles");
|
|
||||||
GLOG_DEFINE_bool(alsologtostderr, BoolFromEnv("GOOGLE_ALSOLOGTOSTDERR", false),
|
|
||||||
"log messages go to stderr in addition to logfiles");
|
|
||||||
GLOG_DEFINE_bool(colorlogtostderr, false,
|
|
||||||
"color messages logged to stderr (if supported by terminal)");
|
|
||||||
GLOG_DEFINE_bool(colorlogtostdout, false,
|
|
||||||
"color messages logged to stdout (if supported by terminal)");
|
|
||||||
GLOG_DEFINE_bool(logtostdout, BoolFromEnv("GOOGLE_LOGTOSTDOUT", false),
|
|
||||||
"log messages go to stdout instead of logfiles");
|
|
||||||
#ifdef GLOG_OS_LINUX
|
|
||||||
GLOG_DEFINE_bool(
|
|
||||||
drop_log_memory, true,
|
|
||||||
"Drop in-memory buffers of log contents. "
|
|
||||||
"Logs can grow very quickly and they are rarely read before they "
|
|
||||||
"need to be evicted from memory. Instead, drop them from memory "
|
|
||||||
"as soon as they are flushed to disk.");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// By default, errors (including fatal errors) get logged to stderr as
|
|
||||||
// well as the file.
|
|
||||||
//
|
|
||||||
// The default is ERROR instead of FATAL so that users can see problems
|
|
||||||
// when they run a program without having to look in another file.
|
|
||||||
DEFINE_int32(stderrthreshold, google::GLOG_ERROR,
|
|
||||||
"log messages at or above this level are copied to stderr in "
|
|
||||||
"addition to logfiles. This flag obsoletes --alsologtostderr.");
|
|
||||||
|
|
||||||
GLOG_DEFINE_string(alsologtoemail, "",
|
|
||||||
"log messages go to these email addresses "
|
|
||||||
"in addition to logfiles");
|
|
||||||
GLOG_DEFINE_bool(log_file_header, true,
|
|
||||||
"Write the file header at the start of each log file");
|
|
||||||
GLOG_DEFINE_bool(log_prefix, true,
|
|
||||||
"Prepend the log prefix to the start of each log line");
|
|
||||||
GLOG_DEFINE_bool(log_year_in_prefix, true,
|
|
||||||
"Include the year in the log prefix");
|
|
||||||
GLOG_DEFINE_int32(minloglevel, 0,
|
|
||||||
"Messages logged at a lower level than this don't "
|
|
||||||
"actually get logged anywhere");
|
|
||||||
GLOG_DEFINE_int32(logbuflevel, 0,
|
|
||||||
"Buffer log messages logged at this level or lower"
|
|
||||||
" (-1 means don't buffer; 0 means buffer INFO only;"
|
|
||||||
" ...)");
|
|
||||||
GLOG_DEFINE_int32(logbufsecs, 30,
|
|
||||||
"Buffer log messages for at most this many seconds");
|
|
||||||
|
|
||||||
GLOG_DEFINE_int32(logcleansecs, 60 * 5, // every 5 minutes
|
|
||||||
"Clean overdue logs every this many seconds");
|
|
||||||
|
|
||||||
GLOG_DEFINE_int32(logemaillevel, 999,
|
|
||||||
"Email log messages logged at this level or higher"
|
|
||||||
" (0 means email all; 3 means email FATAL only;"
|
|
||||||
" ...)");
|
|
||||||
GLOG_DEFINE_string(logmailer, "", "Mailer used to send logging email");
|
|
||||||
|
|
||||||
// Compute the default value for --log_dir
|
|
||||||
static const char* DefaultLogDir() {
|
|
||||||
const char* env;
|
|
||||||
env = getenv("GOOGLE_LOG_DIR");
|
|
||||||
if (env != nullptr && env[0] != '\0') {
|
|
||||||
return env;
|
|
||||||
}
|
|
||||||
env = getenv("TEST_TMPDIR");
|
|
||||||
if (env != nullptr && env[0] != '\0') {
|
|
||||||
return env;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
GLOG_DEFINE_int32(logfile_mode, 0664, "Log file mode/permissions.");
|
|
||||||
|
|
||||||
GLOG_DEFINE_string(
|
|
||||||
log_dir, DefaultLogDir(),
|
|
||||||
"If specified, logfiles are written into this directory instead "
|
|
||||||
"of the default logging directory.");
|
|
||||||
GLOG_DEFINE_string(log_link, "",
|
|
||||||
"Put additional links to the log "
|
|
||||||
"files in this directory");
|
|
||||||
|
|
||||||
GLOG_DEFINE_uint32(max_log_size, 1800,
|
|
||||||
"approx. maximum log file size (in MB). A value of 0 will "
|
|
||||||
"be silently overridden to 1.");
|
|
||||||
|
|
||||||
GLOG_DEFINE_bool(stop_logging_if_full_disk, false,
|
|
||||||
"Stop attempting to log to disk if the disk is full.");
|
|
||||||
|
|
||||||
GLOG_DEFINE_string(log_backtrace_at, "",
|
|
||||||
"Emit a backtrace when logging at file:linenum.");
|
|
||||||
|
|
||||||
GLOG_DEFINE_bool(log_utc_time, false, "Use UTC time for logging.");
|
|
||||||
|
|
||||||
// TODO(hamaji): consider windows
|
// TODO(hamaji): consider windows
|
||||||
enum { PATH_SEPARATOR = '/' };
|
enum { PATH_SEPARATOR = '/' };
|
||||||
|
|
||||||
|
|||||||
@ -63,8 +63,6 @@
|
|||||||
#include "glog/raw_logging.h"
|
#include "glog/raw_logging.h"
|
||||||
#include "googletest.h"
|
#include "googletest.h"
|
||||||
|
|
||||||
DECLARE_string(log_backtrace_at); // logging.cc
|
|
||||||
|
|
||||||
#ifdef GLOG_USE_GFLAGS
|
#ifdef GLOG_USE_GFLAGS
|
||||||
# include <gflags/gflags.h>
|
# include <gflags/gflags.h>
|
||||||
using namespace GFLAGS_NAMESPACE;
|
using namespace GFLAGS_NAMESPACE;
|
||||||
|
|||||||
@ -80,9 +80,6 @@ bool IsGoogleLoggingInitialized() {
|
|||||||
# include "stacktrace.h"
|
# include "stacktrace.h"
|
||||||
# include "symbolize.h"
|
# include "symbolize.h"
|
||||||
|
|
||||||
GLOG_DEFINE_bool(symbolize_stacktrace, true,
|
|
||||||
"Symbolize the stack trace in the tombstone");
|
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
|
|
||||||
using DebugWriter = void(const char*, void*);
|
using DebugWriter = void(const char*, void*);
|
||||||
|
|||||||
@ -39,8 +39,6 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/commandlineflags.h"
|
|
||||||
#include "base/googleinit.h"
|
|
||||||
#include "glog/logging.h"
|
#include "glog/logging.h"
|
||||||
#include "glog/raw_logging.h"
|
#include "glog/raw_logging.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
@ -50,18 +48,6 @@
|
|||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
GLOG_DEFINE_int32(v, 0,
|
|
||||||
"Show all VLOG(m) messages for m <= this."
|
|
||||||
" Overridable by --vmodule.");
|
|
||||||
|
|
||||||
GLOG_DEFINE_string(
|
|
||||||
vmodule, "",
|
|
||||||
"per-module verbose level."
|
|
||||||
" Argument is a comma-separated list of <module name>=<log level>."
|
|
||||||
" <module name> is a glob pattern, matched against the filename base"
|
|
||||||
" (that is, name ignoring .cc/.h./-inl.h)."
|
|
||||||
" <log level> overrides any value given by --v.");
|
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
|
|
||||||
namespace glog_internal_namespace_ {
|
namespace glog_internal_namespace_ {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user