Пример #1
0
        public void LogBufferedVerbose(IEnumerable <VerboseMessage> verboseMessages)
        {
            var count = verboseMessages.Count();
            var i     = 1;

            //var list = new List<AsyncLogEventInfo>();
            //int originalThreadId = Thread.CurrentThread.ManagedThreadId;
            foreach (var verbose in verboseMessages)
            {
                var logEventInfo = new LogEventInfo()
                {
                    Level     = LogLevel.Info,
                    TimeStamp = verbose.DateTime,
                    Message   = verbose.Message,
                };
                logEventInfo.AppendRoutineTag(verbose.DateTime, correlationToken, memberTag);
                logEventInfo.Properties["Description"] = $"BufferedVerbose";
                logEventInfo.Properties["Buffered"]    = $"{i++}/{count}";
                if (verbose.StackTrace != null)
                {
                    logEventInfo.Properties["StackTrace"] = verbose.StackTrace;
                }
                if (documentBuilder != null)
                {
                    documentBuilder.AddVerbose(verbose.DateTime, verbose.Message);
                }
                logger.Log(logEventInfo);
            }
        }
Пример #2
0
        public void LogVerbose(DateTime dateTime, string message)
        {
            var logEventInfo = new LogEventInfo()
            {
                Level     = LogLevel.Info,
                TimeStamp = dateTime,
                Message   = message
            };

            logEventInfo.AppendRoutineTag(dateTime, correlationToken, memberTag);
            logEventInfo.Properties["Description"] = $"Verbose";
            if (documentBuilder != null)
            {
                documentBuilder.AddVerbose(dateTime, message);
            }
            logger.Log(logEventInfo);
        }
Пример #3
0
        public void LogActivityStart(DateTime dateTime)
        {
            var logEventInfo = new LogEventInfo()
            {
                Level     = LogLevel.Trace,
                TimeStamp = dateTime,
                Message   = "Started"
            };

            logEventInfo.AppendRoutineTag(dateTime, correlationToken, memberTag);
            logEventInfo.Properties["Description"] = $"Start;";
            if (documentBuilder != null)
            {
                documentBuilder.AddProperty(dateTime, "Started");
            }
            logger.Log(logEventInfo);
        }
Пример #4
0
        public void LogException(DateTime dateTime, Exception excepion)
        {
            var message      = markdownException(excepion);
            var logEventInfo = new LogEventInfo()
            {
                Level     = LogLevel.Error,
                TimeStamp = dateTime,
                Message   = message
            };

            logEventInfo.AppendRoutineTag(dateTime, correlationToken, memberTag);
            logEventInfo.Properties["Description"] = $"Exception";
            if (documentBuilder != null)
            {
                documentBuilder.AddException(dateTime, message);
            }
            logger.Log(logEventInfo);
        }
Пример #5
0
        public void LogActivityFinish(DateTime dateTime, TimeSpan timeSpan, bool isSuccess)
        {
            var verb     = (isSuccess ? "Finished" : "FAILURE");
            var duration = Math.Round(timeSpan.TotalMilliseconds);

            var logEventInfo = new LogEventInfo()
            {
                Level     = LogLevel.Trace,
                TimeStamp = dateTime,
                Message   = verb + "; " + duration + "ms"
            };

            logEventInfo.AppendRoutineTag(dateTime, correlationToken, memberTag);
            logEventInfo.Properties["Description"] = $"Finish";
            if (documentBuilder != null)
            {
                documentBuilder.AddProperty(dateTime, $"{verb} - {duration}ms");
            }
            logger.Log(logEventInfo);
        }
Пример #6
0
 public void Output(DateTime dateTime, object output)
 {
     try
     {
         var message      = serializeObject(output, 1, true);
         var logEventInfo = new LogEventInfo()
         {
             Level     = LogLevel.Info,
             TimeStamp = dateTime,
             Message   = message
         };
         logEventInfo.AppendRoutineTag(dateTime, correlationToken, memberTag);
         logEventInfo.Properties["Description"] = $"Output";
         if (documentBuilder != null)
         {
             documentBuilder.AddOutput(dateTime, message);
         }
         logger.Log(logEventInfo);
     }
     catch (Exception ex)
     {
         LogException(DateTime.Now, ex);
     }
 }