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

Slightly better logging experience. #61

Merged
merged 5 commits into from
Jan 20, 2025

Conversation

ghyatzo
Copy link
Contributor

@ghyatzo ghyatzo commented Jan 20, 2025

While testing for the previous PRs, I got a bit annoyed by the repeated spam of the same message at every status update.

This PR changes the logging to print a new message only when the status actually changes, adds a timestamp and a
simple indicator of progress.
An example of complete output is:

┌ Info: 14:32:11 - CDS request                                    
│   dataset = "reanalysis-era5-pressure-levels-monthly-means"     
└   status = "accepted"                                           
┌ Info: 14:32:18 - CDS request
│   dataset = "reanalysis-era5-pressure-levels-monthly-means"     
└   status = "successful"                                         
┌ Info: Downloading
│   source = "https://object-store.os-api.cci2.ecmwf.int:443/cci2-prod-cache/1c5003f9dc140530e360d2824bcca486.grib"
│   dest = "C:\\Users\\User\\Dev\\+Julia\\CDSAPI.jl\\test\\data\\era5.grib"
│   progress = 1.0                                                
│   time_taken = "0.27 s"                                         
│   time_remaining = "0.0 s"                                      
│   average_speed = "7.417 MiB/s"                                 
│   downloaded = "1.980 MiB"                                      
│   remaining = "0 bytes"                                         
└   total = "1.980 MiB"        

While in between updates an example output is:

┌ Info: 14:32:11 - CDS request                                    
│   dataset = "reanalysis-era5-pressure-levels-monthly-means"     
└   status = "accepted"
...... # adds a `.` every wait interval

src/CDSAPI.jl Outdated
@info "CDS request" dataset=name status=data["status"]

if data["status"] != laststatus
print("\e[1K\e[0E") # erase terminal line and reset cursor
Copy link
Member

Choose a reason for hiding this comment

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

Please make sure you are using portable methods to erase the terminal. The REPL module doesn't provide a function for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's portable on most modern terminals, not supported on terminals like windows cmd.exe.
This is kind of a gimmick anyway. So it's probably better to just remove it.

Project.toml Outdated Show resolved Hide resolved
@juliohm juliohm merged commit 57d98c9 into JuliaClimate:master Jan 20, 2025
0 of 6 checks passed
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