Skip to content

Commit

Permalink
Print a file-local message of UTC time of file rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
jdksjolen committed Feb 6, 2025
1 parent 81126c2 commit ae5ac77
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/hotspot/share/logging/logFileOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "logging/logAsyncWriter.hpp"
#include "logging/logConfiguration.hpp"
#include "logging/logFileOutput.hpp"
#include "logging/logDecorations.hpp"
#include "memory/allocation.inline.hpp"
#include "runtime/arguments.hpp"
#include "runtime/os.hpp"
Expand Down Expand Up @@ -370,6 +371,20 @@ void LogFileOutput::rotate() {
return;
}

{ // Produce a file-unique rotation message.
LogTagSet& tagset = LogTagSetMapping<LOG_TAGS(logging)>::tagset();
LogLevelType level = tagset.level_for(this);
if (level >= LogLevelType::Info) {
LogDecorations decorations(LogLevel::Info, tagset, tagset.decorators());

stringStream st(os::iso8601_timestamp_size);
char buf[os::iso8601_timestamp_size];
char* result = os::iso8601_time(os::javaTimeMillis(), buf, os::iso8601_timestamp_size, true);
st.print("Rotated file at %s", result);
this->write_internal(decorations, st.freeze());
}
}

// Reset accumulated size, increase current file counter, and check for file count wrap-around.
_current_size = 0;
increment_file_count();
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/logging/logTagSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ class LogTagSet {
_output_list.set_output_level(output, level);
}

const LogDecorators& decorators() {
return _decorators;
}

// Refresh the decorators for this tagset to contain the decorators for all
// of its current outputs combined with the given decorators.
void update_decorators(const LogDecorators& decorator = LogDecorators::None);
Expand Down

0 comments on commit ae5ac77

Please sign in to comment.