Skip to content

Commit b002b5d

Browse files
committed
Allow enterprise ID to contain sub-identifiers
1 parent 201ac5b commit b002b5d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

rfc5424logging/handler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,10 @@ def __init__(
165165
structured_data (dict):
166166
A dictionary with structured data that is added to every message. Per message your
167167
can add more structured data by adding it to the ``extra`` argument of the log function.
168-
enterprise_id (int):
168+
enterprise_id (str):
169169
The Private Enterprise Number. This is used to compose the structured data IDs when
170-
they do not include an Enterprise ID and are not one of the reserved structured data IDs
170+
they do not include an Enterprise ID and are not one of the reserved structured data IDs.
171+
Can be a single PEN like ``32473`` or optionally contain sub-identifiers like ``32473.2.6``
171172
utc_timestamp (bool):
172173
Whether the timestamp should be converted to UTC time or kept in the local timezone
173174
timeout (int):

tests/test_structured_data.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@
129129
b'<14>1 2000-01-01T17:11:11.111111+06:00 testhostname root 111'
130130
b' - [timeQuality isSynced="1"]'
131131
b' \xef\xbb\xbfThis is an interesting message'
132+
), ( # 22
133+
{'address': address, 'enterprise_id': "32473.1.2"},
134+
{'extra': {'structured_data': sd1_no_pen}},
135+
b'<14>1 2000-01-01T17:11:11.111111+06:00 testhostname root 111'
136+
b' - [my_sd_id1@32473.1.2 my_key1="my_value1"] \xef\xbb\xbfThis is an interesting message'
132137
),
133138
])
134139
def test_sd(logger, handler_kwargs, logger_kwargs, expected):

0 commit comments

Comments
 (0)