LogFormat

This commit is contained in:
2022-11-17 21:35:20 +06:00
parent 7397933601
commit b3d8757afc
3 changed files with 14 additions and 8 deletions

View File

@@ -17,10 +17,16 @@ public class DefaultLogFormat : ILogFormat
public string CreateMessage(string context, LogSeverity severity, object message)
{
var sb = new StringBuilder();
if (PrintTimeStamp) sb.Append('[').Append(DateTime.Now.ToString(MyTimeFormat.ForText)).Append(']');
if(PrintContext) sb.Append('[').Append(context).Append(']');
if(PrintSeverity) sb.Append('[').Append(severity.ToString()).Append(']');
if (sb.Length != 0) sb.Append(": ");
if (PrintTimeStamp)
sb.Append('[').Append(DateTime.Now.ToString(MyTimeFormat.ForText)).Append(']');
if (PrintContext && PrintSeverity)
sb.Append('[').Append(context).Append('/').Append(severity.ToString().Append(']'));
else if(PrintContext)
sb.Append('[').Append(context).Append(']');
else if(PrintSeverity)
sb.Append('[').Append(severity.ToString()).Append(']');
if (sb.Length != 0)
sb.Append(": ");
sb.Append(message.ToString());
sb.Append('\n');
return sb.ToString();