Skip to content
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

Add initialization option for replacing the internal logger with the Rust log crate #98

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ewpratten
Copy link
Contributor

This fixes #94, and supersedes #95

There is no need to link extra C code for replacing the internal logger when Rust is FFI-compatible in both directions.

This PR adds a new function (RaylibBuilder::replace_logger()) that, when called, will redirect all raylib log messages through calls to the log crate. In my particular use case, I am using this to further pass through Tokio's tracing crate, but it can be really used for anything.

Limitations

For now, I have artificially limited this (with a cfg macro) to only happen on Linux (it will just silently not replace the logger on other platforms) due to MSVC throwing a fit about __va_list_tag not existing (presumably since stdarg.h doesn't seem to be standard across compilers). I don't currently have the time to debug this on windows, and don't have the resources to compile it on macos.


This is the first of a small handful of PRs you will see from me, since it is the weekend of Ludum Dare 49, and my team is once again building our entry with this crate.

It also happens to be the month of hacktoberfest. I would appreciate if you could tag this PR as hacktoberfest-accepted weather or not it gets merged so it can count towards my total. More info on hacktoberfest can be found here.

@Dacode45
Copy link
Collaborator

Dacode45 commented Oct 7, 2021

Going to have to look at this one more closely

@IoIxD
Copy link
Contributor

IoIxD commented Jan 31, 2024

Hi, if you're still interested in working on this, some users of the library are moving over to a fork of it which aims to be actively maintained. It would be nice if you reopened the PR there!

@IoIxD
Copy link
Contributor

IoIxD commented Jan 31, 2024

I actually looked into this myself, this seems like an extremely promising feature. But I think we should instead make a safe binding to SetTraceLogCallback so that users can use their own logging crate if they want.
Do you mind if I do this on the new repo?

@ewpratten
Copy link
Contributor Author

Hi @IoIxD I've been maintaining my own similar (with very different goals) rust library for a while now.

https://github.com/ewpratten/raylib-ffi

Optional logging hooks is next on my personal feature list for it actually.

Feel free to make use of my code in this PR for the new fork of this repo if you'd like. I don't mind at all.

If you have further questions or comments or anything, feel free to reach out to me. I don't really keep an eye on the comment notifications for this repo, its actually a coincidence that I happened to glance at my screen when this GitHub notification came through 😆

@IoIxD
Copy link
Contributor

IoIxD commented Jan 31, 2024

Thanks!

@ewpratten
Copy link
Contributor Author

@IoIxD if you do make use of my work, I'd appreciate you @ mentioning me in the commit / PR, just so I can see what you end up doing with it. I'm curious 🙂

@IoIxD
Copy link
Contributor

IoIxD commented Jan 31, 2024

I'm probably gonna redo the commit, actually, to make a safe/public binding to the original function so that other users can use their own custom logger. I'll mention this in the PR though.

@ewpratten
Copy link
Contributor Author

ya, of course! Thanks

danslocombe pushed a commit to danslocombe/raylib-rs that referenced this pull request Nov 24, 2024
* partial android support

* remove `RAYMATH_STATIC_INLINE`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No way to set the log callback
3 participants