Enhance logging.

This commit is contained in:
Stephan Porada 2019-09-12 11:35:23 +02:00
parent 129ee05b51
commit 926935af56
3 changed files with 9 additions and 5 deletions

View File

@ -17,10 +17,8 @@ As a last step texts can be loaded into an information retrieval system to query
## Setup
0. **Create log files**
``` basj
``` bash
mkdir /logs
touch /logs/opaque_flask.log
touch /logs/opaque_daemon.log
```

View File

@ -36,11 +36,17 @@ class DevelopmentConfig(Config):
os.environ.get('POSTGRES_PASSWORD'),
os.environ.get('POSTGRES_DB_NAME')
)
if not os.path.isfile('logs/opaque_web.log'):
file_path = os.path.join(os.getcwd(), 'logs/opaque_web.log')
log = open(file_path, 'w+')
log.close()
log_format = ("%(asctime)s - %(levelname)s - %(name)s - "
"%(filename)s - %(lineno)d - %(message)s")
logging.basicConfig(filename='logs/opaque_flask.log', level='WARNING',
logging.basicConfig(filename='logs/opaque_web.log', level='WARNING',
format=log_format, datefmt='%Y-%m-%d %H:%M:%S',
filemode='w')
logger = logging.getLogger(__name__)
logger.info('Logging has started.')
class TestingConfig(Config):

View File

@ -19,7 +19,7 @@ services:
- /mnt/opaque:/mnt/opaque
- ./app:/home/opaque/app
- ./config.py:/home/opaque/config.py
- ./logs/opaque_flask.log:/home/opaque/logs/opaque_flask.log
- ./logs:/home/opaque/logs
- ./migrations:/home/opaque/migrations
- ./opaque.py:/home/opaque/opaque.py
daemon: