Skip to content

Commit

Permalink
Expose hostname in logging (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 authored May 2, 2023
1 parent 2f9db1a commit 6e652ee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions karton/core/logger.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import logging
import platform
import traceback
import warnings
from typing import Optional

from .backend import KartonBackend
from .task import Task

HOSTNAME = platform.node()


class KartonLogHandler(logging.Handler):
"""
Expand Down Expand Up @@ -54,6 +57,8 @@ def emit(self, record: logging.LogRecord) -> None:
if self.task is not None:
log_line["task"] = self.task.serialize()

log_line["hostname"] = HOSTNAME

log_consumed = self.backend.produce_log(
log_line, logger_name=self.channel, level=record.levelname
)
Expand Down

0 comments on commit 6e652ee

Please sign in to comment.