Always log to log file
This commit is contained in:
parent
4edf07be15
commit
4dd01bfcd2
1 changed files with 13 additions and 20 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import time
|
||||
import atexit
|
||||
import logging
|
||||
import logging, logging.handlers
|
||||
import os
|
||||
import pkg_resources
|
||||
|
||||
|
|
@ -30,17 +30,10 @@ from openflexure_microscope.api.microscope import default_microscope as api_micr
|
|||
from openflexure_microscope.api.v2 import views
|
||||
|
||||
# Handle logging
|
||||
is_gunicorn = "gunicorn" in os.environ.get("SERVER_SOFTWARE", "")
|
||||
|
||||
DEFAULT_LOGFILE = logs_file_path("openflexure_microscope.log")
|
||||
|
||||
logger = logging.getLogger()
|
||||
if (__name__ == "__main__") or (not is_gunicorn):
|
||||
# If imported, but not by gunicorn
|
||||
print("Letting sys handle logs")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
else:
|
||||
# Direct standard Python logging to file and console
|
||||
|
||||
error_formatter = logging.Formatter(
|
||||
"[%(asctime)s] [%(threadName)s] [%(levelname)s] %(message)s"
|
||||
)
|
||||
|
|
@ -55,7 +48,7 @@ else:
|
|||
handler.setFormatter(error_formatter)
|
||||
logger.addHandler(handler)
|
||||
|
||||
logger.setLevel(logging.getLogger("gunicorn.error").level)
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
|
||||
# Log server paths being used
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue