Moonlight-XboxOG latest
Moonlight Xbox OG is a port of the Moonlight Game Streaming client to the original Xbox console.
log_file.h
Go to the documentation of this file.
1
5#pragma once
6
7// standard includes
8#include <cstddef>
9#include <string>
10#include <vector>
11
12// local includes
13#include "src/logging/logger.h"
14
15namespace logging {
16
21 std::string filePath;
22 std::vector<std::string> lines;
23 bool fileFound = false;
24 std::string errorMessage;
25 };
26
32 std::string default_log_file_path();
33
41 bool reset_log_file(const std::string &filePath = default_log_file_path(), std::string *errorMessage = nullptr);
42
51 bool append_log_file_entry(const LogEntry &entry, const std::string &filePath = default_log_file_path(), std::string *errorMessage = nullptr);
52
57 public:
63 explicit RuntimeLogFileSink(std::string filePath = default_log_file_path());
64
70 const std::string &file_path() const;
71
78 bool reset(std::string *errorMessage = nullptr) const;
79
87 bool consume(const LogEntry &entry, std::string *errorMessage = nullptr) const;
88
89 private:
90 std::string filePath_;
91 };
92
100 LoadLogFileResult load_log_file(const std::string &filePath = default_log_file_path(), std::size_t maxLines = 64U);
101
102} // namespace logging
Small helper that targets one persisted runtime log file.
Definition log_file.h:56
const std::string & file_path() const
Return the configured runtime log-file path.
Definition log_file.cpp:92
bool consume(const LogEntry &entry, std::string *errorMessage=nullptr) const
Append one log entry to the configured runtime log file.
Definition log_file.cpp:100
RuntimeLogFileSink(std::string filePath=default_log_file_path())
Construct a runtime log-file sink for the requested file path.
Definition log_file.cpp:89
bool reset(std::string *errorMessage=nullptr) const
Truncate or recreate the configured runtime log file.
Definition log_file.cpp:96
@ logging
Logging and diagnostics options.
std::string default_log_file_path()
Return the default path used for persisted log output.
Definition log_file.cpp:30
bool append_log_file_entry(const LogEntry &entry, const std::string &filePath, std::string *errorMessage)
Append one formatted log entry to the persisted log file.
Definition log_file.cpp:57
LoadLogFileResult load_log_file(const std::string &filePath, std::size_t maxLines)
Load recent lines from the persisted log file.
Definition log_file.cpp:104
bool reset_log_file(const std::string &filePath, std::string *errorMessage)
Truncate or recreate the persisted log file.
Definition log_file.cpp:34
Declares logging configuration and output.
Result of loading the persisted log file for the shell viewer.
Definition log_file.h:20
bool fileFound
True when the target file existed on disk.
Definition log_file.h:23
std::string filePath
Path that was requested for loading.
Definition log_file.h:21
std::vector< std::string > lines
Loaded log lines in display order.
Definition log_file.h:22
std::string errorMessage
Error detail when loading failed.
Definition log_file.h:24
Structured log entry stored by the in-memory logger.
Definition logger.h:83