Hi, I've been trying to get Bevy to log to a file using samcarey's workaround here: https://github.com/bevyengine/bevy/issues/5233 . This involves disabling LogPlugin and replacing it with a duplicate library with some minor tweaks. I've done that successfully but i'm having trouble adding tracing's WorkerGuard as a resource (so it isn't dropped). Evidently it won't work because WorkerGuard doesn't implement the resource trait, which makes sense. Can anyone point me towards any examples/resources for implementing resource against things from non-bevy crates?
#Implement the resource trait on an preexisting struct / get tracing-appender working with bevy
4 messages · Page 1 of 1 (latest)
Ah-ha, I've found this: https://bevyengine.org/learn/book/migration-guides/0.8-0.9/
.. so I guess I have to take WorkerGuard and "wrap it in a tuple struct to bypass orphan rules". I won't lie, I haven't done any rust for half a year and that sentence might as well have said "reverse the polarity of the neutron flow" XD
Alright... Think I have to do something like this
#[derive(Resource)]
struct WorkerGuardResource(pub WorkerGuard);
getting closer...
Yeah that did it.
Just incase anyone comes across this later, to make samcarey's workaround work in 0.91 you need to add something like
#[derive(Resource)]
struct WorkerGuardResource(WorkerGuard);
to your edited LogPlugin. Then instead of
app.insert_resource(worker_guard);
You'd need to have something like
let worker_guard_resource = WorkerGuardResource(worker_guard);
app.insert_resource(worker_guard_resource);