-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Emulator: Create a Log Backup #2464
base: main
Are you sure you want to change the base?
Conversation
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.
Seems fine, although one general thought is maybe we should do this as part of the log system init alongside defining the new log file instead of out in emulator init.
src/emulator.cpp
Outdated
#ifdef _WIN32 | ||
Common::NtApi::Initialize(); | ||
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); | ||
#endif | ||
|
||
// Renaming shad_log.txt to shad_log.old.txt when booting. | ||
const auto LogDir = Common::FS::GetUserPath(Common::FS::PathType::LogDir); | ||
const auto CurrentLog = LogDir / "shad_log.txt"; |
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.
We have a constant LOG_FILE
in the path util for this.
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.
We have a constant
LOG_FILE
in the path util for this.
I tried but it seems like rename
ignores it when I change. Maybe it wants a "raw" filename.
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.
With const auto CurrentLog = LogDir / LOG_FILE;
right? There shouldn't be any difference since it's just a string macro.
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.
Yes, you were right it works.
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.
Would it be more convenient if we defined the log file name without the extension? That way, we could easily change the base name in one place.
constexpr auto LOG_FILE = "shad_log";`
Then construct the full paths like this:
const auto CurrentLog = LogDir / (std::string(LOG_FILE) + ".txt");
const auto NewLogName = LogDir / (std::string(LOG_FILE) + ".old.txt");
What do you think about this approach?
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.
Would it be more convenient if we defined the log file name without the extension? That way, we could easily change the base name in one place.
constexpr auto LOG_FILE = "shad_log";`Then construct the full paths like this:
const auto CurrentLog = LogDir / (std::string(LOG_FILE) + ".txt"); const auto NewLogName = LogDir / (std::string(LOG_FILE) + ".old.txt");What do you think about this approach?
The problem is that LOG_FILE
is shad_log.txt
, if we do what you showed, it would make shad_log.txt.txt
and shad_log.txt.old.txt
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.
Yes, now I see that the constant is already used in the code. My bad.
@squidbus I placed the code to rename the log outside the emulator init. Is it ok now? |
What I had more in mind was, inside the log system where we initialize the file output to |
6715b59
to
1b62913
Compare
Tell me if I should migrate it to the log system. |
Compressing was planned? Logs may be VERY BIG. |
Probably later but it requires a lot of extra work. |
Like yuzu and other emulators, it is good to have a log backup.
When starting shadPS4, the log of the previous session is renamed to
shad_log.old.txt
.This can be useful to compare logs when making changes.
I tried to make the code as understandable as possible.