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

Feature/remove unnecessary string handling in logging #1103

Conversation

fredrikhaglund
Copy link
Contributor

@fredrikhaglund fredrikhaglund commented Jun 27, 2017

Please take a moment to fill out the following:

Fixes issue #1089.

Changes proposed in this pull request:

  • Use EmptyLogger as default in Release mode
  • Add #define DEBUG to DebugLogger classto make it work in nuget release

The DebugLogging class does not do anything useful unless compiled using DEBUG mode. Nuget packages are compiled in release mode which only leaves the string formating code without doing anything with the result and if a developer try to use this class from their application code it will be confusing and misleading since it actually does not log anything.
Nuget packages are compiled in release mode so the DebugLogger will not work. Use EmptyLogger as default if not compiling in debug mode.
Nuget packages are compiled in release mode so the DebugLogger will not work. Use EmptyLogger as default if not compiling in debug mode.
@dnfclas
Copy link

dnfclas commented Jun 27, 2017

@fredrikhaglund,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by .NET Foundation. We will now review your pull request.
Thanks,
.NET Foundation Pull Request Bot

@@ -5,6 +5,7 @@

namespace Prism.Logging
{
#if DEBUG
Copy link
Member

Choose a reason for hiding this comment

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

Remove this check. This will break anyone using this class as Prism is not released in Debug mode, so this class will now be missing from the assembly.

@fredrikhaglund
Copy link
Contributor Author

You are aware that this class does not work at all unless compiled in debug mode? Debug.WriteLine is removed by the compiler when compiled in release mode.

My whole point is that I used this class in my project and wasted time figuring out why nothing was logged.

Another option that does not introduce a breaking change by removing the class would be to add an obsolete attribute with a warning when compiled in release mode. Better?

@brianlagunas
Copy link
Member

I've thought about this a little bit and probably the best approach would be to use #define DEBUG in the logger so it will work. This means we could remove all the other #if checks

@brianlagunas
Copy link
Member

Let me think about this a little more. Maybe we should remove the DebugLogger. I did it to make my life easier for developing, but it provides no value to anyone using the class outside of debugging the source code.

@dansiegel
Copy link
Member

I think perhaps the better idea would be to add the DebugLogger to the project templates. This would solve a few problems for developers...

@brianlagunas
Copy link
Member

That's actually not a bad idea.

The DebugLogging class does not do anything useful unless compiled using DEBUG mode. Nuget packages are compiled in release mode which only leaves the string formating code without doing anything with the result and if a developer try to use this class from their application code it will be confusing and misleading since it actually does not log anything.
@fredrikhaglund
Copy link
Contributor Author

I added #define DEBUG and removed conditional compilation to DebugLogger class.

Removing the class or hiding it with a conditional compile would be a breaking change so this is better.

@brianlagunas
Copy link
Member

With the DEBUG defined, there should be no need to have the conditional EmptyLogger now right?

@fredrikhaglund
Copy link
Contributor Author

Changing so the default is always the EmptyLogger and updating unit test to use DebugLogger?

Leaving the DebugLogger as default will cause unneeded string handling and debug logging in release builds of Apps. Not a big deal but everything that can help improve performance in mobile apps is welcome...

@dansiegel
Copy link
Member

As I recall System.Diagnostics.Debug is useless in unit tests. I believe the best thing is to remove the DebugLogger altogether. If we want output from the unit tests then we want to use ITestOutputHelper.

@brianlagunas brianlagunas merged commit 4441c1e into PrismLibrary:master Jul 7, 2017
@brianlagunas
Copy link
Member

Thanks for the PR

@brianlagunas brianlagunas added this to the Prism 7.0 milestone Jul 7, 2017
@lock
Copy link

lock bot commented Jan 28, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants