-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/logfile size control #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,13 +38,25 @@ std::unique_ptr<Backend> FileRecorderFactory::CreateFileLoggingBackend( | |
| const Configuration& config, | ||
| score::cpp::pmr::memory_resource* memory_resource) noexcept | ||
| { | ||
| const std::string file_name{std::string(config.GetLogFilePath().data(), config.GetLogFilePath().size()) + "/" + | ||
| std::string{config.GetAppId().data(), config.GetAppId().size()} + ".dlt"}; | ||
| const std::string file_path_base{std::string(config.GetLogFilePath().data(), config.GetLogFilePath().size())}; | ||
| const std::string app_id{std::string{config.GetAppId().data(), config.GetAppId().size()}}; | ||
| const std::string file_extension{".dlt"}; | ||
| std::string file_name{file_path_base + "/" + app_id + file_extension}; | ||
| if (config.GetNoOfLogFiles() > 1) { | ||
| file_name = file_path_base + "/" + app_id + "_1" + file_extension; | ||
| } | ||
|
|
||
| auto open_flags = score::os::Fcntl::Open::kReadWrite | score::os::Fcntl::Open::kCreate | score::os::Fcntl::Open::kCloseOnExec; | ||
| if (!config.IsCircularFileLogging()) | ||
| { | ||
| open_flags |= score::os::Fcntl::Open::kAppend; | ||
| } | ||
|
|
||
|
|
||
| // NOLINTBEGIN(score-banned-function): FileLoggingBackend is disabled in production. Argumentation: Ticket-75726 | ||
| const auto descriptor_result = fcntl_->open( | ||
| file_name.data(), | ||
| score::os::Fcntl::Open::kWriteOnly | score::os::Fcntl::Open::kCreate | score::os::Fcntl::Open::kCloseOnExec, | ||
| open_flags, | ||
| score::os::Stat::Mode::kReadUser | score::os::Stat::Mode::kWriteUser | score::os::Stat::Mode::kReadGroup | | ||
| score::os::Stat::Mode::kReadOthers); | ||
| // NOLINTEND(score-banned-function): see above for detailed explanation | ||
|
|
@@ -72,9 +84,15 @@ std::unique_ptr<Backend> FileRecorderFactory::CreateFileLoggingBackend( | |
|
|
||
| return std::make_unique<FileOutputBackend>(std::move(message_builder), | ||
| descriptor, | ||
| file_name, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Maintainability] The factory now forwards six backend-specific knobs ( Context for AgentsChain of Thought
Reasoning The comment accurately identifies that this PR expands the FileOutputBackend constructor call from 5 to 11 positional parameters, adding 6 new backend-specific knobs (file_name, IsCircularFileLogging, IsOverwriteLogOnFull, MaxLogFileSizeBytes, NoOfLogFiles, IsTruncateOnRotation). This is a real change introduced by this PR. The concern about misordered arguments is legitimate in C++ — three bool parameters (IsCircularFileLogging, IsOverwriteLogOnFull, IsTruncateOnRotation) and two numeric parameters could be swapped without compiler warnings. The suggestion is actionable: pass a settings struct or the Configuration reference to FileOutputBackend instead of individual parameters. The factory already has However, this is primarily a design/maintainability suggestion rather than a bug. The current code will work correctly if parameter ordering matches the constructor. The comment is valid but is a moderate-priority refactoring suggestion rather than a critical issue. Evidence Summary 1. File Snapshot (BASE)
2. File Lookup
3. File Snapshot (HEAD)
4. File Lookup
5. File Lookup
|
||
| std::move(allocator), | ||
| score::os::Fcntl::Default(memory_resource), | ||
| score::os::Unistd::Default(memory_resource)); | ||
| score::os::Unistd::Default(memory_resource), | ||
| config.IsCircularFileLogging(), | ||
| config.IsOverwriteLogOnFull(), | ||
| config.GetMaxLogFileSizeBytes(), | ||
| config.GetNoOfLogFiles(), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Logic] When Add a guard or clamp: const auto no_of_log_files = std::max(config.GetNoOfLogFiles(), static_cast<decltype(config.GetNoOfLogFiles())>(1));Then use Context for AgentsChain of Thought
Reasoning Analysis:
Overall: The comment identifies a genuine inconsistency in newly-introduced code, the concern about edge cases with 0 is reasonable (though unverified), and the fix is concrete and actionable. Evidence Summary 1. File Snapshot (HEAD)
2. File Lookup
3. File Lookup
4. File Lookup
5. File Lookup
6. File Lookup
7. File Lookup
8. File Lookup
9. File Lookup
10. File Snapshot (HEAD)
11. File Snapshot (BASE)
|
||
| config.IsTruncateOnRotation()); | ||
| } | ||
|
|
||
| } // namespace detail | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Maintainability] When more than one log file is configured the factory now renames the primary log from
<path>/<app>.dltto<path>/<app>_1.dlt. That file name is an externally observable contract (collectors, uploaders, cleanup scripts expect the unsuffixed name) and this change introduces a silent backward-incompatible storage path without any migration or feature flag. Deployments that already setNoOfLogFiles() > 1will suddenly stop writing to the previously documented location, and rolling back will leave stale_1files behind. Please preserve the existing base name for the active file and let rotation logic manage suffixed files, or gate the new naming scheme behind an explicit opt-in so external tooling has a migration path.Context for Agents
Chain of Thought
Reasoning
Failed to parse validation response
Evidence Summary
1. File Snapshot (BASE)
score/mw/log/detail/file_recorder/file_recorder_factory.cpp2. File Snapshot (HEAD)
score/mw/log/detail/file_recorder/file_recorder_factory.cpp3. File Lookup
configuration.h104. File Lookup
file_output_backend.h105. File Lookup
file_recorder_factory.h56. File Lookup
file_output_backend.cpp57. File Snapshot (HEAD)
score/mw/log/detail/file_recorder/file_recorder_factory.h8. File Snapshot (BASE)
score/mw/log/detail/file_recorder/file_recorder_factory.h9. File Lookup
Configuration.h1010. File Lookup
configuration.cpp1011. File Lookup
log_mode.h1012. File Lookup
configuration.hpp1013. File Lookup
configuration.h10