Skip to content

Commit

Permalink
Support from different logging message per threads/processes
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Dec 5, 2024
1 parent 84b16b0 commit 92f20bf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/anemoi/utils/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
import threading

thread_local = threading.local()
thread_local.logging_name = "main"


LOGGER = logging.getLogger(__name__)


def set_logging_name(logging_name):
thread_local.logging_name = logging_name
def set_logging_name(name):
thread_local.logging_name = name


class ThreadCustomFormatter(logging.Formatter):
Expand All @@ -30,7 +29,8 @@ def format(self, record):
return super().format(record)


def enable_logging_name(logging_name):
def enable_logging_name(name="main"):
thread_local.logging_name = name

formatter = ThreadCustomFormatter("%(asctime)s - %(logging_name)s - %(levelname)s - %(message)s")

Expand Down

0 comments on commit 92f20bf

Please sign in to comment.