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: add verbosity option and improve log #156

Merged
merged 18 commits into from
Sep 23, 2022
Merged

Conversation

Guts
Copy link
Collaborator

@Guts Guts commented Sep 22, 2022

ℹ️ this PR supersedes the #155

Context

Recently, we faced an issue with the log length using qgis-plugin-ci on GitLab CI/CD:

Job's log exceeded limit of 4194304 bytes.
Job execution will continue but no more output will be collected.

See this job: https://gitlab.com/Oslandia/qgis/ign-geotuileur/-/jobs/3056269109

But I've been thinking for a long time that we should reduce the amount of information returned to the terminal or let the end-user pick.

Proposed 'log policy'

Meant to be added to contributing guidelines.

  • print to systematically display information to the CLI end-user and which doesn't require some log filter or format. And mark the statement with # noqa: T2 to avoid flake8 alerts. Example: Plugin archive created: qtribu.0.15.0-beta2.zip (Size: 731.37 Ko)

  • logger.error for blocking issues or interrupted process. If the case is predictable and predicted, do not raise brutal exception to avoid hard readable trace in terminal. Example:

    logger.error(err_msg, exc_info=UncommitedChanges())
    sys.exit(1)
    2022-09-22 14:47:25||ERROR||release||You have uncommitted changes. Stash or commit them or use -c / --allow-uncommitted-changes option.
    qgispluginci.exceptions.UncommitedChanges
  • logger.warning for annoying or imperfect but not blocking situations . Example: 2022-09-22 14:45:01||WARNING||parameters||Homepage is not given in the metadata. It is a mandatory information to publish the plugin on the QGIS official repository.

  • logger.info for normal message during the process.

  • logger.debug for detailed message during specific steps. example: list of zipped files, etc.

Changes

STILL IN PROGRESS

  • add a verbosity option -v with an incremental count

    # by default, log nothing except print statement = WARNING
    qgis-plugin-ci package latest
    # -v = INFO
    qgis-plugin-ci -v package latest
    # -vv = DEBUG
    qgis-plugin-ci -vv package latest
  • add a setting into the setup.cfg to customize log format. Default: %(asctime)s||%(levelname)s||%(module)s||%(message)s - OPTION STILL NOT IMPLEMENTED

  • remove option alias -v from the version option to avoid conflict

  • improve some exception handling: mainly add Trace: {exc} and use f-string instead of format as recommended

  • add some volontary print statements (typically to conclude each successful command)

  • add flake8-print as development requirement to enforce the lg policy. Use # noqa: T2 for relevant print statements

@Guts Guts added the enhancement New feature or request label Sep 22, 2022
@Guts Guts self-assigned this Sep 22, 2022
@Guts Guts marked this pull request as ready for review September 22, 2022 18:25
@Guts Guts merged commit df71e5e into master Sep 23, 2022
@Guts Guts deleted the feature/verbosity-option branch September 23, 2022 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants