-
Notifications
You must be signed in to change notification settings - Fork 471
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
Add trace log level #404
Add trace log level #404
Conversation
@pi3k14 this request is a bit out of nowhere. Do you intend to use it in one of the Castle libraries, or are you using Castle's |
Notice Serilog has a LogLevel called Verbose |
@jonorossi We are using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pi3k14 sorry about the delay, all the unrelated changes makes for a large pull request.
The changes look good, only the one comment on the console logger.
Is "trace" the right name, it seems most loggers including log4net and NLog use it, while System.Diagnostics.SourceLevels
and Serilog use "verbose", however S.D.SL only has one level under info. "Trace" is probably clearer that it is lower than "debug", literally for detailed tracing turned on when needed.
@fir3pho3nixx @stakx I know we've spoken about reducing our dependence on Castle's ILogger which will take a while, but in the mean time I don't see any objection to this change. I'm assuming since you guys didn't jump in you don't mind either.
We'll need to consider how to release these changes because it'll be a breaking change to the ILogger
interface.
@pi3k14 could you update the changelog. Thanks.
I don't mind the change. It seems to me a pity that we need to support every log level ever conceived, even when they appear redundant in some cases; feels to me as if it made the common logging abstraction fall apart. That being said, adding more log levels is probably much easier and more straightforward than investing time in devising some opaque & overly clever log level mapping. And to be honest, I'm also not sufficiently familiar with the logging stuff to be a good judge on this. :) |
I vehemently disagree with this. I am not happy. I won’t block this to help folks out but as maintainers we should not be in this position. |
@jonorossi I added an entry in the ChangeLog, but unsure about your regime for version number and dates, please have a look. @fir3pho3nixx, a bit unsure about what "position" you don't like to be in. But maybe the Castle project should have a look at using LibLog (or EventSourceLogger, an ILogger implementation) and throw away your own logging abstraction? Lastly - I don't know why most of the code in this project used constructs like public void Trace(Func<string> messageFactory)
{
if (IsTraceEnabled)
{
Logger.Log(declaringType, Level.Trace, messageFactory.Invoke(), null);
}
} (I "normalized" all code to be similar) my preferred version would be public void Trace(Func<string> messageFactory)
{
Logger.Log(declaringType, Level.Trace, messageFactory.Invoke(), null);
} and let only the logger implementations perform the check for enabled log level. Give a hint, and I can change all to the latter. |
The idea is to avoid the "expensive" Invoke, when loglevel is not active
|
Normally all changes are initially listed under "Unreleased" heading; then when we're ready to publish a release, that title gets replaced with the actual version number and release date. That way, you as a contributor don't need to worry about version number & date at all, this will be determined by the Castle team (@jonorossi to be precise). It is also more accurate because there is no version 4.3.2 released on the 3rd, obviously. :) I was just briefly skimming over the changes, two things I noticed:
|
@stakx @fir3pho3nixx @pi3k14 you can probably tell I haven't been quick to progress this pull request, the new log level won't be used by Castle projects so only by users, this is the first time I recall this log level being proposed. The problem we've got right now is that we've discussed deprecating Castle's logging abstraction (which predates newer .NET logging, its from around 2004-2005) but haven't done anything about formalising that proposal to let people know our position and encourage users to use other libraries directly. We've briefly discussed how we could support a new logging facility for Windsor that isn't tied to the current Castle logging abstraction and would give users more freedom and not force all logging to a lowest common denominator interface (i.e. loosing structured logging when using Serilog). @pi3k14 what logging sink/adapter are you using under the Castle abstraction? |
@jonorossi for the time being we are using NLog (and Log4Net), but we are also in a process to find a better solution. Not sure yet what that is going to be ... EventSourceLogger and EventFlow looks interesting though. |
From my perspective, in Castle Project's prime (before 2010) users were building their applications with Windsor, MonoRail, ActiveRecord and other bits of the Castle stack so making use of the Castle logging abstraction wasn't a big thought as it just made sense; obviously most of these are now deprecated and other libraries have taken their place (i.e. ASP.NET MVC). We've been slimming down Windsor in the last year, and slowly deprecating bits dumped into what is today Castle Core. I'm not trying to be rude just completely honest to learn how people are using it, but if you don't see the Castle logging abstraction in your project's future why are you continuing to use it today rather than just talking to NLog directly? |
@stakx Fixed some space/tab glitches, corrected placement in ChangeLog. As for the Diagnostics logger I "feel" :) this is correct, but in practise it doesn't make any difference because of the simple log level mappings. |
@jonorossi "Rome wasn't built in one day" :), and it isn't just our libraries/apps but also third parties (eg. ASP.NET Boilerplate) that we have custom branches of. |
Very true 👍
Oh, I didn't realise ASP.NET Boilerplate recommended using Castle's logging: https://aspnetboilerplate.com/Pages/Documents/Logging. Since the 3 major .NET logging libraries have a log level under debug for tracing then we should probably just add it and move on. We'll separately need to start putting together our roadmap for Castle's logging abstraction and adapters, things won't happen overnight, it'll take a while to unroll things and will need to start from the top to add guidance and a new logging facility. |
src/Castle.Services.Logging.SerilogIntegration/SerilogLogger.cs
Outdated
Show resolved
Hide resolved
This reverts commit 9a78afd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look at the following few things!
src/Castle.Core.Tests/Core.Tests/Logging/LevelFilteredLoggerTests.cs
Outdated
Show resolved
Hide resolved
src/Castle.Core.Tests/Core.Tests/Logging/LevelFilteredLoggerTests.cs
Outdated
Show resolved
Hide resolved
src/Castle.Core.Tests/Core.Tests/Logging/LevelFilteredLoggerTests.cs
Outdated
Show resolved
Hide resolved
src/Castle.Core.Tests/Core.Tests/Logging/LevelFilteredLoggerTests.cs
Outdated
Show resolved
Hide resolved
src/Castle.Services.Logging.SerilogIntegration/SerilogLogger.cs
Outdated
Show resolved
Hide resolved
All comments should be resolved. |
Think you should keep the Level-check when you can avoid string.Format call or allocation of SystemStringFormat (Same overhead as calling Invoke)
This should be applied to all level-implementations
…Sent from my Samsung device
-------- Original message --------
From: Frode Nilsen <notifications@github.com>
Date: 05/09/2018 10:02 (GMT+01:00)
To: castleproject/Core <Core@noreply.github.com>
Cc: Rolf Kristensen <sweaty1@hotmail.com>, Mention <mention@noreply.github.com>
Subject: Re: [castleproject/Core] Feature request : Support trace logging (#404)
All comments should be resolved.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#404 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AK-fnE2p_IYH-n0iYhJTNs4wVjdliBEVks5uX4UqgaJpZM4V_xrW>.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now, except for one detail (see first review comment below).
This comment has been minimized.
This comment has been minimized.
@jonorossi, @stakx, @snakefoot I am holding back the last check-in until we are in agreement on what "correct" check of log levels are. |
I think the checks should be on for all levels when it avoid allocations. When logging is not enabled.
…Sent from my Samsung device
-------- Original message --------
From: Frode Nilsen <notifications@github.com>
Date: 05/09/2018 12:15 (GMT+01:00)
To: castleproject/Core <Core@noreply.github.com>
Cc: Rolf Kristensen <sweaty1@hotmail.com>, Mention <mention@noreply.github.com>
Subject: Re: [castleproject/Core] Feature request : Support trace logging (#404)
@jonorossi<https://github.com/jonorossi>, @stakx<https://github.com/stakx>, @snakefoot<https://github.com/snakefoot> I am holding back the last check-in until we are in agreement on what "correct" check of log levels are.
My current understanding is, use a IsTraceEnabled guard when Log function uses functors, creates new objects or use string.Format?
Only apply this rule to new methods created for Trace logging?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#404 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AK-fnEPogY0OhOopbWCLKXLt1coCA0CBks5uX6QlgaJpZM4V_xrW>.
|
@snakefoot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good except for the indentation in SerilogLogger.cs
.
src/Castle.Services.Logging.SerilogIntegration/SerilogLogger.cs
Outdated
Show resolved
Hide resolved
Thanks @pi3k14, apologises for so much back for forward. @stakx before we merge, what are your thoughts on versioning for releasing this, this has a breaking change to |
TL;DR: If we release a new major version (which seems reasonable to me), we should definitely include all deprecations with it to make that release a substantial one. (And if we decided in #408 to deprecate the logging facility as well, then there would possibly be no release with the new Now for some more detail. My initial feeling was that this wasn't a big deal and would probably justify only a minor version bump—because, just how many people these days actually implement If we wanted to turn this into a non-breaking change, we could probably go down the horrible COM route and move the new Which brings us back to a breaking change. My understanding is that you prefer major version releases to feel "substantial", so we should definitely include more than just the If we do this, perhaps we shouldn't merge this PR just yet and wait until we're getting closer to the v5 release. Because once it's merged, it might block us from releasing a further 4.x minor version if someone requests such a one. (Say we get a request to release 4.3.2 because of #406. We'd then have to create separate release branches to exclude or revert this PR here.) Alternatively, we could subscribe to semver's rather clinical view of major version bumps, which happen whenever there's a breaking change (however substantial or small), i.e. iterate major versions much more quickly than we have in the past. I'm not a big fan of this as humans give more meaning to version numbers than semver does, releasing new major versions every few months might just make Core look unstable. |
The logging facility is in Windsor, and the the logging abstraction isn't going away that quickly. We'd have to get everything else in place before even deprecating it (can't see it going anywhere in the next 12 months). I can guarantee there is a lot of use of these interfaces out there.
I was actually thinking the same thing, I'd be happy with 4.4.0 for these changes, that way we'd be able to release the changes without waiting for a big bang 5.0 release. Yer, not going down the COM-style route, i.e. ILogger2 or ILoggerEx 😆.
We can always branch off a tag, but yes I'd prefer we don't have work sitting unreleased in master so long.
I've always thought the same thing especially for libraries, I know people have held back on upgrades to JSON.NET major version bumps without even looking at the changes. My view is that you can't just change your dependencies and ship to production anyway, because any and all changes can be breaking changes even if they don't change the public API, all code changes change behaviour, and especially with Castle libraries which have sort of defaulted to everything being public the chance is even higher. |
From that perspective, choosing the version number becomes more a question of how much of a breaking change this might be. I would then say that the impact of the changes made to Here's three ideas:
|
👍, glad to read you agree.
This is something we've done in the past quite a bit, see the "Breaking Changes" heading under 4.1.0 last year for some minor but still breaking changes.
Interestingly I don't recall anyone complaining about us making small breaking changes in non-major versions in the past. A preamble feels a little YAGNI, if someone is taking the time to read the changelog they'll see the breaking changes section. I guess that means we are ready to merge this and get a release out. @stakx happy? |
@jonorossi, from my point of view, this is good to go. |
We've let this PR sit still for a while, same goes for #419. Are you OK if we merge them both |
@stakx my bad, working through my Castle notifications today. Since moving back to Gmail from "Inbox by Gmail" in September, I've found myself not actioning notifications after reading them since I was using a bundle in my inbox before so always saw them, but now they get hidden, out of sight out of mind. For now I've changed the email rule not to skip my inbox. |
Merged. Thanks @pi3k14, I'm normally not so slack getting pull requests merged. |
Modified logger to support Trace log in Log4Net & NLog (fallback to Debug for Serilog).