Skip to content
Snippets Groups Projects

log: add basic utility to log to editor from native plugin

Open Martin Finkel requested to merge mfkl/vlc-unity:log-to-editor-from-plugin into master
2 unresolved threads

Need to clarify the various logging things:

  • libvlcsharp logs (to Unity Editor console or stdout),
  • libvlc logs (_libVLC.Log += (s, e) => UnityEngine.Debug.Log(e.FormattedLog);)
  • now in-editor vlc plugin logs.

components that may want to publish logs:

  • unity users script,
  • libvlcsharp,
  • vlc unity plugin,
  • libvlc.

possible outputs:

  • Unity Editor Log Console
  • stdout,
  • log file.

solution:

  • register a log callback from UnityEngine.Debug.Log from the vlc-unity c# initialization script to the C++ vlc unity plugin.
  • expose log functions from the vlc-unity plugin (one for logging to the Unity Editor, another to log to stdout).
  • have libvlcsharp call into either of the exposed log functions (notably when an exception is thrown from a reverse callback).

https://blog.sentry.io/unity-exception-handling-a-beginners-guide/

I guess the user could want:

  • to subscribe all logs in a single call,
  • to selectively subscribe to some logs,
  • to send the libvlc logs to the editor and to send the vlc plugin logs to a file?
  • unity editor log color support, enable/disable
Edited by Martin Finkel

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
11 12 const int seekTimeDelta = 5000;
12 13 Texture2D tex = null;
13 14 bool playing;
14
15
16 [DllImport("VLCUnityPlugin", CallingConvention = CallingConvention.Cdecl)]
17 static extern void RegisterDebugCallback(debugCallback cb);
  • 22 static void OnDebugCallback(IntPtr request, int color, int size)
    23 {
    24 //Ptr to string
    25 string debug_string = Marshal.PtrToStringAnsi(request, size);
    26
    27 //Add Specified Color
    28 debug_string =
    29 String.Format("{0}{1}{2}{3}{4}",
    30 "<color=",
    31 ((Color)color).ToString(),
    32 ">",
    33 debug_string,
    34 "</color>"
    35 );
    36
    37 UnityEngine.Debug.Log(debug_string);
  • Martin Finkel changed the description

    changed the description

  • Author Maintainer

    This MR is needed to partly provide a fix to #131 (closed) (with some more code that uses it from libvlcsharp)

  • Martin Finkel changed the description

    changed the description

  • Martin Finkel added 26 commits

    added 26 commits

    Compare with previous version

  • Martin Finkel changed the description

    changed the description

  • Martin Finkel mentioned in merge request !44 (merged)

    mentioned in merge request !44 (merged)

  • Martin Finkel added 16 commits

    added 16 commits

    Compare with previous version

  • Martin Finkel added 12 commits

    added 12 commits

    Compare with previous version

  • Martin Finkel added 2 commits

    added 2 commits

    Compare with previous version

  • Martin Finkel changed the description

    changed the description

  • Author Maintainer
  • Please register or sign in to reply
    Loading