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

Move the logging infrastructure from ReactiveUI into Splat #33

Merged
merged 2 commits into from
Dec 17, 2013

Conversation

anaisbetts
Copy link
Member

Similar to #32, this PR moves the other super common reason to pull RxUI.Core into an unrelated library, the logging infrastructure.

I'd love to come up with something everyone can agree with so that we can share this code instead of all inflicting our own versions on people - at least the interfaces?

/cc @slodge @lbugnion @nigel-sampson

void Debug(IFormatProvider formatProvider, [Localizable(false)] string message, params object[] args);
void Debug([Localizable(false)] string message);
void Debug([Localizable(false)] string message, params object[] args);
void Debug<TArgument>(IFormatProvider formatProvider, [Localizable(false)] string message, TArgument argument);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything in particular we gain from using all these generics? I thought params object[] args combined with the right string.Format would be Good Enough...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With using all the generics, you avoid boxing value types, which normally I wouldn't care about but for logging it can actually make a difference (i.e. a tight loop could end up spewing thousands of boxes)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't these be boxed anyway due to the internal use of String.Format(IFormatProvider, String, Object[])?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dahlbyk Probably. 👨 🔫

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👨

It's so cute that they made an emoji of you.

You're absolutely right that avoiding boxing for logging here would be worth it...any clever ideas short of a custom implementation of String.Format()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first thoughts went to using StringBuilder.AppendFormat (which it turns out String.Format uses internally) and I'm not seeing any box/unbox IL instructions there. Will do some more digging but perhaps something's changed there (I'm looking at .NET 4.5.1)...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you have to box to use AppendFormat, bah humbug...

{
public void Write(string message, LogLevel logLevel)
{
if ((int)logLevel < (int)Level) return;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid building log messages that are never used, would it be worth making WrappingFullLogger even more dull by inserting this check before calling _inner.Write(...)?

@SimonCropp
Copy link
Contributor

@paulcbetts any timeline on this? I am contemplating extending it :)

@anaisbetts
Copy link
Member Author

@SimonCropp Quite soon :)

@anaisbetts
Copy link
Member Author

So, let's punt on the boxing perf for now - since the Interface is still correct, we can always fix the boxing later.

anaisbetts pushed a commit that referenced this pull request Dec 17, 2013
Move the logging infrastructure from ReactiveUI into Splat
@anaisbetts anaisbetts merged commit 5d3ec49 into master Dec 17, 2013
@anaisbetts anaisbetts deleted the logging branch December 19, 2013 01:04
@lock lock bot locked and limited conversation to collaborators Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants