Ejemplo n.º 1
0
        private void AddJob(Loglevels level, string div, string msg, Exception ex, LoggingContext context1, LoggingContext context2, LoggingContext context3)
        {
            if (this.Level > level)
            {
                return;
            }

#if !UNITY_WEBGL || UNITY_EDITOR
            if (this.isDisposed)
            {
                return;
            }
#endif

            var job = new LogJob
            {
                level      = level,
                division   = div,
                msg        = msg,
                ex         = ex,
                time       = DateTime.Now,
                threadId   = System.Threading.Thread.CurrentThread.ManagedThreadId,
                stackTrace = System.Environment.StackTrace,
                context1   = context1 != null?context1.Clone() : null,
                                 context2 = context2 != null?context2.Clone() : null,
                                                context3 = context3 != null?context3.Clone() : null
            };

#if !UNITY_WEBGL || UNITY_EDITOR
            this.jobs.Enqueue(job);
            try
            {
                this.newJobEvent.Set();
            }
            catch
            {
                try
                {
                    this.Output.Write(job.level, job.ToJson(sb));
                }
                catch
                { }
                return;
            }

            if (System.Threading.Interlocked.CompareExchange(ref this.threadCreated, 1, 0) == 0)
            {
                BestHTTP.PlatformSupport.Threading.ThreadedRunner.RunLongLiving(ThreadFunc);
            }
#else
            this.Output.Write(job.level, job.ToJson(sb));
#endif
        }
Ejemplo n.º 2
0
        private void WriteToOutput(LogJob job)
        {
            string json = job.ToJson(sb);

            this.Output.Write(job.level, json);
        }