Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions score/mw/log/detail/file_recorder/file_recorder_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,9 +84,15 @@ std::unique_ptr<Backend> FileRecorderFactory::CreateFileLoggingBackend(

return std::make_unique<FileOutputBackend>(std::move(message_builder),
descriptor,
file_name,
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(),
config.IsTruncateOnRotation());
Comment on lines +91 to +95
Copy link

@mobileinfo mobileinfo Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the benefit to pass these config parameters individually?

}

} // namespace detail
Expand Down
Loading