-
Notifications
You must be signed in to change notification settings - Fork 16
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
[BS-Hooks 4] Paper switch and format #147
base: master
Are you sure you want to change the base?
Conversation
Looks more or less good so far, don't forget to add formatters for wrapper types (either to the same file or somewhere else entirely) also, I'd like to guard debug logs behind a macro so we can enable/disable them at preprocessor time |
Fixes #104 |
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.
Sorry for the huge review, I know it's still in draft but I was in the reviewing mood. Feel free to not feel like doing many of these things, no problem, we can talk more about them in the future.
shared/utils/il2cpp-functions.hpp
Outdated
@@ -1,8 +1,6 @@ | |||
#ifndef IL2CPP_FUNCTIONS_H | |||
#define IL2CPP_FUNCTIONS_H | |||
#pragma once |
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.
This is intentionally guarded not by a pragma once but by a define. This allows it to collide on duplicate versions of this header and share this header tag ID, same for utils.h/utils-functions.h (and especially typedefs.h which is not touched in this PR)
@@ -1,6 +1,8 @@ | |||
#pragma once |
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.
This is a reasonable #pragma once, for example.
@@ -25,7 +25,6 @@ extern/ | |||
qpm.shared.json | |||
*.backup | |||
extern.cmake | |||
qpm_defines.cmake |
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.
If this is no longer ignored, where is the corresponding file committed to this repo? Shouldn't this still be ignored?
shared/utils/il2cpp-functions.hpp
Outdated
@@ -434,16 +433,16 @@ class il2cpp_functions { | |||
// must be done on-demand because the pointers aren't necessarily correct at the time of il2cpp_functions::Init | |||
static void CheckS_GlobalMetadata() { | |||
if (!s_GlobalMetadataHeader) { | |||
static auto& logger = getFuncLogger(); | |||
static auto& logger = ::il2cpp_utils::getLogger(); |
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 should also not have this be static so the compiler can see through it (since it's just a lookup anyways)
src/utils/logging.cpp
Outdated
#include <ctime> | ||
#include <iomanip> | ||
#include <sstream> | ||
static Paper::LoggerContext loggerContext = |
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.
Move this static into the function call (lets try and cut down on the number of global statics we have, they suck).
Also, it's worth noting that we now have no easy way of converting code that debug logs to avoid debug logging (ex, like we normally would via means by checking against NDEBUG
) We could maybe still do something here where we have getLogger()
return an empty instance, but that would stop ALL logging, not just debug logging.
src/utils/utils.cpp
Outdated
void safeAbort(const char* func, const char* file, int line, uint16_t frameCount) { | ||
static auto logger = Logger::get().WithContext("CRASH_UNLESS"); | ||
static auto logger = il2cpp_utils::getLogger(); |
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.
drop static and avoid copy but this one matters less since we are exiting
ss << std::endl; | ||
Logger::get().log(lvl, "%s", ss.str().c_str()); | ||
il2cpp_utils::getLogger().fmtLog<Paper::LogLevel::INF>("{}", ss.str().c_str()); |
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.
Is there no non-templated log by level here? If not, drop the lvl
param and change the usage to not have the level specified, or move the entire definition to a header and make it templated.
src/utils/utils.cpp
Outdated
__attribute__((format(printf, 4, 5))) void safeAbortMsg(const char* func, const char* file, int line, const char* fmt, ...) { | ||
static auto logger = Logger::get().WithContext("CRASH_UNLESS"); | ||
void safeAbortMsg(const char* func, const char* file, int line, const char* fmt, ...) { | ||
static auto logger = il2cpp_utils::getLogger(); |
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.
drop static and avoid copy but also does not matter as much since we are exiting
std::terminate(); // cleans things up and then calls abort | ||
} | ||
|
||
__attribute__((format(printf, 4, 5))) void safeAbortMsg(const char* func, const char* file, int line, const char* fmt, ...) { | ||
static auto logger = Logger::get().WithContext("CRASH_UNLESS"); | ||
void safeAbortMsg(const char* func, const char* file, int line, const char* fmt, ...) { |
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.
Removing the attribute here is not necessary, but instead we could swap to using a format abort instead. That would probably work nicer in the future as well. Ex:
CriticalLog(...);
SAFE_ABORT();
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.
Sorry for the huge review, I know it's still in draft but I was in the reviewing mood. Feel free to not feel like doing many of these things, no problem, we can talk more about them in the future.
Use
paperlog
Switches all format specifiers to
fmt
syntaxAdds format wrappers for
StringW
,MethodInfo
,ParameterInfo
,FieldInfo
,SafePtr<T>
,SafePtrUnity<T>
Todo: