diff --git a/src/ripple/beast/utility/EnhancedLogging.h b/src/ripple/beast/utility/EnhancedLogging.h index b51607d8e..198e0b52f 100644 --- a/src/ripple/beast/utility/EnhancedLogging.h +++ b/src/ripple/beast/utility/EnhancedLogging.h @@ -71,12 +71,9 @@ strip_source_root(const char* file) #endif } -// Location position enum -enum class LocationPosition { PREFIX, SUFFIX, NONE }; - -// Get configured position - cached at startup -LocationPosition -get_log_location_position(); +// Check if location info should be shown - cached at startup +bool +should_show_location(); // Helper to write location string (no leading/trailing space) void diff --git a/src/ripple/beast/utility/src/beast_EnhancedLogging.cpp b/src/ripple/beast/utility/src/beast_EnhancedLogging.cpp index b2161a104..c5f34bd88 100644 --- a/src/ripple/beast/utility/src/beast_EnhancedLogging.cpp +++ b/src/ripple/beast/utility/src/beast_EnhancedLogging.cpp @@ -83,26 +83,16 @@ get_log_highlight_color() return escape; } -// Get configured position - cached at startup -LocationPosition -get_log_location_position() +// Check if location info should be shown - cached at startup +bool +should_show_location() { - static const LocationPosition position = []() { - const char* env = std::getenv("LOG_LOCATION_POSITION"); - if (!env) - return LocationPosition::SUFFIX; // Default to suffix for better - // readability - - if (std::strcmp(env, "suffix") == 0 || std::strcmp(env, "end") == 0) - return LocationPosition::SUFFIX; - if (std::strcmp(env, "prefix") == 0 || std::strcmp(env, "start") == 0) - return LocationPosition::PREFIX; - if (std::strcmp(env, "none") == 0) - return LocationPosition::NONE; - - return LocationPosition::PREFIX; + static const bool show = []() { + const char* env = std::getenv("LOG_DISABLE"); + // Show location by default, hide if LOG_DISABLE=1 + return !env || std::strcmp(env, "1") != 0; }(); - return position; + return show; } // Helper to write location string (no leading/trailing space) diff --git a/src/ripple/beast/utility/src/beast_Journal.cpp b/src/ripple/beast/utility/src/beast_Journal.cpp index 2e85a2223..037da0b76 100644 --- a/src/ripple/beast/utility/src/beast_Journal.cpp +++ b/src/ripple/beast/utility/src/beast_Journal.cpp @@ -146,14 +146,6 @@ Journal::ScopedStream::ScopedStream( { // Modifiers applied from all ctors m_ostream << std::boolalpha << std::showbase; - - // Write prefix if configured - if (file_ && - detail::get_log_location_position() == detail::LocationPosition::PREFIX) - { - detail::log_write_location_string(m_ostream, file_, line_); - m_ostream << " "; - } } #endif @@ -162,11 +154,8 @@ Journal::ScopedStream::~ScopedStream() std::string s(m_ostream.str()); #ifdef BEAST_ENHANCED_LOGGING - // Add suffix if configured - if (file_ && - detail::get_log_location_position() == - detail::LocationPosition::SUFFIX && - !s.empty() && s != "\n") + // Add suffix if location is enabled + if (file_ && detail::should_show_location() && !s.empty() && s != "\n") { std::ostringstream combined; combined << s;