예제 #1
0
        protected override void PerformJob(DebuggerJob job)
        {
            string message     = "";
            bool   isException = false;

            try
            {
                Monitor.Enter(_StreamLock);

                if (job.Data is string)
                {
                    message = job.Data.ToString();
                }
                else if (job.Data is Exception)
                {
                    isException = true;
                    message     = _ErrorFormater.GetErrorLog(job.Data as Exception);
                }

                //Log to file
                _textWriter.Write(message + "\r\n");
                _textWriter.Flush();
            }
            finally
            {
                Monitor.Exit(_StreamLock);
            }


            if (isException)
            {
                //TODO Logger to Database
            }
        }
예제 #2
0
        private void WriteLog(object data)
        {
            if (_queueInitialized)
            {
                _debuggerQueue.AddJob(new DebuggerJob()
                {
                    Data = data, ID = Guid.NewGuid()
                });
            }
            else
            {
                string message     = "";
                bool   isException = false;
                try
                {
                    Monitor.Enter(_syncLock);
                    if (data is string)
                    {
                        message = data.ToString();
                    }
                    else if (data is Exception)
                    {
                        isException = true;
                        message     = _ErrorFormater.GetErrorLog(data as Exception);
                    }

                    //Log to file
                    _textWriter.Write(message + "\r\n");
                    _textWriter.Flush();
                }
                finally
                {
                    Monitor.Exit(_syncLock);
                }

                if (isException)
                {
                    //TODO Logger to Database
                }
            }
        }