-
Notifications
You must be signed in to change notification settings - Fork 55
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
Allow redirection of lcf console messages #416
Conversation
Update: severity levels exists in Player already, so matching with them makes sense nowadays. |
Why are exceptions disabled in liblcf? |
Same reason why we disable RTTI: Portability. We have some quite low spec homebrew platforms that we support. We also do not want to maintain two codepaths. So no exception it is. |
But is printing to stderr a good choice? |
Uhm no that is why I plan to make this configurable in this PR? Currently errors land on stderr. |
Looking forward to begin merged |
I rechecked the code now: There is literally nothing finished here yet. Except for one example usage. Can't finish this for 0.8.0 in such short time. Hot candidate for 0.8.1 |
For XML the SetError function was removed and is printed directly. Tracing stuff (LCF_DEBUG_TRACE) goes now through fprintf. Not worth to send this through the logger as is off by default.
I think on liblcf side is not much missing anymore. The handler function concept is well-known and works. Usually you get some |
Like most other APIs do it
Suitable logging function for use in Player: lcf::LogHandler::SetHandler([](lcf::LogHandler::Level level, StringView message, lcf::LogHandler::UserData) {
Output::Debug("lcf ({}): {}", lcf::LogHandler::kLevelTags.tag(level), message);
}); So currently only written to terminal/logfile. Not sure if any of the stuff should be reported through the graphical "console" inside the window. Most of that stuff is recoverable (similar to the libpng warnings spamming the shell) and everything critical is already shown as an "Output::Error". |
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.
I find it a bit messy that at first every log message is made a C-String, then a C++ std::string and last a string_view.
Maybe we should make fmt
a lcf dependency in the future to hide the conversions.
Apart from the minor nits, LGTM
if ((i+1) % 16 == 0) { | ||
fprintf(stderr, "\n"); | ||
Log::Debug(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.
Android (clang) build fails with -Wformat-security
:
Log::Debug("%s", ss.str().c_str());
First commit: The chunk dumping during Skip didnt really work except on Windows. I finally fixed it (useful for Maniacs Patch to find unknown chunks). Also is now always on, a missing chunk is now always a bug because we know about all common ones.
Second commit: I want your feedback here. Before I implement this completely (is some work) please tell me if the general approach is fine for you.
I want to allow custom output handlers for lcf diagnostics. E.g. for the Player they could be written to easyrpg_log.txt. Currently they are completely lost which is bad for handling bug reports. As vital information is missing.
To redirect it library users can invoke lcf::LogHandler::SetHandler(Handlerfunctionhere)