Moonlight-XboxOG latest
Moonlight Xbox OG is a port of the Moonlight Game Streaming client to the original Xbox console.
log_file.cpp File Reference

Implements log file lifecycle helpers. More...

#include "src/logging/log_file.h"
#include <array>
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <deque>
#include <string>
#include "src/platform/filesystem_utils.h"
#include "src/startup/storage_paths.h"
Include dependency graph for log_file.cpp:

Functions

bool logging::append_log_file_entry (const LogEntry &entry, const std::string &filePath=default_log_file_path(), std::string *errorMessage=nullptr)
 Append one formatted log entry to the persisted log file.
 
std::string logging::default_log_file_path ()
 Return the default path used for persisted log output.
 
LoadLogFileResult logging::load_log_file (const std::string &filePath=default_log_file_path(), std::size_t maxLines=64U)
 Load recent lines from the persisted log file.
 
bool logging::reset_log_file (const std::string &filePath=default_log_file_path(), std::string *errorMessage=nullptr)
 Truncate or recreate the persisted log file.
 

Detailed Description

Implements log file lifecycle helpers.

Function Documentation

◆ append_log_file_entry()

bool logging::append_log_file_entry ( const LogEntry & entry,
const std::string & filePath = default_log_file_path(),
std::string * errorMessage = nullptr )

Append one formatted log entry to the persisted log file.

Parameters
entryStructured log entry to append.
filePathTarget log file path.
errorMessageOptional output for I/O failures.
Returns
true when the entry was written successfully.

◆ default_log_file_path()

std::string logging::default_log_file_path ( )

Return the default path used for persisted log output.

Returns
Default log file path.

◆ load_log_file()

LoadLogFileResult logging::load_log_file ( const std::string & filePath = default_log_file_path(),
std::size_t maxLines = 64U )

Load recent lines from the persisted log file.

Parameters
filePathTarget log file path.
maxLinesMaximum number of trailing lines to retain.
Returns
Loaded log file contents and any error details.

◆ reset_log_file()

bool logging::reset_log_file ( const std::string & filePath = default_log_file_path(),
std::string * errorMessage = nullptr )

Truncate or recreate the persisted log file.

Parameters
filePathPath to reset.
errorMessageOptional output for I/O failures.
Returns
true when the file was reset successfully.