diff --git a/src/hotspot/share/logging/logConfiguration.cpp b/src/hotspot/share/logging/logConfiguration.cpp index ea8aaa1d733..b82458cf472 100644 --- a/src/hotspot/share/logging/logConfiguration.cpp +++ b/src/hotspot/share/logging/logConfiguration.cpp @@ -43,6 +43,9 @@ LogOutput** LogConfiguration::_outputs = nullptr; size_t LogConfiguration::_n_outputs = 0; +LogStdoutOutput* LogConfiguration::StdoutLog = nullptr; +LogStderrOutput* LogConfiguration::StderrLog = nullptr; + LogConfiguration::UpdateListenerFunction* LogConfiguration::_listener_callbacks = nullptr; size_t LogConfiguration::_n_listener_callbacks = 0; diff --git a/src/hotspot/share/logging/logConfiguration.hpp b/src/hotspot/share/logging/logConfiguration.hpp index f8f848cabea..e9cf3e53c8b 100644 --- a/src/hotspot/share/logging/logConfiguration.hpp +++ b/src/hotspot/share/logging/logConfiguration.hpp @@ -24,6 +24,7 @@ #ifndef SHARE_LOGGING_LOGCONFIGURATION_HPP #define SHARE_LOGGING_LOGCONFIGURATION_HPP +#include "logging/logFileStreamOutput.hpp" #include "logging/logLevel.hpp" #include "memory/allStatic.hpp" #include "utilities/globalDefinitions.hpp" @@ -41,6 +42,8 @@ class LogConfiguration : public AllStatic { friend class VMError; friend class LogTestFixture; public: + static LogStdoutOutput* StdoutLog; + static LogStderrOutput* StderrLog; // Function for listeners typedef void (*UpdateListenerFunction)(void); diff --git a/src/hotspot/share/logging/logFileStreamOutput.cpp b/src/hotspot/share/logging/logFileStreamOutput.cpp index 715c13279f8..76e67a45de2 100644 --- a/src/hotspot/share/logging/logFileStreamOutput.cpp +++ b/src/hotspot/share/logging/logFileStreamOutput.cpp @@ -32,8 +32,6 @@ #include "utilities/defaultStream.hpp" const char* const LogFileStreamOutput::FoldMultilinesOptionKey = "foldmultilines"; -LogStdoutOutput* StdoutLog = nullptr; -LogStderrOutput* StderrLog = nullptr; bool LogFileStreamOutput::set_option(const char* key, const char* value, outputStream* errstream) { bool success = false; diff --git a/src/hotspot/share/logging/logFileStreamOutput.hpp b/src/hotspot/share/logging/logFileStreamOutput.hpp index cd1d34c0864..a9c3e4b6ee1 100644 --- a/src/hotspot/share/logging/logFileStreamOutput.hpp +++ b/src/hotspot/share/logging/logFileStreamOutput.hpp @@ -87,7 +87,4 @@ class LogStderrOutput : public LogFileStreamOutput { } }; -extern LogStderrOutput* StderrLog; -extern LogStdoutOutput* StdoutLog; - #endif // SHARE_LOGGING_LOGFILESTREAMOUTPUT_HPP diff --git a/test/hotspot/gtest/logging/test_logConfiguration.cpp b/test/hotspot/gtest/logging/test_logConfiguration.cpp index dd9a9fc5ce8..c9be6965c5e 100644 --- a/test/hotspot/gtest/logging/test_logConfiguration.cpp +++ b/test/hotspot/gtest/logging/test_logConfiguration.cpp @@ -71,8 +71,8 @@ TEST_VM_F(LogConfigurationTest, describe) { const char* description = ss.as_string(); // Verify that stdout and stderr are listed by default - EXPECT_PRED2(string_contains_substring, description, StdoutLog->name()); - EXPECT_PRED2(string_contains_substring, description, StderrLog->name()); + EXPECT_PRED2(string_contains_substring, description, LogConfiguration::StdoutLog->name()); + EXPECT_PRED2(string_contains_substring, description, LogConfiguration::StderrLog->name()); // Verify that each tag, level and decorator is listed for (size_t i = 0; i < LogTag::Count; i++) { @@ -129,7 +129,7 @@ TEST_VM_F(LogConfigurationTest, update_output) { EXPECT_TRUE(is_described("all=info")); // Verify by iterating over tagsets - LogOutput* o = StdoutLog; + LogOutput* o = LogConfiguration::StdoutLog; for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { EXPECT_TRUE(ts->has_output(o)); EXPECT_TRUE(ts->is_level(LogLevel::Info)); @@ -181,8 +181,8 @@ TEST_VM_F(LogConfigurationTest, disable_logging) { // Verify that no tagset has logging enabled for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { - EXPECT_FALSE(ts->has_output(StdoutLog)); - EXPECT_FALSE(ts->has_output(StderrLog)); + EXPECT_FALSE(ts->has_output(LogConfiguration::StdoutLog)); + EXPECT_FALSE(ts->has_output(LogConfiguration::StderrLog)); EXPECT_FALSE(ts->is_level(LogLevel::Error)); } } @@ -196,7 +196,7 @@ TEST_VM_F(LogConfigurationTest, disable_output) { EXPECT_TRUE(is_described("#0: stdout all=off")); // Verify by iterating over tagsets - LogOutput* o = StdoutLog; + LogOutput* o = LogConfiguration::StdoutLog; for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { EXPECT_FALSE(ts->has_output(o)); EXPECT_FALSE(ts->is_level(LogLevel::Error)); @@ -336,7 +336,7 @@ TEST_VM_F(LogConfigurationTest, parse_empty_command_line_arguments) { bool ret = LogConfiguration::parse_command_line_arguments(cmdline); EXPECT_TRUE(ret) << "Error parsing command line arguments '" << cmdline << "'"; for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { - EXPECT_EQ(LogLevel::Unspecified, ts->level_for(StdoutLog)); + EXPECT_EQ(LogLevel::Unspecified, ts->level_for(LogConfiguration::StdoutLog)); } } } @@ -418,7 +418,7 @@ TEST_VM_F(LogConfigurationTest, configure_stdout) { EXPECT_FALSE(log_is_enabled(Debug, logging)); EXPECT_FALSE(log_is_enabled(Info, gc)); LogTagSet* logging_ts = &LogTagSetMapping::tagset(); - EXPECT_EQ(LogLevel::Info, logging_ts->level_for(StdoutLog)); + EXPECT_EQ(LogLevel::Info, logging_ts->level_for(LogConfiguration::StdoutLog)); // Enable 'gc=debug' (no wildcard), verifying no other tags are enabled LogConfiguration::configure_stdout(LogLevel::Debug, true, LOG_TAGS(gc)); @@ -428,9 +428,9 @@ TEST_VM_F(LogConfigurationTest, configure_stdout) { for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { if (ts->contains(PREFIX_LOG_TAG(gc))) { if (ts->ntags() == 1) { - EXPECT_EQ(LogLevel::Debug, ts->level_for(StdoutLog)); + EXPECT_EQ(LogLevel::Debug, ts->level_for(LogConfiguration::StdoutLog)); } else { - EXPECT_EQ(LogLevel::Off, ts->level_for(StdoutLog)); + EXPECT_EQ(LogLevel::Off, ts->level_for(LogConfiguration::StdoutLog)); } } } @@ -441,12 +441,12 @@ TEST_VM_F(LogConfigurationTest, configure_stdout) { EXPECT_TRUE(log_is_enabled(Trace, gc, heap)); for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { if (ts->contains(PREFIX_LOG_TAG(gc))) { - EXPECT_EQ(LogLevel::Trace, ts->level_for(StdoutLog)); + EXPECT_EQ(LogLevel::Trace, ts->level_for(LogConfiguration::StdoutLog)); } else if (ts == logging_ts) { // Previous setting for 'logging' should remain - EXPECT_EQ(LogLevel::Info, ts->level_for(StdoutLog)); + EXPECT_EQ(LogLevel::Info, ts->level_for(LogConfiguration::StdoutLog)); } else { - EXPECT_EQ(LogLevel::Off, ts->level_for(StdoutLog)); + EXPECT_EQ(LogLevel::Off, ts->level_for(LogConfiguration::StdoutLog)); } } @@ -457,7 +457,7 @@ TEST_VM_F(LogConfigurationTest, configure_stdout) { EXPECT_FALSE(log_is_enabled(Error, gc)); EXPECT_FALSE(log_is_enabled(Error, gc, heap)); for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { - EXPECT_EQ(LogLevel::Off, ts->level_for(StdoutLog)); + EXPECT_EQ(LogLevel::Off, ts->level_for(LogConfiguration::StdoutLog)); } } diff --git a/test/hotspot/gtest/logging/test_logOutputList.cpp b/test/hotspot/gtest/logging/test_logOutputList.cpp index 346ef936316..121fc9847ff 100644 --- a/test/hotspot/gtest/logging/test_logOutputList.cpp +++ b/test/hotspot/gtest/logging/test_logOutputList.cpp @@ -22,6 +22,7 @@ */ #include "precompiled.hpp" +#include "logging/logConfiguration.hpp" #include "logging/logFileStreamOutput.hpp" #include "logging/logLevel.hpp" #include "logging/logOutput.hpp" @@ -174,7 +175,7 @@ TEST(LogOutputList, is_level_single_output) { for (size_t i = LogLevel::First; i < LogLevel::Count; i++) { LogLevelType level = static_cast(i); LogOutputList list; - list.set_output_level(StdoutLog, level); + list.set_output_level(LogConfiguration::StdoutLog, level); for (size_t j = LogLevel::First; j < LogLevel::Count; j++) { LogLevelType other = static_cast(j); // Verify that levels finer than the current level for stdout are reported as disabled, @@ -202,8 +203,8 @@ TEST(LogOutputList, is_level_empty) { // Test is_level() on lists with two outputs on different levels TEST(LogOutputList, is_level_multiple_outputs) { for (size_t i = LogLevel::First; i < LogLevel::Count - 1; i++) { - LogOutput* dummy1 = StdoutLog; - LogOutput* dummy2 = StderrLog; + LogOutput* dummy1 = LogConfiguration::StdoutLog; + LogOutput* dummy2 = LogConfiguration::StderrLog; LogLevelType first = static_cast(i); LogLevelType second = static_cast(i + 1); LogOutputList list; @@ -227,19 +228,19 @@ TEST(LogOutputList, level_for) { LogOutputList list; // Ask the empty list about stdout, stderr - EXPECT_EQ(LogLevel::Off, list.level_for(StdoutLog)); - EXPECT_EQ(LogLevel::Off, list.level_for(StderrLog)); + EXPECT_EQ(LogLevel::Off, list.level_for(LogConfiguration::StdoutLog)); + EXPECT_EQ(LogLevel::Off, list.level_for(LogConfiguration::StderrLog)); // Ask for level in a list with two outputs on different levels - list.set_output_level(StdoutLog, LogLevel::Info); - list.set_output_level(StderrLog, LogLevel::Trace); - EXPECT_EQ(LogLevel::Info, list.level_for(StdoutLog)); - EXPECT_EQ(LogLevel::Trace, list.level_for(StderrLog)); + list.set_output_level(LogConfiguration::StdoutLog, LogLevel::Info); + list.set_output_level(LogConfiguration::StderrLog, LogLevel::Trace); + EXPECT_EQ(LogLevel::Info, list.level_for(LogConfiguration::StdoutLog)); + EXPECT_EQ(LogLevel::Trace, list.level_for(LogConfiguration::StderrLog)); // Remove and ask again - list.set_output_level(StdoutLog, LogLevel::Off); - EXPECT_EQ(LogLevel::Off, list.level_for(StdoutLog)); - EXPECT_EQ(LogLevel::Trace, list.level_for(StderrLog)); + list.set_output_level(LogConfiguration::StdoutLog, LogLevel::Off); + EXPECT_EQ(LogLevel::Off, list.level_for(LogConfiguration::StdoutLog)); + EXPECT_EQ(LogLevel::Trace, list.level_for(LogConfiguration::StderrLog)); // Ask about an unknown output LogOutput* dummy = dummy_output(4711); @@ -252,5 +253,5 @@ TEST(LogOutputList, level_for) { } // Make sure the stderr level is still the same - EXPECT_EQ(LogLevel::Trace, list.level_for(StderrLog)); + EXPECT_EQ(LogLevel::Trace, list.level_for(LogConfiguration::StderrLog)); } diff --git a/test/hotspot/gtest/logging/test_logTagSet.cpp b/test/hotspot/gtest/logging/test_logTagSet.cpp index d1cf555a3ff..b6133673c45 100644 --- a/test/hotspot/gtest/logging/test_logTagSet.cpp +++ b/test/hotspot/gtest/logging/test_logTagSet.cpp @@ -22,6 +22,7 @@ */ #include "precompiled.hpp" +#include "logging/logConfiguration.hpp" #include "logging/logFileStreamOutput.hpp" #include "logging/logLevel.hpp" #include "logging/logOutput.hpp" @@ -39,18 +40,18 @@ TEST(LogTagSet, defaults) { EXPECT_TRUE(ts->is_level(LogLevel::Error)); EXPECT_TRUE(ts->is_level(LogLevel::Warning)); EXPECT_FALSE(ts->is_level(LogLevel::Info)); - EXPECT_TRUE(ts->has_output(StdoutLog)); - EXPECT_FALSE(ts->has_output(StderrLog)); + EXPECT_TRUE(ts->has_output(LogConfiguration::StdoutLog)); + EXPECT_FALSE(ts->has_output(LogConfiguration::StderrLog)); } } TEST(LogTagSet, has_output) { LogTagSet& ts = LogTagSetMapping::tagset(); - ts.set_output_level(StderrLog, LogLevel::Trace); - EXPECT_TRUE(ts.has_output(StderrLog)); + ts.set_output_level(LogConfiguration::StderrLog, LogLevel::Trace); + EXPECT_TRUE(ts.has_output(LogConfiguration::StderrLog)); EXPECT_FALSE(ts.has_output(NULL)); - ts.set_output_level(StderrLog, LogLevel::Off); - EXPECT_FALSE(ts.has_output(StderrLog)); + ts.set_output_level(LogConfiguration::StderrLog, LogLevel::Off); + EXPECT_FALSE(ts.has_output(LogConfiguration::StderrLog)); } TEST(LogTagSet, ntags) { @@ -63,18 +64,18 @@ TEST(LogTagSet, ntags) { TEST(LogTagSet, is_level) { LogTagSet& ts = LogTagSetMapping::tagset(); // Set info level on stdout and verify that is_level() reports correctly - ts.set_output_level(StdoutLog, LogLevel::Info); + ts.set_output_level(LogConfiguration::StdoutLog, LogLevel::Info); EXPECT_TRUE(ts.is_level(LogLevel::Error)); EXPECT_TRUE(ts.is_level(LogLevel::Warning)); EXPECT_TRUE(ts.is_level(LogLevel::Info)); EXPECT_FALSE(ts.is_level(LogLevel::Debug)); EXPECT_FALSE(ts.is_level(LogLevel::Trace)); - ts.set_output_level(StdoutLog, LogLevel::Default); + ts.set_output_level(LogConfiguration::StdoutLog, LogLevel::Default); EXPECT_TRUE(ts.is_level(LogLevel::Default)); } TEST(LogTagSet, level_for) { - LogOutput* output = StdoutLog; + LogOutput* output = LogConfiguration::StdoutLog; LogTagSet& ts = LogTagSetMapping::tagset(); for (uint i = 0; i < LogLevel::Count; i++) { LogLevelType level = static_cast(i);