LogTextWriting.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #region --------------- Copyright Dresser Wayne Pignone -------------
  2. /*
  3. * $Log: /Wrk/WayneLibraries/Wrk/Log/LogTextWriting.cs $
  4. *
  5. * 2 08-02-13 9:54 Mattias.larsson
  6. * Support LogTextWritingParameters.
  7. *
  8. * 1 08-01-23 16:34 Mattias.larsson
  9. */
  10. #endregion
  11. using System.Text;
  12. namespace Wayne.Lib.Log
  13. {
  14. internal static class LogTextWriting
  15. {
  16. #region Methods
  17. public static string GetLogEntryText(LogWriter logWriter, LogEntry logEntry, LogTextWritingParameters writingParameters)
  18. {
  19. StringBuilder output = new StringBuilder();
  20. if (!string.IsNullOrEmpty(writingParameters.DateTimeFormat))
  21. {
  22. output.Append(logEntry.GetDateTimeString(writingParameters.DateTimeFormat));
  23. output.Append(" ");
  24. }
  25. if ((writingParameters.EntityLogKind != EntityLogKind.None) || !writingParameters.SuppressCategory)
  26. {
  27. output.Append(logEntry.EntityCategory.GetName(writingParameters.EntityLogKind, writingParameters.SuppressCategory));
  28. output.Append(": ");
  29. }
  30. int indentLength = output.Length;
  31. bool isFirstLine = true;
  32. string indent = null;
  33. logEntry.AppendToStringBuilder(logWriter, output, indentLength, ref isFirstLine, ref indent);
  34. return output.ToString();
  35. }
  36. #endregion
  37. }
  38. }