Beispiel #1
0
        public virtual void BuildEntryText(StringBuilder sb, string categoryName, LogLevel logLevel, EventId eventId, string message, Exception exception,
                                           FileLogScope logScope, DateTimeOffset timestamp)
        {
            AppendLogLevel(sb, logLevel);

            AppendCategoryName(sb, categoryName);

            AppendEventId(sb, eventId);

            AppendTimestamp(sb, timestamp);

            if (logScope != null)
            {
                AppendLogScopeInfo(sb, logScope);
            }

            if (!string.IsNullOrEmpty(message))
            {
                AppendMessage(sb, message);
            }

            if (exception != null)
            {
                AppendException(sb, exception);
            }
        }
Beispiel #2
0
        protected virtual void AppendLogScopeInfo(StringBuilder sb, FileLogScope logScope)
        {
            sb.Append(_messagePadding);

            var list = new List <FileLogScope>();

            do
            {
                list.Add(logScope);
            }while ((logScope = logScope.Parent) != null);

            var n = list.Count;

            AppendLogScope(sb, list[n - 1]);
            for (var i = n - 2; i >= 0; i--)
            {
                sb.Append(' ');
                AppendLogScope(sb, list[i]);
            }

            sb.AppendLine();
        }
Beispiel #3
0
 protected virtual void AppendLogScope(StringBuilder sb, FileLogScope logScope)
 {
     sb.Append("=> ");
     sb.Append(logScope);
 }
Beispiel #4
0
 public virtual IDisposable BeginScope <TState>(TState state)
 {
     return(FileLogScope.Push(state));
 }