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

Configurable server log file. #79

Merged
merged 3 commits into from
Oct 22, 2016
Merged

Configurable server log file. #79

merged 3 commits into from
Oct 22, 2016

Conversation

tweekmonster
Copy link
Collaborator

Closes #74

@tweekmonster tweekmonster changed the title [WIP] Configurable server log file. Configurable server log file. Oct 20, 2016
@tweekmonster
Copy link
Collaborator Author

@blueyed Could you give this a try?

@zchee
Copy link
Member

zchee commented Oct 20, 2016

@tweekmonster SGTM, not test yet.

)
'deoplete#sources#jedi#show_docstring', False)
self.debug_server = vars.get(
'deoplete#sources#jedi#debug_server', False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about using True here?
It is only used when generic debug is enabled, and then the server should be included probably by default?

I could imagine that g:deoplete#sources#jedi#debug_server = 1 also enables generic debugging explicitly though - so we would have 3 states here..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, yeah probably should be on by default.

I could imagine that g:deoplete#sources#jedi#debug_server = 1 also enables generic debugging explicitly though - so we would have 3 states here..

Could you elaborate?

Copy link
Collaborator

Choose a reason for hiding this comment

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

With only g:deoplete#sources#jedi#debug_server = 1 debugging should be enabled already - assuming an implicit call to call deoplete#custom#set('jedi', 'debug_enabled', 1).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That makes sense. This is with the understanding that deoplete#enable_logging() must be called first, right?

for handler in root_log.handlers:
if isinstance(handler, logging.FileHandler):
log_file = getattr(handler, 'baseFilename', None)
break
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we filter this for the deoplete handler right away?
What happens if no FileHandler is found - in this case the fallback should be logging.FileHandler('/tmp/jedi-server.log') probably still?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you mean by "right away"? And, if debug_enabled is True, the FileHandler should always be found. I could see the placement being a problem if enabling debug at runtime, though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you mean by "right away"?

Only consider the "deoplete" root logger.

I could see the placement being a problem if enabling debug at runtime, though.

Yeah, we should consider a feature in the future to change this during runtime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Still not following about "Only consider the "deoplete" root logger." Unless I'm misunderstanding, that's what already is happening since the root logger is the only one that has handlers.

TBH, I would rather not scan the handlers and update Deoplete to pass the log location to the source instances, but that requires a third-party change and backward compatibility code (scanning handlers).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Still not following about "Only consider the "deoplete" root logger."

I've thought that it might be possible to only look at the deoplete root handler right away.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As in root_logger.handlers[0]?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, but in a less hard-coded way.. not sure though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, sorry about that. I thought maybe you meant "directly" in the context of class instantiation, or maybe import deoplete.logger.

The reason for scanning is because the only assumption I want to make about Deoplete's logger is that it's named 'deoplete'. I don't want deoplete-jedi to break because logging changed in Deoplete (even though it's not likely). It'll probably be better if the deoplete.logger module had a file_handler variable, but that would require changing Deoplete.

I've noticed more than a few issues in Deoplete where the problem was that Deoplete was out of date or a source was. Not sure how people are updating one and not the other, but I prefer to use the method that's less likely to cause an error.

@blueyed
Copy link
Collaborator

blueyed commented Oct 20, 2016

As for the overall PR: I've tried it and it works good already. I've left the comments above afterwards.

@tweekmonster
Copy link
Collaborator Author

@blueyed Updated. I'm going out to dinner. If you feel the update is good enough, you can squash+merge.

@tweekmonster
Copy link
Collaborator Author

I think this is good to go. Merging.

@tweekmonster tweekmonster merged commit 4b4f684 into master Oct 22, 2016
@zchee zchee deleted the server-log branch October 25, 2016 06:22
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.

None yet

3 participants