Example #1
0
        /// <summary>
        /// Notify a Unity log message if it the client has been configured to
        /// notify at the specified level, if not leave a breadcrumb with the log
        /// message.
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="stackTrace"></param>
        /// <param name="logType"></param>
        void Notify(string condition, string stackTrace, LogType logType)
        {
            if (Configuration.AutoNotify && logType.IsGreaterThanOrEqualTo(Configuration.NotifyLevel))
            {
                var logMessage = new UnityLogMessage(condition, stackTrace, logType);

                if (UniqueCounter.ShouldSend(logMessage))
                {
                    if (LogTypeCounter.ShouldSend(logMessage))
                    {
                        var severity          = Configuration.LogTypeSeverityMapping.Map(logType);
                        var backupStackFrames = new System.Diagnostics.StackTrace(1, true).GetFrames();
                        var forceUnhandled    = logType == LogType.Exception && !Configuration.ReportUncaughtExceptionsAsHandled;
                        var exception         = Exception.FromUnityLogMessage(logMessage, backupStackFrames, severity, forceUnhandled);
                        Notify(new Exception[] { exception }, exception.HandledState, null, logType);
                    }
                }
            }
            else
            {
                Breadcrumbs.Leave(logType.ToString(), BreadcrumbType.Log, new Dictionary <string, string> {
                    { "message", condition },
                });
            }
        }