Commit 9b83dc9f by Derek Mauro Committed by Copybara-Service

Move vlog_config to the internal directory and change the namespace of VLogSite

PiperOrigin-RevId: 588403935
Change-Id: I6a3af3c044b887ec65b19390d316cfb3ccdcc853
parent 5dc2cc1a
......@@ -180,6 +180,8 @@ set(ABSL_INTERNAL_DLL_FILES
"log/internal/proto.cc"
"log/internal/strip.h"
"log/internal/structured.h"
"log/internal/vlog_config.cc"
"log/internal/vlog_config.h"
"log/internal/voidify.h"
"log/initialize.cc"
"log/initialize.h"
......@@ -191,8 +193,6 @@ set(ABSL_INTERNAL_DLL_FILES
"log/log_sink_registry.h"
"log/log_streamer.h"
"log/structured.h"
"log/vlog_config.cc"
"log/vlog_config.h"
"log/vlog_is_on.h"
"memory/memory.h"
"meta/type_traits.h"
......
......@@ -92,7 +92,6 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":globals",
":vlog_config",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:log_severity",
......@@ -100,6 +99,7 @@ cc_library(
"//absl/flags:marshalling",
"//absl/log/internal:config",
"//absl/log/internal:flags",
"//absl/log/internal:vlog_config",
"//absl/strings",
],
# Binaries which do not access these flags from C++ still want this library linked in.
......@@ -239,25 +239,6 @@ cc_library(
)
cc_library(
name = "vlog_config",
srcs = ["vlog_config.cc"],
hdrs = ["vlog_config.h"],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:private"],
deps = [
"//absl/base",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/log/internal:fnmatch",
"//absl/memory",
"//absl/strings",
"//absl/synchronization",
"//absl/types:optional",
],
)
cc_library(
name = "vlog_is_on",
hdrs = ["vlog_is_on.h"],
copts = ABSL_DEFAULT_COPTS,
......@@ -266,9 +247,9 @@ cc_library(
"//absl/log:__subpackages__",
],
deps = [
":vlog_config",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/log/internal:vlog_config",
"//absl/strings",
],
)
......@@ -295,29 +276,6 @@ cc_test(
],
)
cc_test(
name = "vlog_config_benchmark",
size = "medium",
srcs = ["vlog_config_benchmark.cc"],
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
tags = [
"benchmark",
"no_test_loonix",
"notsan",
],
deps = [
":vlog_config",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/container:layout",
"//absl/memory",
"//absl/random:distributions",
"//absl/strings",
"@com_github_google_benchmark//:benchmark_main",
],
)
# Test targets
cc_test(
......
......@@ -680,9 +680,9 @@ absl_cc_library(
NAME
vlog_config_internal
SRCS
"vlog_config.cc"
"internal/vlog_config.cc"
HDRS
"vlog_config.h"
"internal/vlog_config.h"
COPTS
${ABSL_DEFAULT_COPTS}
LINKOPTS
......
......@@ -28,7 +28,7 @@
#include "absl/flags/marshalling.h"
#include "absl/log/globals.h"
#include "absl/log/internal/config.h"
#include "absl/log/vlog_config.h"
#include "absl/log/internal/vlog_config.h"
#include "absl/strings/numbers.h"
#include "absl/strings/string_view.h"
......
......@@ -378,6 +378,47 @@ cc_library(
],
)
cc_library(
name = "vlog_config",
srcs = ["vlog_config.cc"],
hdrs = ["vlog_config.h"],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//absl/log:__subpackages__"],
deps = [
"//absl/base",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/log/internal:fnmatch",
"//absl/memory",
"//absl/strings",
"//absl/synchronization",
"//absl/types:optional",
],
)
cc_binary(
name = "vlog_config_benchmark",
testonly = 1,
srcs = ["vlog_config_benchmark.cc"],
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
tags = [
"benchmark",
],
visibility = ["//visibility:private"],
deps = [
":vlog_config",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/container:layout",
"//absl/memory",
"//absl/random:distributions",
"//absl/strings",
"@com_github_google_benchmark//:benchmark_main",
],
)
# Test targets
cc_test(
name = "stderr_log_sink_test",
......
......@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "absl/log/vlog_config.h"
#include "absl/log/internal/vlog_config.h"
#include <stddef.h>
......@@ -42,6 +42,7 @@
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace log_internal {
namespace {
bool ModuleIsPath(absl::string_view module_pattern) {
#ifdef _WIN32
......@@ -51,7 +52,6 @@ bool ModuleIsPath(absl::string_view module_pattern) {
#endif
}
} // namespace
} // namespace log_internal
bool VLogSite::SlowIsEnabled(int stale_v, int level) {
if (ABSL_PREDICT_TRUE(stale_v != kUninitialized)) {
......@@ -71,7 +71,6 @@ bool VLogSite::SlowIsEnabled3(int stale_v) { return SlowIsEnabled(stale_v, 3); }
bool VLogSite::SlowIsEnabled4(int stale_v) { return SlowIsEnabled(stale_v, 4); }
bool VLogSite::SlowIsEnabled5(int stale_v) { return SlowIsEnabled(stale_v, 5); }
namespace log_internal {
namespace {
struct VModuleInfo final {
std::string module_pattern;
......
......@@ -21,8 +21,8 @@
// It also declares and defines multiple internal utilities used to implement
// `VLOG`, such as `VLogSiteManager`.
#ifndef ABSL_LOG_VLOG_CONFIG_H_
#define ABSL_LOG_VLOG_CONFIG_H_
#ifndef ABSL_LOG_INTERNAL_VLOG_CONFIG_H_
#define ABSL_LOG_INTERNAL_VLOG_CONFIG_H_
// IWYU pragma: private, include "absl/log/log.h"
......@@ -40,13 +40,14 @@
namespace absl {
ABSL_NAMESPACE_BEGIN
class VLogSite;
namespace log_internal {
class SyntheticBinary;
class VLogSite;
int RegisterAndInitialize(VLogSite* v);
void UpdateVLogSites();
constexpr int kUseFlag = (std::numeric_limits<int16_t>::min)();
} // namespace log_internal
// Represents a unique callsite for a `VLOG()` or `VLOG_IS_ON()` call.
//
......@@ -122,7 +123,6 @@ class VLogSite final {
static_assert(std::is_trivially_destructible<VLogSite>::value,
"VLogSite must be trivially destructible");
namespace log_internal {
// Returns the current verbose log level of `file`.
// Does not allocate memory.
int VLogLevel(absl::string_view file);
......@@ -155,8 +155,9 @@ void OnVLogVerbosityUpdate(std::function<void()> cb);
// Does not allocate memory.
VLogSite* SetVModuleListHeadForTestOnly(VLogSite* v);
} // namespace log_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_LOG_VLOG_CONFIG_H_
#endif // ABSL_LOG_INTERNAL_VLOG_CONFIG_H_
......@@ -26,7 +26,7 @@
#include "absl/base/config.h"
#include "absl/container/internal/layout.h"
#include "absl/log/vlog_config.h"
#include "absl/log/internal/vlog_config.h"
#include "absl/memory/memory.h"
#include "absl/random/distributions.h"
#include "absl/strings/str_cat.h"
......
......@@ -58,7 +58,7 @@
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/log/vlog_config.h" // IWYU pragma: export
#include "absl/log/internal/vlog_config.h" // IWYU pragma: export
#include "absl/strings/string_view.h"
// IWYU pragma: private, include "absl/log/log.h"
......@@ -81,13 +81,13 @@
//
// VLOG_IS_ON is not async signal safe, but it is guaranteed not to allocate
// new memory.
#define VLOG_IS_ON(verbose_level) \
(ABSL_LOG_INTERNAL_MAX_LOG_VERBOSITY_CHECK(verbose_level)[]() \
->::absl::VLogSite * \
{ \
ABSL_CONST_INIT static ::absl::VLogSite site(__FILE__); \
return &site; \
}() \
#define VLOG_IS_ON(verbose_level) \
(ABSL_LOG_INTERNAL_MAX_LOG_VERBOSITY_CHECK(verbose_level)[]() \
->::absl::log_internal::VLogSite * \
{ \
ABSL_CONST_INIT static ::absl::log_internal::VLogSite site(__FILE__); \
return &site; \
}() \
->IsEnabled(verbose_level))
namespace absl {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment