Skip to content

Commit

Permalink
simplify logging
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Oct 20, 2024
1 parent 1d9807a commit f98fd71
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 f98fd71

Please sign in to comment.