Skip to content

Commit

Permalink
SHORT LogLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Nov 17, 2023
1 parent 179e658 commit ec24589
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 4 additions & 1 deletion sandbox/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
{
console.ConfigureEnableAnsiEscapeCode = true;
console.OutputEncodingToUtf8 = true;
console.UsePlainTextFormatter();
console.UsePlainTextFormatter(formatter =>
{
formatter.SetPrefixFormatter($"{0:timeonly} | {1:short} | ", (template, info) => template.Format(info.Timestamp, info.LogLevel));
});
});
});
});
Expand Down
15 changes: 7 additions & 8 deletions src/ZLogger/MessageTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,26 @@ static void AppendLogLevel(ref Utf8StringWriter<IBufferWriter<byte>> writer, ref
{
case LogLevel.Trace:
writer.AppendUtf8("TRC"u8);
break;
return;
case LogLevel.Debug:
writer.AppendUtf8("DBG"u8);
break;
return;
case LogLevel.Information:
writer.AppendUtf8("INF"u8);
break;
return;
case LogLevel.Warning:
writer.AppendUtf8("WRN"u8);
break;
return;
case LogLevel.Error:
writer.AppendUtf8("ERR"u8);
break;
return;
case LogLevel.Critical:
writer.AppendUtf8("CRI"u8);
break;
return;
case LogLevel.None:
writer.AppendUtf8("NON"u8);
break;
return;
default:
writer.AppendFormatted(value);
break;
}
}
Expand Down

0 comments on commit ec24589

Please sign in to comment.