log: rotate log files with timestamps and add flag to disable ANSI colors (#2886)

Rotates the log files with a timestamp instead of copying all files and
incrementing an integer. Increases the amount of info you have when
looking at user's log files (ie. when looking at all the files, the file
creation dates are accurate).


![image](https://github.com/open-goal/jak-project/assets/13153231/61bcdf51-f0f6-4eee-b1e5-140aede5d19e)

Also simplifies the API for setting the log file, and `gk` logs are now
game specific with `jak1` or `jak2`. Which should be useful going
forward.

Lastly, added a flag to all CLIs to disable ansi colors for people that
want to do so. Though at the same time, there is finally a workaround in
jenkins to fix ANSI colors in the truncated log view -- so I'm not sure
why anyone would want to get rid of the color information. You can even
setup text editors to display the color info making log parsing much
easier. Fixes #1917

---------

Co-authored-by: ManDude <7569514+ManDude@users.noreply.github.com>
This commit is contained in:
Tyler Wilding
2023-08-08 10:59:37 -06:00
committed by GitHub
parent 39d989cfcc
commit 5d7aa7cea1
10 changed files with 124 additions and 48 deletions
+6 -1
View File
@@ -8,6 +8,7 @@
#include "common/util/FileUtil.h"
#include "common/util/json_util.h"
#include "common/util/read_iso_file.h"
#include "common/util/term_util.h"
#include "common/util/unicode_util.h"
#include "decompiler/Disasm/OpcodeInfo.h"
@@ -258,6 +259,7 @@ int main(int argc, char** argv) {
app.add_flag("-c,--compile", flag_compile, "Compile the game");
app.add_flag("-p,--play", flag_play, "Play the game");
app.add_flag("-f,--folder", flag_folder, "Extract from folder");
define_common_cli_arguments(app);
app.validate_positionals();
CLI11_PARSE(app, argc, argv);
@@ -296,7 +298,10 @@ int main(int argc, char** argv) {
}
try {
lg::set_file(file_util::get_file_path({"log", "extractor.log"}));
lg::set_file("extractor");
if (_cli_flag_disable_ansi) {
lg::disable_ansi_colors();
}
} catch (const std::exception& e) {
lg::error("Failed to setup logging: {}", e.what());
return 1;