I want to filter logs by Client/Server or by category Gameplay/UI etc. and skip logging into Editor console when needed. Can I achieve this by using the Logging package? If I write my own logging solution it looks like I can’t Burst compile it. Has anyone tried this package, any tips?
Yes, the logging package could help solve your use cases. You could set up different loggers for different categories of logs and you’d then easily be able to send them to different files, skip the editor console for some categories, or set different log levels for each. Even if using a single logger, you could pass the log category as a parameter to every log call and use a structured logging format (like JSON) which would allow you to filter the log files with third-party tools.
However there are some cons you should be aware of. The logging package is currently in maintenance mode, so no new features will be added to it. It’s not widely used so support for it by the community will likely be limited. Juggling multiple loggers can become inconvenient since you need to pass them around all the time. Capturing stack traces when logging from Burst-compiled code incurs a significant performance penalty. Also admittedly the documentation is pretty barebones.
I use the logging package to give me per World logs, as well as being able to disable or minimize logging my libraries so other users don’t need to see unimportant logs.
Results in this
Nothing special, can see my implementation here. Probably not too different to what Netcode does.
BLDebugSystem
BLDebug
Because I want it per world does mean I need to pass a custom debug struct to any job that uses it though.
Oh and then I just wrote a simple menu to control the log level
This looks exactly like what I need atm, thanks!
As an addition, if you’re curious why I have a CustomLog it’s because the logging package only source generator only generates the largest fixedstring variant, so if you have a 4096 fixed string somewhere, and everything else only needs a 128 variant, all of your logs will go through the 4096 method.
I just copied the source generated code and manually added all the size variants so i didn’t have to create 4k structs everywhere.