public string FormatSlow(Entry entry) { int slotNumber; var builder = FixedStringBuilderPool.Get(out slotNumber); try { var dt = entry.TimeStamp; builder.AppendDigitsFast(dt.Hour, 2); builder.Append(':'); builder.AppendDigitsFast(dt.Minute, 2); builder.Append(':'); builder.AppendDigitsFast(dt.Second, 2); builder.Append(':'); builder.AppendDigitsFast(dt.Millisecond, 3); builder.Append("|"); builder.Append(LogLevels.Levels[(int)entry.Level]); builder.Append("|"); builder.AppendDigitsFast(LogEnvironment.CurrentManagedThreadId, 2, ' '); builder.Append("|"); builder.Append(entry.Tag); builder.Append("|"); if (_categoryFormatter != null) { builder.Append(_categoryFormatter.GetString(entry.Category)); builder.Append("|"); } builder.Append(entry.Message); if (entry.Exception != null) { builder.Append(" --> "); string exceptionString = entry.Exception.ToString(); if (_doAsyncExceptionCleanup) { exceptionString = ExceptionUtil.CleanStackTrace(exceptionString); } builder.Append(exceptionString); } builder.AppendLine(); return(builder.ToString()); } finally { FixedStringBuilderPool.Return(slotNumber, builder); } }
public string Format(Entry entry) { int slotNumber; var builder = FixedStringBuilderPool.Get(out slotNumber); try { // This line looks strange but represents required format // http://help.papertrailapp.com/kb/configuration/configuring-remote-syslog-from-embedded-or-proprietary-systems/ builder.Append($"<22>1 {entry.TimeStamp.ToString("s")} {_uniqueId} {_applicationName} - - - "); builder.Append(LogLevels.Levels[(int)entry.Level]); builder.Append("|"); builder.Append(LogEnvironment.CurrentManagedThreadId.ToString()); builder.Append("|"); builder.Append(entry.Tag); builder.Append("|"); if (_categoryFormatter != null) { builder.Append(_categoryFormatter.GetString(entry.Category)); builder.Append("|"); } builder.Append(entry.Message); if (entry.Exception != null) { builder.Append(" --> "); var exceptionString = entry.Exception.ToString(); if (_doAsyncExceptionCleanup) { exceptionString = ExceptionUtil.CleanStackTrace(exceptionString); } builder.Append(exceptionString); } builder.AppendLine(); return(builder.ToString()); } finally { FixedStringBuilderPool.Return(slotNumber, builder); } }
public string Format(Entry entry) { int slotNumber; var builder = FixedStringBuilderPool.Get(out slotNumber); try { builder.Append(entry.TimeStamp.ToString("HH:mm:ss:fff")); builder.Append("|"); builder.Append(LogLevels.Levels[(int)entry.Level]); builder.Append("|"); builder.Append(LogEnvironment.CurrentManagedThreadId.ToString()); builder.Append("|"); builder.Append(entry.Tag); builder.Append("|"); if (_categoryFormatter != null) { builder.Append(_categoryFormatter.GetString(entry.Category)); builder.Append("|"); } builder.Append(entry.Message); if (entry.Exception != null) { builder.Append(" --> "); var exceptionString = entry.Exception.ToString(); if (_doAsyncExceptionCleanup) { exceptionString = ExceptionUtil.CleanStackTrace(exceptionString); } builder.Append(exceptionString); } return(builder.ToString()); } finally { FixedStringBuilderPool.Return(slotNumber, builder); } }