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

Verbose logging more convenient #359

Merged
merged 1 commit into from
Dec 11, 2023
Merged

Verbose logging more convenient #359

merged 1 commit into from
Dec 11, 2023

Conversation

jpswinski
Copy link
Member

@jpswinski jpswinski commented Dec 11, 2023

This PR simplifies the user experience for getting basic messages logged to the console when calling SlideRule APIs.

Previously

  • Each SlideRule Python client module had it's own logger (except for a few which used the global logger)
  • The init function's verbose setting enabled/disabled the logging of messages received from the server
  • The init function's loglevel setting changed the logging level for the sliderule module's logger
  • It was on the user to create a log handler either manually or by using logging.basicConfig

This design gives the user full control - they can create individual handlers for the log messages generated in each of the submodules of the SlideRule Python client, and manage exactly how they are displayed. It also separates out the log messages coming from the server (which typically are a lot), from the log messages generated by the client (which typically are a few).

But in the vast majority of the cases, a user either wants to see messages printed to their screen, or they don't want to see anything. And the verbose option intuitively should control this.

Changes in this PR

  • The SlideRule Python client uses a single logger created in the core module
  • Server log messages are always logged at the level they are generated at
  • The init function's verbose setting will automatically create a console logger which will display all log messages of a sufficient log level to the screen
  • The init function's loglevel setting will always change the global log level, and when a console logger is created (i.e. when verbose is set to True), then it will change the console logger's log level as well.
  • If the user wants control over how the logger is created, they can always set verbose to False (which is the default), and create their own log handler and attach it to sliderule.logger

Copy link
Member

@dshean dshean left a comment

Choose a reason for hiding this comment

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

Wow! Looks great. I think this will work well, and we can tweak if necessary.
One suggestion - we might add something to doc adding some notes on what each log level will report for SlideRule.
For larger areas (that could take >30-60 sec to complete), it's good to see some message(s) immediately after the call, so the user knows things are running.
Most of the time, for production runs, I like seeing a report on the number of granules, and some kind of progress (n of m granules processed). For testing, good to see the warnings/errors (e.g., when raster sampling failed due to missing tile or something).

@jpswinski jpswinski merged commit 3f19701 into main Dec 11, 2023
5 checks passed
@jpswinski jpswinski deleted the logger branch December 11, 2023 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants