Skip to content

Commit

Permalink
Merge pull request #59 from openclimatefix/declutter_logging
Browse files Browse the repository at this point in the history
Declutter logging
  • Loading branch information
dfulu authored Mar 26, 2024
2 parents 29a482f + 73d1e28 commit 084e376
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions pvnet_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,29 @@

# ---------------------------------------------------------------------------
# LOGGER

class SQLAlchemyFilter(logging.Filter):

def filter(self, record):
return "sqlalchemy" not in record.pathname

# Create a logger
logger = logging.getLogger()
logger.setLevel(logging.INFO)

formatter = logging.Formatter(
fmt="[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s"
)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)

logging.basicConfig(
level=getattr(logging, os.getenv("LOGLEVEL", "INFO")),
format="[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s",
)

logger = logging.getLogger(__name__)
logger.addHandler(stream_handler)

# Get rid of these verbose logs
# Get rid of the verbose sqlalchemy logs
stream_handler.addFilter(SQLAlchemyFilter())
sql_logger = logging.getLogger("sqlalchemy.engine.Engine")
sql_logger.addHandler(logging.NullHandler())


# ---------------------------------------------------------------------------
# APP MAIN

Expand Down
2 changes: 1 addition & 1 deletion pvnet_app/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def download_all_sat_data():
fs = fsspec.open(sat_download_path).fs
if fs.exists(sat_download_path):
fs.get(sat_download_path, "sat_5_min.zarr.zip")
os.system(f"unzip sat_5_min.zarr.zip -d {sat_5_path}")
os.system(f"unzip -qq sat_5_min.zarr.zip -d {sat_5_path}")

# Also download 15-minute satellite if it exists
sat_15_dl_path = os.environ["SATELLITE_ZARR_PATH"]\
Expand Down

0 comments on commit 084e376

Please sign in to comment.