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
+2 -2
View File
@@ -658,7 +658,7 @@ void Function::find_type_defs(LinkedObjectFile& file, DecompilerTypeSystem& dts)
if (instr.kind == InstructionKind::SLL && instr.get_dst(0).get_reg() == make_gpr(Reg::V0) &&
instr.get_src(0).get_reg() == make_gpr(Reg::RA) && instr.get_src(1).get_imm() == 0) {
// done!
// fmt::print("Got type {} parent {}\n", type_name, parent_type);
// lg::print("Got type {} parent {}\n", type_name, parent_type);
dts.add_type_parent(type_name, parent_type);
DecompilerLabel flag_label = file.labels.at(label_idx);
u64 word = file.read_data_word(flag_label);
@@ -667,7 +667,7 @@ void Function::find_type_defs(LinkedObjectFile& file, DecompilerTypeSystem& dts)
word |= (word2 << 32);
types_defined.push_back(type_name);
dts.add_type_flags(type_name, word);
// fmt::print("Flags are 0x{:x}\n", word);
// lg::print("Flags are 0x{:x}\n", word);
state = 0;
continue;
}