Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions rfc5424logging/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from logging import Handler

from pytz import utc
from tzlocal import get_localzone

from rfc5424logging import transport

Expand Down Expand Up @@ -218,6 +217,9 @@ def __init__(
self.stream = stream
self.transport = None

from tzlocal import get_localzone
self._local_zone = get_localzone()

if not (isinstance(self.facility, int) and LOG_KERN <= self.facility <= LOG_LOCAL7):
raise ValueError("Facility is not valid")

Expand Down Expand Up @@ -366,7 +368,7 @@ def build_msg(self, record):
# HEADER
pri = '<%d>' % self.encode_priority(self.facility, record.levelname)
version = SYSLOG_VERSION
timestamp = datetime.fromtimestamp(record.created, get_localzone())
timestamp = datetime.fromtimestamp(record.created, self._local_zone)
if self.utc_timestamp:
timestamp = timestamp.astimezone(utc)
timestamp = timestamp.isoformat()
Expand Down