logs: replace every fmt::print with a lg call instead (#1368)

Favors the `lg` namespace over `fmt` directly, as this will output the
logs to a file / has log levels.

I also made assertion errors go to a file, this unfortunately means
importing `lg` and hence `fmt` which was attempted to be avoided before.
But I'm not sure how else to do this aspect without re-inventing the
file logging.

We have a lot of commented out prints as well that we should probably
cleanup at some point / switch them to trace level and default to `info`
level.

I noticed the pattern of disabling debug logs behind some boolean,
something to consider cleaning up in the future -- if our logs were more
structured (knowing where they are coming from) then a lot this
boilerplate could be eliminated.

Closes #1358
This commit is contained in:
Tyler Wilding
2022-10-01 11:58:36 -04:00
committed by GitHub
parent 4e48ba21c1
commit 4d751af38e
120 changed files with 990 additions and 893 deletions
+6 -9
View File
@@ -326,10 +326,7 @@ goos::Object decompile_sparticle_rot_x(const std::vector<LinkedWord>& words,
goos::Object decompile_sparticle_int_with_rand_init(const std::vector<LinkedWord>& words,
const std::string& field_name,
const std::string& flag_name) {
if (flag_name != "plain-v1") {
fmt::print("Bad {} {}\n", field_name, flag_name);
}
ASSERT(flag_name == "plain-v1");
ASSERT_MSG(flag_name == "plain-v1", fmt::format("Bad {} {}\n", field_name, flag_name));
if (word_as_s32(words.at(2)) == 0 && word_as_s32(words.at(3)) == 1) {
return decompile_sparticle_int_init(words, field_name, flag_name);
}
@@ -451,7 +448,7 @@ goos::Object decompile_sparticle_group_item(const TypeSpec& type,
const TypeSystem& ts,
const LinkedObjectFile* /*file*/) {
// auto normal = decompile_structure(type, label, labels, words, ts, file, false);
// fmt::print("Doing: {}\n", normal.print());
// lg::print("Doing: {}\n", normal.print());
auto uncast_type_info = ts.lookup_type(type);
auto type_info = dynamic_cast<StructureType*>(uncast_type_info);
if (!type_info) {
@@ -530,7 +527,7 @@ goos::Object decompile_sparticle_group_item(const TypeSpec& type,
}
result += ')';
// fmt::print("Result: {}\n", result);
// lg::print("Result: {}\n", result);
return pretty_print::to_symbol(result);
}
@@ -541,7 +538,7 @@ goos::Object decompile_sparticle_field_init(const TypeSpec& type,
const TypeSystem& ts,
const LinkedObjectFile* file) {
auto normal = decompile_structure(type, label, labels, words, ts, file, false);
// fmt::print("Doing: {}\n", normal.print());
// lg::print("Doing: {}\n", normal.print());
auto uncast_type_info = ts.lookup_type(type);
auto type_info = dynamic_cast<StructureType*>(uncast_type_info);
if (!type_info) {
@@ -623,7 +620,7 @@ goos::Object decompile_sparticle_field_init(const TypeSpec& type,
}
}
// fmt::print("Result: {}\n\n", result.print());
// lg::print("Result: {}\n\n", result.print());
return result;
}
@@ -708,7 +705,7 @@ goos::Object decompile_sparticle_field_init(const DefpartElement::StaticInfo::Pa
}
}
// fmt::print("Result: {}\n\n", result.print());
// lg::print("Result: {}\n\n", result.print());
return result;
}
} // namespace decompiler