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

Exceptionless selflog for serilog #4

Merged
merged 4 commits into from
Jan 17, 2017
Merged

Conversation

hmvs
Copy link

@hmvs hmvs commented Jan 14, 2017

Copy link
Member

@niemyjski niemyjski left a comment

Choose a reason for hiding this comment

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

Thanks for your PR, it looks good. I just don't think that we should hook it up by default. We should put it in the docs.

@@ -45,6 +45,7 @@ public class ExceptionlessSink : ILogEventSink {
config.ServerUrl = serverUrl;

config.UseInMemoryStorage();
config.UseLogger(new SelfLogLogger());
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should be included by default. We should add this to the docs, diagnostic messages shouldn't be included by default.

@@ -66,7 +67,13 @@ public class ExceptionlessSink : ILogEventSink {
public ExceptionlessSink(Func<EventBuilder, EventBuilder> additionalOperation = null, bool includeProperties = true, ExceptionlessClient client = null) {
_additionalOperation = additionalOperation;
_includeProperties = includeProperties;
_client = client ?? ExceptionlessClient.Default;
if (client != null) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we also revert this part, diagnostics shouldn't be included by default.

using Serilog.Debugging;

namespace Serilog.Sinks.Exceptionless {
public class SelfLogLogger : IExceptionlessLog {
Copy link
Member

Choose a reason for hiding this comment

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

Will this class name conflict with other self log implementations? Should we prefix it?

@hmvs
Copy link
Author

hmvs commented Jan 16, 2017

@niemyjski You will not see diagnostics until you call Serilog.Debugging.SelfLog.Enable(Console.Out);
And this usually only one thing that should be done to see diagnostics in serilog.
About class name - i have put it in our namespace. So should be fine.

}
else {
_client = ExceptionlessClient.Default;
_client.Configuration.UseLogger(new SelfLogLogger());
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we should only do this on the default instance instead of every time? If you pass in your own client instance (you might be passing in ExceptionlessClient.Default), we won't wire up the self log? Maybe do _client = client ?? ExceptionlessClient.Default; and the following line call useLogger

Copy link
Author

Choose a reason for hiding this comment

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

But in this case we will overwrite logging if user have already set up logging for the client.
Maybe we should apply logging if logger is null.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think there is code in the client to detect the null logger.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

So you could do a type check and just set it and simplify the code a bit too to do the previous _client = client ?? ExceptionlessClient.Default;

Copy link
Author

Choose a reason for hiding this comment

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

Yep, will change it. Thanks

@hmvs
Copy link
Author

hmvs commented Jan 16, 2017

@niemyjski Please have a look. Do we have better ways to understand that it is NullExceptionlessLog, or it's fine?

@niemyjski
Copy link
Member

I'll take a deeper look in the morning. I could of swore we had a HasRegistration method.

@hmvs
Copy link
Author

hmvs commented Jan 17, 2017

I found event better, we have HasDefaultRegistration.
So i have tried and user can mute it by exceptionlessClient.Configuration.UseLogger(new NullExceptionlessLog()) and it will not overwrite it.

@hmvs
Copy link
Author

hmvs commented Jan 17, 2017

@niemyjski Have a look at the last commit, i have used exactly this method :)

@niemyjski niemyjski merged commit f050c39 into exceptionless:master Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants