Add logging util
This commit is contained in:
parent
cd2ad332e4
commit
691fdecff8
2 changed files with 21 additions and 0 deletions
|
|
@ -3,3 +3,4 @@ from .compute_histogram import compute_histogram
|
|||
from .generate_rotation_matrices import generate_rotation_matrices
|
||||
from .get_next_run_name import get_next_run_name
|
||||
from .kldiv import kldiv
|
||||
from .set_up_logging import set_up_logging
|
||||
|
|
|
|||
20
src/editor/utils/set_up_logging.py
Normal file
20
src/editor/utils/set_up_logging.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import logging
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def set_up_logging(logs_path: Optional[str] = None):
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s - %(levelname)s - %(message)s",
|
||||
handlers=[
|
||||
logging.StreamHandler(),
|
||||
(
|
||||
logging.FileHandler(
|
||||
logs_path / f"{datetime.now().isoformat(timespec='minutes')}.log"
|
||||
)
|
||||
if logs_path
|
||||
else logging.NullHandler()
|
||||
),
|
||||
],
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue