Skip to content

Commit

Permalink
Reduce logging
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdijk committed Oct 3, 2024
1 parent 15efb90 commit f3df40f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
28 changes: 19 additions & 9 deletions narrowcast_content/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from logging import Formatter, FileHandler
from logging.config import dictConfig
from pathlib import Path

from flask import Flask, request, abort, session
Expand All @@ -18,13 +17,24 @@

cache.init_app(app)

if not app.debug:
file_handler = FileHandler('error.log')
file_handler.setFormatter(Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
app.logger.setLevel(logging.INFO)
file_handler.setLevel(logging.INFO)
app.logger.addHandler(file_handler)
app.logger.info('errors')
dictConfig(
{
"version": 1,
"formatters": {
"default": {
"format": "[%(asctime)s] %(levelname)s in %(module)s: %(message)s",
}
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout",
"formatter": "default",
}
},
"root": {"level": "WARN", "handlers": ["console"]},
}
)

# Add all the blueprints
app.register_blueprint(buienradar_graph)
Expand Down
3 changes: 1 addition & 2 deletions narrowcast_content/waitress_server.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from waitress import serve
from . import app
from paste.translogger import TransLogger

serve(TransLogger(app, setup_console_handler=False),
serve(app,
host='0.0.0.0',
port=8080,
connection_limit=500,
Expand Down

0 comments on commit f3df40f

Please sign in to comment.