From 600f61a2cc70d717b1d539132f67787002ae10e7 Mon Sep 17 00:00:00 2001 From: Lars Falk-Petersen Date: Tue, 2 Jan 2024 14:53:30 +0100 Subject: [PATCH] Lazy logging. --- app/initialize.py | 10 +++++----- app/routes/collections_page.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/initialize.py b/app/initialize.py index b768a6f..66f6a29 100644 --- a/app/initialize.py +++ b/app/initialize.py @@ -65,10 +65,10 @@ def open_grib(): dataset = xr.open_dataset(filename, engine="cfgrib") except ValueError as err: logger.error( - "Unable to open file %s. Check installation of modules cfgrib, eccodes.\n%s" - % (filename, err) + "Unable to open file %s. Check installation of modules cfgrib, eccodes.\n%s", + filename, err ) - logger.info("xarray versions:", xr.show_versions()) + logger.info("xarray versions: %s", xr.show_versions()) sys.exit(1) if not validate_grib(dataset): sys.exit(1) @@ -145,10 +145,10 @@ def download_gribfile(data_path: str, api_url: str = API_URL) -> str: ) if os.path.exists(fname): - logger.info(f"Latest file is {fname}, already have that. Skipping download.") + logger.info("Latest file is %s, already have that. Skipping download.", fname) return fname - logger.info(f"Downloading {api_url} to path {fname}") + logger.info("Downloading %s to path %s.", api_url, fname) with open(fname, "wb") as fd: for chunk in response.iter_content(chunk_size=524288): fd.write(chunk) diff --git a/app/routes/collections_page.py b/app/routes/collections_page.py index 1b17098..b85fc37 100644 --- a/app/routes/collections_page.py +++ b/app/routes/collections_page.py @@ -165,7 +165,7 @@ def create_point(coords: str = "") -> dict: logger.error(errmsg) return Response(status_code=status.HTTP_400_BAD_REQUEST, content=errmsg) - logger.info("create_data for coord", point.y, point.x) + logger.info("create_data for coord %s, %s", point.y, point.x) dataset = get_dataset() # Sanity checks on coordinates