Update logging
This commit is contained in:
21
src/app.py
21
src/app.py
@@ -2,6 +2,24 @@ from flask import Flask, request
|
|||||||
from reconnect import reboot
|
from reconnect import reboot
|
||||||
from os import environ
|
from os import environ
|
||||||
from subprocess import call, DEVNULL, STDOUT
|
from subprocess import call, DEVNULL, STDOUT
|
||||||
|
from logging.config import dictConfig
|
||||||
|
|
||||||
|
dictConfig({
|
||||||
|
'version': 1,
|
||||||
|
'formatters': {'default': {
|
||||||
|
'format': '[%(asctime)s] %(levelname)s in %(module)s: %(message)s',
|
||||||
|
}},
|
||||||
|
'handlers': {'wsgi': {
|
||||||
|
'class': 'logging.StreamHandler',
|
||||||
|
'stream': 'ext://flask.logging.wsgi_errors_stream',
|
||||||
|
'formatter': 'default'
|
||||||
|
}},
|
||||||
|
'root': {
|
||||||
|
'level': 'INFO',
|
||||||
|
'handlers': ['wsgi']
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@@ -38,9 +56,10 @@ def safe():
|
|||||||
if call(['nslookup', website], stdout=DEVNULL, stderr=STDOUT) == 0:
|
if call(['nslookup', website], stdout=DEVNULL, stderr=STDOUT) == 0:
|
||||||
app.logger.info(f'Successfully resolved {website}')
|
app.logger.info(f'Successfully resolved {website}')
|
||||||
success += 1
|
success += 1
|
||||||
|
else:
|
||||||
|
app.logger.error(f'Unable to resolve {website}')
|
||||||
|
|
||||||
if success > 3:
|
if success > 3:
|
||||||
app.logger.error('Websites resolved successfully')
|
|
||||||
return 'Error: DNS seems to be working, debug manually!'
|
return 'Error: DNS seems to be working, debug manually!'
|
||||||
|
|
||||||
# Reboot router
|
# Reboot router
|
||||||
|
Reference in New Issue
Block a user