Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduced LogEventBuilder instead of NLog.Fluent.LogBuilder #4325

Merged
merged 3 commits into from
Mar 27, 2021

Conversation

snakefoot
Copy link
Contributor

@snakefoot snakefoot commented Feb 27, 2021

Introduces LogEventBuilder as replacement for Fluent.LogBuilder. Alternative to #4044 that skips obsolete of ILogger-interfaces

Obsoleted the old fluent LogBuilder and introduced LogEventBuilder that is available without needing to write using NLog.Fluent. The interfaces are very similar, but the start method is a little different:

  • LogBuilder: logger.Info().Message("Hello").Write();
  • LogEventBuilder: logger.ForInfoEvent().Message("Hello").Write();

I guess one could change LogEventBuilder to be activated from using Info() but it would generate more noise about ambiguous extensions-methods. But actually I like ForInfoEvent() since it signals that one is starting to define a LogEvent.

Also unsure if I like the Write()-method. Think I prefer .Log() but then the transformation would not be that easy:

  • LogEventBuilder: logger.ForInfoEvent().Message("Hello").Log();

The major improvement in LogEventBuilder is there is no allocation if the LogLevel is not enabled. And when the LogLevel is enabled, then it no longer allocates an additional LogBuilder-object (Because LogEventBuilder is a struct on the stack). Resolves #532

@snakefoot snakefoot added this to the 5.0 (new) milestone Feb 27, 2021
@snakefoot snakefoot changed the title Introduced ILoggerBasic to replace ILogger. Introduced LogEventBuilder Introduced ILog to replace ILogger Feb 27, 2021
@snakefoot snakefoot changed the title Introduced ILog to replace ILogger Introduced ILog as light alternative to ILogger Feb 27, 2021
@snakefoot snakefoot force-pushed the ILoggerBasicBuilder branch from 920a703 to c18df30 Compare March 1, 2021 07:33
@snakefoot
Copy link
Contributor Author

snakefoot commented Mar 16, 2021

If #3366 becomes true, then it doesn't make sense to introduce a new interface, that will be removed with NLog 6.0

Guess I will just have just to live with the pain, and change the new LogEventBuilder to work with the very ugly ILogger-api.

@snakefoot snakefoot changed the title Introduced ILog as light alternative to ILogger Introduced LogEventBuilder instead of NLog.Fluent.LogBuilder Mar 17, 2021
@snakefoot snakefoot force-pushed the ILoggerBasicBuilder branch from 3d04287 to 5f4b031 Compare March 17, 2021 17:13
@snakefoot snakefoot closed this Mar 17, 2021
@snakefoot snakefoot reopened this Mar 17, 2021
@snakefoot snakefoot force-pushed the ILoggerBasicBuilder branch 2 times, most recently from 4071c44 to afa3639 Compare March 17, 2021 21:50
@snakefoot snakefoot force-pushed the ILoggerBasicBuilder branch from e58c23b to 5c1da65 Compare March 18, 2021 22:49
@snakefoot snakefoot closed this Mar 22, 2021
@snakefoot snakefoot reopened this Mar 22, 2021
@sonarqubecloud
Copy link

@snakefoot
Copy link
Contributor Author

@snakefoot snakefoot added the documentation done all docs done (wiki, api docs, lists on nlog-project.org, xmldocs) label Nov 23, 2021
@snakefoot snakefoot deleted the ILoggerBasicBuilder branch July 30, 2022 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Breaking API change (different to semantic change) documentation done all docs done (wiki, api docs, lists on nlog-project.org, xmldocs) feature needs documentation on wiki performance size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Callsite Layout Renderer and Caller Attributes
1 participant