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

Rework logging system and in-app log view #834

Merged
merged 4 commits into from Feb 10, 2018
Merged

Conversation

zas
Copy link
Collaborator

@zas zas commented Feb 9, 2018

  • use standard logging module as backend

  • implement a circular buffer handler for in-app log view

  • use default logging levels

  • debug mode is now tied to verbosity

  • default log format changed, adding source/lineno infos and milliseconds precision

  • history log changed to logging/circular buffer handler too

  • log view was changed accordingly

  • Save As button added

  • Clear Log (only the in-memory buffer and the view) button added, with confirmation dialog

  • Highlight text and button added

  • Verbosity toggling menu added

  • Debug mode check box removed (replaced by verbosity = Debug)

Replace #830


def set_verbosity(self, level):
self.actions[level].setChecked(True)


class LogView(LogViewCommon):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I get this warning from Qt - QLayout: Attempting to add QLayout "" to LogView "", which already has a layout
should it matter?

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's a parenting conflict, when you set explicitly a parent and Qt think different.
Too much parenting kills parenting ;)
Try to see if it is better with 5699bb1

self.hbox.addWidget(self.save_log_as_button)
self.save_log_as_button.clicked.connect(self._save_log_as_do)

# ------
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do we need this?

No, removed in 5699bb1

- use standard logging module as backend
- implement a circular buffer handler for in-app log view
- use default logging levels
- debug mode is now tied to verbosity
- default log format changed, adding source/lineno infos and milliseconds precision
- history log changed to logging/circular buffer handler too

- log view was changed accordingly
- Save As button added
- Clear Log (only the in-memory buffer and the view) button added, with confirmation dialog
- Highlight text and button added
- Verbosity toggling menu added
- Debug mode check box removed (replaced by verbosity = Debug)
- if user set verbosity to debug in log view, keep this setting on next start
- if -d is passed on command line, set verbosity to debug only until exit, but if the user switches it in log view
- set default log level to warning
- save verbosity to config option "log_verbosity"
QLayout: Attempting to add QLayout "" to LogView "", which already has a layout
@zas zas merged commit 8242c18 into metabrainz:master Feb 10, 2018
@zas zas deleted the log_logging branch February 10, 2018 16:51

# copied from https://github.com/python/cpython/blob/3.5/Lib/logging/__init__.py#L1353-L1381
# see https://stackoverflow.com/questions/4957858/how-to-write-own-logging-methods-for-own-logging-levels
def findCaller(self, stack_info=False):
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I'm missing something, but why do we need our own copy of this method? Replacing this whole class with

class OurLogger(logging.getLoggerClass()):
    pass

appears to result in exactly the same log messages.

Also, technically, there's a license declaration at the top of logging.py in cpython that this copy here appears to violate (but I am not a lawyer).

Copy link
Collaborator Author

@zas zas Feb 12, 2018

Choose a reason for hiding this comment

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

It is needed, because of https://github.com/metabrainz/picard/pull/834/files#diff-5e8bcd94ca229f5652e0efe229fcfab7R105 which is using _srcfile

Just subclassing will not work in all cases, because of this. I wish there was another way, but i couldn't find one, findCaller() is just badly designed and doesn't play well with our wrapped calls.

About the license, i guess you're right, it should appear somewhere. Copying just above this block and in https://github.com/metabrainz/picard/blob/master/AUTHORS.txt should be ok, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

#839 removes the useless code ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants