Skip to content

Commit

Permalink
Remove exporting of FLAGS_v and FLAGS_vmodule in vlog_is_on.h
Browse files Browse the repository at this point in the history
This leaves it to just provide XLS_VLOG_IS_ON() which will be
removed in the next step and replaced with VLOG_IS_ON().

PiperOrigin-RevId: 615942629
  • Loading branch information
hzeller authored and copybara-github committed Mar 14, 2024
1 parent 44d18d9 commit 0a26a09
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 105 deletions.
18 changes: 1 addition & 17 deletions xls/common/logging/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,7 @@ cc_library(
name = "vlog_is_on",
hdrs = ["vlog_is_on.h"],
visibility = ["//xls:xls_internal"],
deps = [
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
],
)

cc_test(
name = "vlog_is_on_test",
srcs = ["vlog_is_on_test.cc"],
deps = [
":logging",
":vlog_is_on",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log:globals",
"//xls/common:xls_gunit",
"//xls/common:xls_gunit_main",
],
deps = ["@com_google_absl//absl/log"],
)

py_test(
Expand Down
9 changes: 0 additions & 9 deletions xls/common/logging/vlog_is_on.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,8 @@
#ifndef XLS_COMMON_LOGGING_VLOG_IS_ON_H_
#define XLS_COMMON_LOGGING_VLOG_IS_ON_H_

#include <cstdint>
#include <string>

#include "absl/flags/declare.h"
#include "absl/log/log.h"

ABSL_DECLARE_FLAG(int32_t, v);
// Note: Setting vmodule with absl::SetFlag is not supported. Instead use
// absl::SetVLogLevel.
ABSL_DECLARE_FLAG(std::string, vmodule);

// We pack an int16_t verbosity level and an int16_t epoch into an
// int32_t at every XLS_VLOG_IS_ON() call site. The level determines
// whether the site should log, and the epoch determines whether the
Expand Down
72 changes: 0 additions & 72 deletions xls/common/logging/vlog_is_on_test.cc

This file was deleted.

13 changes: 6 additions & 7 deletions xls/common/status/status_builder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/base/log_severity.h"
#include "absl/flags/flag.h"
#include "absl/log/globals.h"
#include "absl/log/log.h"
#include "absl/log/log_entry.h"
Expand Down Expand Up @@ -224,10 +223,10 @@ TEST(StatusBuilderTest, LogToMultipleErrorLevelsLvalue) {
ConvertToStatusAndIgnore(builder.Log(LogSeverity::kError) << "yes!");

// This one shouldn't log because vlogging is disabled.
absl::SetFlag(&FLAGS_v, 0);
absl::SetGlobalVLogLevel(0);
ConvertToStatusAndIgnore(builder.VLog(2) << "Non!");

absl::SetFlag(&FLAGS_v, 2);
absl::SetGlobalVLogLevel(2);
ConvertToStatusAndIgnore(builder.VLog(2) << "Oui!");
}
}
Expand All @@ -245,10 +244,10 @@ TEST(StatusBuilderTest, LogToMultipleErrorLevelsRvalue) {
.Log(LogSeverity::kError)
<< "yes!");
// This one shouldn't log because vlogging is disabled.
absl::SetFlag(&FLAGS_v, 0);
absl::SetGlobalVLogLevel(0);
ConvertToStatusAndIgnore(
StatusBuilder(absl::AbortedError(""), Locs::kSecret).VLog(2) << "Non!");
absl::SetFlag(&FLAGS_v, 2);
absl::SetGlobalVLogLevel(2);
ConvertToStatusAndIgnore(
StatusBuilder(absl::AbortedError(""), Locs::kSecret).VLog(2) << "Oui!");
}
Expand Down Expand Up @@ -372,7 +371,7 @@ TEST(StatusBuilderTest, LogEveryZeroDuration) {
}

TEST(StatusBuilderTest, VLogModuleLvalue) {
absl::SetFlag(&FLAGS_v, 0);
absl::SetGlobalVLogLevel(0);
absl::SetVLogLevel("level0", 0);
absl::SetVLogLevel("level1", 1);
absl::SetVLogLevel("level2", 2);
Expand Down Expand Up @@ -417,7 +416,7 @@ TEST(StatusBuilderTest, VLogModuleLvalue) {
}

TEST(StatusBuilderTest, VLogModuleRvalue) {
absl::SetFlag(&FLAGS_v, 0);
absl::SetGlobalVLogLevel(0);
absl::SetVLogLevel("level0", 0);
absl::SetVLogLevel("level1", 1);
absl::SetVLogLevel("level2", 2);
Expand Down
1 change: 1 addition & 0 deletions xls/fuzzer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ cc_library(
"//xls/tools:eval_utils",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status",
Expand Down
6 changes: 6 additions & 0 deletions xls/fuzzer/sample_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include "absl/algorithm/container.h"
#include "absl/container/flat_hash_map.h"
#include "absl/flags/declare.h"
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
Expand Down Expand Up @@ -76,6 +78,10 @@
#include "xls/tools/eval_utils.h"
#include "re2/re2.h"

// These are used to forward, but also see comment below.
ABSL_DECLARE_FLAG(int32_t, v);
ABSL_DECLARE_FLAG(std::string, vmodule);

namespace xls {

namespace {
Expand Down

0 comments on commit 0a26a09

Please sign in to comment.