Skip to content

Commit

Permalink
Merge pull request #147 from openclimatefix/simplify-logging
Browse files Browse the repository at this point in the history
simplify logging
  • Loading branch information
peterdudfield authored Oct 20, 2024
2 parents 1d9807a + f98fd71 commit a67551a
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions pvnet_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,14 @@ def filter(self, record):


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

formatter = logging.Formatter(
fmt="[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s"
logging.basicConfig(
level=getattr(logging, os.getenv("LOGLEVEL", "DEBUG")),
format="[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s",
)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)
logger.addHandler(stream_handler)
logger = logging.getLogger()

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


# ---------------------------------------------------------------------------
Expand Down

0 comments on commit a67551a

Please sign in to comment.