|
So, I'm migrating projects from SlimDX and .NET 3.5, and there are two things that were insanely helpful on that side that I can't seem to find via a search of Answers, the Forum, or the Unity script documentation.
Obviously there are a few custom calls in there, but those are just illustrative; the main thing is what happens in Main. Basically, that lets me get exceptions off the main thread, and off any other threads, and have them be logged in a super useful format. I'm even packaging the debug symbols along with, so it gives me a line number along with any errors. For public betas, that is super useful in particular. I know that Unity has the log under the _Data folder in windows (and something comparable on OSX), but that doesn't seem to log everything, it doesn't let me log custom messages to my knowledge, and it gets cleared out every time the player starts another game. I love that that Unity log exists, and it's not like I want to turn that off or anything, but I'd also love to be able to additionally do something more like the above in addition. Any thoughts?
(comments are locked)
|
|
Have you reviewed Application.RegisterLogCallback ? While I haven't tested it myself, it would seem to be exactly what you need - you can use it to register your own callback function and then from it log by whatever method you desire (say, log4net). Okay, this is perfect. Thanks! After getting around that bug mentioned in the other thread, this does just what I want. Very helpful!
Jun 21 '10 at 07:55 PM
x4000
(comments are locked)
|
|
Regarding overflows and underflows: You can use the checked and unchecked keywords to change the behaviour at a block level. It may not be the same as application level settings, but it's pretty much the only way it'll work with unity About the exception handling: You may be able to get away with adding your functions to the same events that you do in main. This won't catch native exceptions though, and not much can be done about that You can then pump your exceptions to your own log file (System.IO.File.* perhaps) if you prefer not to use the output.log provided by Unity Okay, so this is pretty cool overall, thanks for the link there. I've been experimenting around with this (adding int.MaxValue to integers at runtime at various points), and the badnews is that this checked keyword is not stepping into the various methods. It works for a given code block and all the sub-blocks inside it (so inside loops, etc), but any method calls that are made don't inherit the checked property. Thinking about this, that makes sense for API purposes where that might cause unexpected crashes of a third party API, which is a bummer.
Jun 21 '10 at 07:54 PM
x4000
It seems like if there was a way to set this for the current AppDomain that would be the ideal solution (that's essentially what the compiler flag does, assuming one AppDomain in your executable), but I don't know a setting for that.
Jun 21 '10 at 07:54 PM
x4000
(comments are locked)
|
