Esempio n. 1
0
        static Try <LogEvent> convertUnityMessageToLogEvent(
            string message, string backtraceS, LogType type, int stackFramesToSkipWhenGenerating
            )
        {
            try {
                var level = convertLevel(type);

                // We want to collect backtrace on the current thread
                var backtrace =
                    level >= Log.Level.WARN
            ?
                    // backtrace may be empty in release mode.
                    string.IsNullOrEmpty(backtraceS)
                ? Backtrace.generateFromHere(stackFramesToSkipWhenGenerating + 1 /*this stack frame*/)
                : Backtrace.parseUnityBacktrace(backtraceS)
            : Option <Backtrace> .None;
                var logEvent = new LogEvent(level, new LogEntry(
                                                message,
                                                ImmutableArray <Tpl <string, string> > .Empty,
                                                ImmutableArray <Tpl <string, string> > .Empty,
                                                backtrace, context: Option <Object> .None
                                                ));
                return(F.scs(logEvent));
            }
            catch (Exception e) {
                return(F.err <LogEvent>(e));
            }
        }
Esempio n. 2
0
        public void Test2()
        {
            var actual = Backtrace.parseUnityBacktrace(
                @"com.tinylabproductions.TLPGame.TLPGame+<>c.<.ctor>b__13_16 ()
com.tinylabproductions.TLPLib.Components.DebugConsole.DConsoleRegistrar+<>c__DisplayClass4_0.<register>b__0 ()
com.tinylabproductions.TLPLib.Components.DebugConsole.DConsoleRegistrar+<>c__DisplayClass5_0`1[com.tinylabproductions.TLPLib.Functional.Unit].<register>b__0 (Unit _)
com.tinylabproductions.TLPLib.Components.DebugConsole.DConsoleRegistrar+<>c__DisplayClass8_0`2[com.tinylabproductions.TLPLib.Functional.Unit,com.tinylabproductions.TLPLib.Functional.Unit].<register>b__0 (Unit obj)
com.tinylabproductions.TLPLib.Components.DebugConsole.DConsoleRegistrar+<>c__DisplayClass9_0`2[com.tinylabproductions.TLPLib.Functional.Unit,com.tinylabproductions.TLPLib.Functional.Unit].<register>b__0 ()
com.tinylabproductions.TLPLib.Components.DebugConsole.DConsole+<>c__DisplayClass18_0.<showGroup>b__0 ()
UnityEngine.Events.InvokableCall.Invoke (System.Object[] args)"
                ).get.elements.a;
            var expected = ImmutableList.Create(
                elem("com.tinylabproductions.TLPGame.TLPGame+<>c.<.ctor>b__13_16 ()"),
                elem("com.tinylabproductions.TLPLib.Components.DebugConsole.DConsoleRegistrar+<>c__DisplayClass4_0.<register>b__0 ()"),
                elem("com.tinylabproductions.TLPLib.Components.DebugConsole.DConsoleRegistrar+<>c__DisplayClass5_0`1[com.tinylabproductions.TLPLib.Functional.Unit].<register>b__0 (Unit _)"),
                elem("com.tinylabproductions.TLPLib.Components.DebugConsole.DConsoleRegistrar+<>c__DisplayClass8_0`2[com.tinylabproductions.TLPLib.Functional.Unit,com.tinylabproductions.TLPLib.Functional.Unit].<register>b__0 (Unit obj)"),
                elem("com.tinylabproductions.TLPLib.Components.DebugConsole.DConsoleRegistrar+<>c__DisplayClass9_0`2[com.tinylabproductions.TLPLib.Functional.Unit,com.tinylabproductions.TLPLib.Functional.Unit].<register>b__0 ()"),
                elem("com.tinylabproductions.TLPLib.Components.DebugConsole.DConsole+<>c__DisplayClass18_0.<showGroup>b__0 ()"),
                elem("UnityEngine.Events.InvokableCall.Invoke (System.Object[] args)")
                );

            actual.shouldEqual(expected);
        }
Esempio n. 3
0
 public static LogEntry fromException(
     string message, Exception ex, Object context = null
     ) => simple($"{message}: {ex.Message}", Backtrace.fromException(ex), context);