Configure logging for the OpenFlexure Server.
A module containing a custom logging handler and helper function for the OpenFlexure server. These handle formatting logs, ensuring that logs are logged both to a file and to the terminal (see note below!). Functionality is also provided for retrieving logs for to send over HTTP.
Note that when running in production OpenFlexure Microscope the server is run via systemd. As such, the logs that are sent to the terminal (STDERR) or any other output to STDOUT/STDERR are captured by systemd. These can be viewed by using journalctl or the ofm journal command.
| Class | |
A logging.Handler that stores the most recent logs for access by the server. |
| Class | |
A logging filter to filter out "uvicorn.access" messages. |
| Function | configure |
Configure logging for the server while it is running. |
| Function | retrieve |
Return logs since the server started, up to a maximum of 250 messages. |
| Function | retrieve |
Return the full log from the file for downloading. |
| Constant | OFM |
Undocumented |
| Constant | OFM |
Undocumented |
Configure logging for the server while it is running.
This modifies the root logger to have a rotating file handler and adds a custom handler that prints and stores all records except uvicorn.access logs.
It is important not to let Uvicorn override these settings.
Return logs since the server started, up to a maximum of 250 messages.
This log is the one shown in the UI and on the logging page.
It does not include any of the uvicorn.access logs as these are emitted every time any API route is called.
All logs, including uvicorn.access are logged to the OFM_LOG_FILE (see above) this is the best place to get logs about crashes.