Skip to content

Commit

Permalink
Include hostname in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
viklofg committed May 7, 2024
1 parent a873b80 commit a943f51
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/htrflow_core/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import socket
from pathlib import Path
from typing import List

Expand All @@ -18,7 +19,10 @@
def setup_pipeline_logging(logfile: str, loglevel: str):
logging.getLogger("transformers").setLevel(logging.ERROR)
time_format = "%Y-%m-%d %H:%M:%S"
formatter = logging.Formatter(fmt="%(asctime)s - %(levelname)s - %(message)s", datefmt=time_format)
formatter = logging.Formatter(
fmt="{hostname} - %(asctime)s - %(levelname)s - %(message)s".format(hostname=socket.gethostname()),
datefmt=time_format,
)
logger = logging.getLogger()
logger.setLevel(loglevel.upper())
handler = logging.FileHandler(logfile, mode="w") if logfile else logging.StreamHandler()
Expand Down

0 comments on commit a943f51

Please sign in to comment.