logging rotation and in pgroup
This commit is contained in:
@ -1,11 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
from time import sleep
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
# at the moment this allows us to group the subdirectories as modules easily
|
||||
# TODO: a more general way would be to have this cristallina as a installed package
|
||||
@ -14,7 +9,6 @@ os.chdir("/sf/cristallina/applications/slic/cristallina")
|
||||
# setup logging
|
||||
from loguru import logger
|
||||
|
||||
|
||||
def setup_logging():
|
||||
logger.remove()
|
||||
logger.add(
|
||||
@ -25,24 +19,36 @@ def setup_logging():
|
||||
logger.info("Loading started.")
|
||||
|
||||
# create file handler which logs
|
||||
# TODO: better directory for log files? should not be pgroup specific so that this always works
|
||||
# TODO: better directory for general log files?
|
||||
try:
|
||||
logger.add(
|
||||
"/sf/cristallina/applications/slic/cristallina/log/cristallina.log",
|
||||
format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}",
|
||||
level="DEBUG",
|
||||
rotation="1 week",
|
||||
)
|
||||
except PermissionError as e:
|
||||
logger.warning("Cannot write log file.")
|
||||
logger.warning(e)
|
||||
|
||||
def setup_logging_pgroup(pgroup, level="INFO"):
|
||||
try:
|
||||
logger.add(
|
||||
f"/sf/cristallina/data/{pgroup}/scratch/slic.log",
|
||||
format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}",
|
||||
level=level,
|
||||
rotation="1 week",
|
||||
)
|
||||
except PermissionError as e:
|
||||
logger.warning(f"Cannot write log file to pgroup {pgroup}.")
|
||||
|
||||
|
||||
# We setup the logging before going further so that
|
||||
# other modules can write startup messages into the log file.
|
||||
setup_logging()
|
||||
|
||||
# TODO: this is later overwritten, probably not intended that way?
|
||||
from epics import PV
|
||||
# from epics import PV
|
||||
|
||||
from devices.alignment_laser import AlignmentLaser
|
||||
from slic.gui import GUI
|
||||
@ -85,7 +91,7 @@ try:
|
||||
logger.info("Connected to stand server")
|
||||
except Exception as error:
|
||||
# catching with a broad net because different connection errors can occur.
|
||||
logger.warning(f"Cannot connect to stand server on {stand_host}. Caught {error}.")
|
||||
logger.warning(f"Cannot connect to stand server on {stand_host}.")
|
||||
|
||||
# spreadsheet = Spreadsheet(adjs, placeholders=PLACEHOLDERS, host="127.0.0.1", port=8080))
|
||||
|
||||
@ -204,6 +210,9 @@ instrument = "cristallina"
|
||||
# pgroup = "p21528" # Cr-MX Colletier 2023-09-05
|
||||
pgroup = "p21516" # Beamline commissioning September 26-27, 2023
|
||||
|
||||
# setup pgroup specific logger
|
||||
setup_logging_pgroup(pgroup)
|
||||
|
||||
daq = SFAcquisition(
|
||||
instrument,
|
||||
pgroup,
|
||||
|
Reference in New Issue
Block a user