Skip to content

Conversation

@finnetrolle
Copy link
Contributor

Investigating #985 task I've created solution. I'm not sure this solution is good, but I tried to explain my thoughts and solution inside code. Also, I copy explanation here.
Also I'm not sure it's a good idea to create log files during test run. But I don't really know how to remove them after tests...

This constructor can be used to create just one logger. In this way nothing will change.
Example = Logger.JavaLogger().appendToFile("logs/first.log")

But if this constructor is used several times in different places with different files we will have bad situation
We call constructor and that means for client that we created new instance, that will write logs to given file
But in fact we created only wrapper. Our worker class java.util.logging.Logger instance will be same for all
JavaLoggers because or getLogger() method logic. And each time we create and apply file to logger -
we apply file handler to same logger.

Correct way to change this - is to ask client for unique logger name to give loggerManager change to differ files
But some users already using this method for single call without any class name. So, I decided to make workaround

I'll create logger with Logger.class name for first instance.
But each other calls of constructor will check if someone already created first logger. If so - I'll create
logger with name Logger.class[1-..]. We will have Logger, Logger1, Logger2, etc. This looks not very good, but
provides backward compatibility. But I mark this constructor as Deprecated and recommend other constructor with
the name to provide inner logger for.

@kdavisk6
Copy link
Member

@finnetrolle

I think you may gone a little too far in this change. I agree with deprecating the default constructor, but by attempting to provide an internal workaround, you are adding complexity that we don't need. I think that by simply marking the default constructor as deprecated and add the new constructor will suffice.

We will remove the default constructor in Feign 11.

Copy link
Member

@kdavisk6 kdavisk6 left a comment

Choose a reason for hiding this comment

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

See my comments

@kdavisk6 kdavisk6 added the feedback provided Feedback has been provided to the author label Aug 24, 2019
@finnetrolle
Copy link
Contributor Author

@kdavisk6 I absolutely agree with you about workaround. But I decided that it's better to make proposal and this is the best I can provide to keep default constructor and change its logic. I'll fix it now

@kdavisk6
Copy link
Member

I understand and appreciate the effort. We can add additional documentation to let user's know of the limitation and our suggested workaround.

@finnetrolle
Copy link
Contributor Author

@kdavisk6 I'm going to change javadoc for deprecated method to warn users

@velo
Copy link
Member

velo commented Aug 26, 2019 via email

@finnetrolle
Copy link
Contributor Author

Done =)

@kdavisk6 kdavisk6 added the ready to merge Will be merged if no other member ask for changes label Aug 26, 2019
@kdavisk6 kdavisk6 merged commit 976e2c1 into OpenFeign:master Aug 30, 2019
@finnetrolle finnetrolle deleted the #985 branch September 3, 2019 22:01
velo pushed a commit that referenced this pull request Oct 7, 2024
Fixes #985 

* JavaLogger(String name) added. Workaround for JavaLogger() provided
* JavaLogger() marked as deprecated. Workaround for JavaLogger() removed
* Little fix for note in README
* One more little fix for note in README
* JavaLogger(Class<?>) constructor added
velo pushed a commit that referenced this pull request Oct 8, 2024
Fixes #985 

* JavaLogger(String name) added. Workaround for JavaLogger() provided
* JavaLogger() marked as deprecated. Workaround for JavaLogger() removed
* Little fix for note in README
* One more little fix for note in README
* JavaLogger(Class<?>) constructor added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feedback provided Feedback has been provided to the author ready to merge Will be merged if no other member ask for changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants