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 ...@@ -180,6 +180,8 @@ set(ABSL_INTERNAL_DLL_FILES
"log/internal/proto.cc" "log/internal/proto.cc"
"log/internal/strip.h" "log/internal/strip.h"
"log/internal/structured.h" "log/internal/structured.h"
"log/internal/vlog_config.cc"
"log/internal/vlog_config.h"
"log/internal/voidify.h" "log/internal/voidify.h"
"log/initialize.cc" "log/initialize.cc"
"log/initialize.h" "log/initialize.h"
...@@ -191,8 +193,6 @@ set(ABSL_INTERNAL_DLL_FILES ...@@ -191,8 +193,6 @@ set(ABSL_INTERNAL_DLL_FILES
"log/log_sink_registry.h" "log/log_sink_registry.h"
"log/log_streamer.h" "log/log_streamer.h"
"log/structured.h" "log/structured.h"
"log/vlog_config.cc"
"log/vlog_config.h"
"log/vlog_is_on.h" "log/vlog_is_on.h"
"memory/memory.h" "memory/memory.h"
"meta/type_traits.h" "meta/type_traits.h"
......
...@@ -92,7 +92,6 @@ cc_library( ...@@ -92,7 +92,6 @@ cc_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
":globals", ":globals",
":vlog_config",
"//absl/base:config", "//absl/base:config",
"//absl/base:core_headers", "//absl/base:core_headers",
"//absl/base:log_severity", "//absl/base:log_severity",
...@@ -100,6 +99,7 @@ cc_library( ...@@ -100,6 +99,7 @@ cc_library(
"//absl/flags:marshalling", "//absl/flags:marshalling",
"//absl/log/internal:config", "//absl/log/internal:config",
"//absl/log/internal:flags", "//absl/log/internal:flags",
"//absl/log/internal:vlog_config",
"//absl/strings", "//absl/strings",
], ],
# Binaries which do not access these flags from C++ still want this library linked in. # Binaries which do not access these flags from C++ still want this library linked in.
...@@ -239,25 +239,6 @@ cc_library( ...@@ -239,25 +239,6 @@ cc_library(
) )
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", name = "vlog_is_on",
hdrs = ["vlog_is_on.h"], hdrs = ["vlog_is_on.h"],
copts = ABSL_DEFAULT_COPTS, copts = ABSL_DEFAULT_COPTS,
...@@ -266,9 +247,9 @@ cc_library( ...@@ -266,9 +247,9 @@ cc_library(
"//absl/log:__subpackages__", "//absl/log:__subpackages__",
], ],
deps = [ deps = [
":vlog_config",
"//absl/base:config", "//absl/base:config",
"//absl/base:core_headers", "//absl/base:core_headers",
"//absl/log/internal:vlog_config",
"//absl/strings", "//absl/strings",
], ],
) )
...@@ -295,29 +276,6 @@ cc_test( ...@@ -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 # Test targets
cc_test( cc_test(
......
...@@ -680,9 +680,9 @@ absl_cc_library( ...@@ -680,9 +680,9 @@ absl_cc_library(
NAME NAME
vlog_config_internal vlog_config_internal
SRCS SRCS
"vlog_config.cc" "internal/vlog_config.cc"
HDRS HDRS
"vlog_config.h" "internal/vlog_config.h"
COPTS COPTS
${ABSL_DEFAULT_COPTS} ${ABSL_DEFAULT_COPTS}
LINKOPTS LINKOPTS
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "absl/flags/marshalling.h" #include "absl/flags/marshalling.h"
#include "absl/log/globals.h" #include "absl/log/globals.h"
#include "absl/log/internal/config.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/numbers.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
......
...@@ -378,6 +378,47 @@ cc_library( ...@@ -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 # Test targets
cc_test( cc_test(
name = "stderr_log_sink_test", name = "stderr_log_sink_test",
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "absl/log/vlog_config.h" #include "absl/log/internal/vlog_config.h"
#include <stddef.h> #include <stddef.h>
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
namespace absl { namespace absl {
ABSL_NAMESPACE_BEGIN ABSL_NAMESPACE_BEGIN
namespace log_internal { namespace log_internal {
namespace { namespace {
bool ModuleIsPath(absl::string_view module_pattern) { bool ModuleIsPath(absl::string_view module_pattern) {
#ifdef _WIN32 #ifdef _WIN32
...@@ -51,7 +52,6 @@ bool ModuleIsPath(absl::string_view module_pattern) { ...@@ -51,7 +52,6 @@ bool ModuleIsPath(absl::string_view module_pattern) {
#endif #endif
} }
} // namespace } // namespace
} // namespace log_internal
bool VLogSite::SlowIsEnabled(int stale_v, int level) { bool VLogSite::SlowIsEnabled(int stale_v, int level) {
if (ABSL_PREDICT_TRUE(stale_v != kUninitialized)) { if (ABSL_PREDICT_TRUE(stale_v != kUninitialized)) {
...@@ -71,7 +71,6 @@ bool VLogSite::SlowIsEnabled3(int stale_v) { return SlowIsEnabled(stale_v, 3); } ...@@ -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::SlowIsEnabled4(int stale_v) { return SlowIsEnabled(stale_v, 4); }
bool VLogSite::SlowIsEnabled5(int stale_v) { return SlowIsEnabled(stale_v, 5); } bool VLogSite::SlowIsEnabled5(int stale_v) { return SlowIsEnabled(stale_v, 5); }
namespace log_internal {
namespace { namespace {
struct VModuleInfo final { struct VModuleInfo final {
std::string module_pattern; std::string module_pattern;
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
// It also declares and defines multiple internal utilities used to implement // It also declares and defines multiple internal utilities used to implement
// `VLOG`, such as `VLogSiteManager`. // `VLOG`, such as `VLogSiteManager`.
#ifndef ABSL_LOG_VLOG_CONFIG_H_ #ifndef ABSL_LOG_INTERNAL_VLOG_CONFIG_H_
#define ABSL_LOG_VLOG_CONFIG_H_ #define ABSL_LOG_INTERNAL_VLOG_CONFIG_H_
// IWYU pragma: private, include "absl/log/log.h" // IWYU pragma: private, include "absl/log/log.h"
...@@ -40,13 +40,14 @@ ...@@ -40,13 +40,14 @@
namespace absl { namespace absl {
ABSL_NAMESPACE_BEGIN ABSL_NAMESPACE_BEGIN
class VLogSite;
namespace log_internal { namespace log_internal {
class SyntheticBinary; class SyntheticBinary;
class VLogSite;
int RegisterAndInitialize(VLogSite* v); int RegisterAndInitialize(VLogSite* v);
void UpdateVLogSites(); void UpdateVLogSites();
constexpr int kUseFlag = (std::numeric_limits<int16_t>::min)(); constexpr int kUseFlag = (std::numeric_limits<int16_t>::min)();
} // namespace log_internal
// Represents a unique callsite for a `VLOG()` or `VLOG_IS_ON()` call. // Represents a unique callsite for a `VLOG()` or `VLOG_IS_ON()` call.
// //
...@@ -122,7 +123,6 @@ class VLogSite final { ...@@ -122,7 +123,6 @@ class VLogSite final {
static_assert(std::is_trivially_destructible<VLogSite>::value, static_assert(std::is_trivially_destructible<VLogSite>::value,
"VLogSite must be trivially destructible"); "VLogSite must be trivially destructible");
namespace log_internal {
// Returns the current verbose log level of `file`. // Returns the current verbose log level of `file`.
// Does not allocate memory. // Does not allocate memory.
int VLogLevel(absl::string_view file); int VLogLevel(absl::string_view file);
...@@ -155,8 +155,9 @@ void OnVLogVerbosityUpdate(std::function<void()> cb); ...@@ -155,8 +155,9 @@ void OnVLogVerbosityUpdate(std::function<void()> cb);
// Does not allocate memory. // Does not allocate memory.
VLogSite* SetVModuleListHeadForTestOnly(VLogSite* v); VLogSite* SetVModuleListHeadForTestOnly(VLogSite* v);
} // namespace log_internal } // namespace log_internal
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
} // namespace absl } // namespace absl
#endif // ABSL_LOG_VLOG_CONFIG_H_ #endif // ABSL_LOG_INTERNAL_VLOG_CONFIG_H_
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "absl/base/config.h" #include "absl/base/config.h"
#include "absl/container/internal/layout.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/memory/memory.h"
#include "absl/random/distributions.h" #include "absl/random/distributions.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
#include "absl/base/config.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" #include "absl/strings/string_view.h"
// IWYU pragma: private, include "absl/log/log.h" // IWYU pragma: private, include "absl/log/log.h"
...@@ -83,9 +83,9 @@ ...@@ -83,9 +83,9 @@
// new memory. // new memory.
#define VLOG_IS_ON(verbose_level) \ #define VLOG_IS_ON(verbose_level) \
(ABSL_LOG_INTERNAL_MAX_LOG_VERBOSITY_CHECK(verbose_level)[]() \ (ABSL_LOG_INTERNAL_MAX_LOG_VERBOSITY_CHECK(verbose_level)[]() \
->::absl::VLogSite * \ ->::absl::log_internal::VLogSite * \
{ \ { \
ABSL_CONST_INIT static ::absl::VLogSite site(__FILE__); \ ABSL_CONST_INIT static ::absl::log_internal::VLogSite site(__FILE__); \
return &site; \ return &site; \
}() \ }() \
->IsEnabled(verbose_level)) ->IsEnabled(verbose_level))
......
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