Skip to content

v2.6.0

Choose a tag to compare

@ltrzesniewski ltrzesniewski released this 12 Jan 19:12
· 60 commits to master since this release

New features

Improved support of ANSI color codes in log patterns

  • ConsoleAppender becomes a simple implementation of StreamAppender:
    • Color output now uses ANSI codes on Windows
    • Coloring becomes customizable through the given Formatter or DefaultStyle (see below)
  • Better SGR codes support in PatternWriter and DefaultFormatter:
    • New placeholders:
      • %levelColor: configurable through the LogLevelColors property
      • %resetColor: an alias for \e[0m
    • The strings in the pattern, the LogLevels and LogLevelColors properties all support custom SGR codes
    • The %{column:n} placeholder now counts by grapheme clusters
  • Added a few example styles in the DefaultStyle class which can be supplied to the ConsoleAppender constructor
    • Current default style for ConsoleAppender: DefaultStyle.Colored.BlueAndWhite (or its plain text version if ColorOutput is false)
    • Current default style for DefaultFormatter: DefaultStyle.NoColor.Simple
    • See the ZeroLog.Examples project or cat the examples.txt file from the artifacts in a console for a preview
  • New APIs:
    • DefaultFormatter.MessagePatternWriter to configure colors in the pattern
    • WithoutAnsiColorCodes() in PatternWriter and DefaultFormatter to return a version without color codes
    • Appender.Initialize() which is called before an appender is first used
    • StreamAppender.Formatter changes from init to set
    • New constructors in ConsoleAppender and DefaultFormatter

Analyzers and code fixes

  • Added a code fix which lets you change from the simple syntax (_log.Info(...)) to Append syntax (_log.Info().Append(...).Log()).
    This is particularly useful if you want to add structured data to a log message:
    imageimage

  • Renamed "Use string interpolation" to "Use simple syntax" for consistency. This undoes the previous fix:
    imageimage

  • Added a [PatternWriter.Pattern] attribute to analyze a literal pattern string on custom string arguments and properties