Commit 4dd01bfc authored by Joel Collins's avatar Joel Collins
Browse files

Always log to log file

parent 4edf07be
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -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