Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Way to use it without RegisterLogCallback?

Discussion in 'Unity Cloud Diagnostics' started by sebas77, Apr 1, 2015.

  1. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,641
    if I got it right, this library works using Application.RegisterLogCallback. However we use the function already, therefore once we start to use it, I guess the library stops to work.

    Can you confirm it? Do you have workarounds?
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Unity 5 renamed this delegate to logMessageReceived and fixed the issue of multiple libraries "fighting" over the log callback.

    If this library is new i bet it uses the new callback.
     
  3. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    I was just about to bring this up! Great minds think alike, I suppose.

    I'm super happy that Unity 5 finally fixed the RegisterLogCallback "fighting", but Unity 4.x users are still kind of up the creek without a paddle.

    After taking a quick peek under the hood, I think it would be great if you guys could also expose the Log method that you hook up to RegisterLogCallback. That way Unity 4.x users can make use of the "daisy-chain" method that's outlined here. They'd just have to register your Log method along with whatever else they have registered, after initializing the service.
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    The log callback is not exposed in any way that I am aware of.
    Also, in case you're using 3rd party code that registers the log callback it self (and for which you have no control over), even if you did have the reference to the log callback, you wouldn't be able to change that code to use your new mechanism of registering multiple callbacks.

    If you have control over the entire codebase, just have a single log callback registered and have that class expose an event that will allow multiple other classes to register to that (like in the link you mentioned).
     
  5. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Currently, the Log method is not exposed. That's why I said it'd be great if it could be exposed! It's currently private -- it'd only have to be set to public, and have a separate, new method to just run the initialization without actually hooking into RegisterLogCallback.

    You can probably get at it with Reflection, but the Init method does a few other things before registering the callback. I suppose you could probably call Init to initialize, register your own callback (thus overwriting the Crash Reporting one) and then use Reflection to add the Log method to your callback.

    I haven't tried it, but that may work. It'll be a complete mess, though, and I'd rather not have to resort to Reflection.

    Which works great, as long as the Log method for this is made public. :)
     
  6. Talarian

    Talarian

    Joined:
    Aug 8, 2014
    Posts:
    10
    Howdy! I'd like to echo this statement as well. We're looking into using the crash logging, but we also use Unity 4.x and can't have the Unity Crash Logger blowing away our Log Callback, as we require that to dump our Unity logs to disk on iOS/Android/etc.

    Any chances we can get a way to override this functionality, or expose the CrashReporting delegate such that we can pass in the exception callstack ourselves? Thanks!
     
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Why can't you use the RegisterLogCallback delegate ?
     
  8. Talarian

    Talarian

    Joined:
    Aug 8, 2014
    Posts:
    10
    Unity 4.x only allows for one thing to register the callback. When another thing comes along and calls RegisterLogCallback, it blows away previous ones. Unity's LogCallback delegate is private as far as I know; we can't access it directly.

    So what we have is either Unity's crash logging calls RegisterLogCallback internally, which blows away our RegisterLogCallback delegate, or vice versa, we blow away theirs. Both Unity's delegate AND the Crash Logger delegate are private, therefore unavailable for us to use directly.

    And no, upgrading to Unity 5.x is out of the question at the moment. We're just a couple months from release and that would be too destabilizing.
     
  9. jerome-lacoste

    jerome-lacoste

    Joined:
    Jan 7, 2012
    Posts:
    206
    It's not too hard to decompile the library, and add a hook to the CrashReporting class so that you can combine your LogCallback with theirs.

    That's what we did...

    We also made it so that we can change the UserId at runtime (i.e. after the user has logged in into our game).

    And no, I probably cannot share the code without authorisation from Unity.
     
    liortal likes this.
  10. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Why do you need authorization from them ?
     
  11. jerome-lacoste

    jerome-lacoste

    Joined:
    Jan 7, 2012
    Posts:
    206
    Because that's their code I modified :)
     
  12. Talarian

    Talarian

    Joined:
    Aug 8, 2014
    Posts:
    10
    Decompilation is explicitly against the terms of use. If we're going to use Unity's solution and be above board, we need Unity to support our scenario. We haven't heard anything about this for months, so I'm just going to have to look into different solutions.
     
  13. ChrisLundquist

    ChrisLundquist

    Unity Technologies

    Joined:
    Mar 2, 2015
    Posts:
    55
    I believe this is fixed in Unity 5.x. I wish I had a better answer for our Unity 4.x users.