ominfra 0.0.0.dev117__py3-none-any.whl → 0.0.0.dev119__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -354,7 +354,7 @@ class StandardLogFormatter(logging.Formatter):
354
354
  if datefmt:
355
355
  return ct.strftime(datefmt) # noqa
356
356
  else:
357
- t = ct.strftime("%Y-%m-%d %H:%M:%S") # noqa
357
+ t = ct.strftime('%Y-%m-%d %H:%M:%S')
358
358
  return '%s.%03d' % (t, record.msecs)
359
359
 
360
360
 
@@ -491,6 +491,7 @@ def configure_standard_logging(
491
491
  json: bool = False,
492
492
  target: ta.Optional[logging.Logger] = None,
493
493
  force: bool = False,
494
+ handler_factory: ta.Optional[ta.Callable[[], logging.Handler]] = None,
494
495
  ) -> ta.Optional[StandardLogHandler]:
495
496
  with _locking_logging_module_lock():
496
497
  if target is None:
@@ -504,7 +505,10 @@ def configure_standard_logging(
504
505
 
505
506
  #
506
507
 
507
- handler = logging.StreamHandler()
508
+ if handler_factory is not None:
509
+ handler = handler_factory()
510
+ else:
511
+ handler = logging.StreamHandler()
508
512
 
509
513
  #
510
514
 
@@ -392,7 +392,7 @@ class StandardLogFormatter(logging.Formatter):
392
392
  if datefmt:
393
393
  return ct.strftime(datefmt) # noqa
394
394
  else:
395
- t = ct.strftime("%Y-%m-%d %H:%M:%S") # noqa
395
+ t = ct.strftime('%Y-%m-%d %H:%M:%S')
396
396
  return '%s.%03d' % (t, record.msecs)
397
397
 
398
398
 
@@ -529,6 +529,7 @@ def configure_standard_logging(
529
529
  json: bool = False,
530
530
  target: ta.Optional[logging.Logger] = None,
531
531
  force: bool = False,
532
+ handler_factory: ta.Optional[ta.Callable[[], logging.Handler]] = None,
532
533
  ) -> ta.Optional[StandardLogHandler]:
533
534
  with _locking_logging_module_lock():
534
535
  if target is None:
@@ -542,7 +543,10 @@ def configure_standard_logging(
542
543
 
543
544
  #
544
545
 
545
- handler = logging.StreamHandler()
546
+ if handler_factory is not None:
547
+ handler = handler_factory()
548
+ else:
549
+ handler = logging.StreamHandler()
546
550
 
547
551
  #
548
552
 
@@ -0,0 +1,187 @@
1
+ """
2
+ https://www.freedesktop.org/software/systemd/man/latest/systemd.journal-fields.html
3
+ https://man.archlinux.org/man/systemd.journal-fields.7.en
4
+
5
+ ==
6
+
7
+ USER JOURNAL FIELDS
8
+ User fields are fields that are directly passed from clients and stored in the journal.
9
+
10
+ MESSAGE=
11
+ The human-readable message string for this entry. This is supposed to be the primary text shown to the user. It is
12
+ usually not translated (but might be in some cases), and is not supposed to be parsed for metadata. In order to
13
+ encode multiple lines in a single log entry, separate them by newline characters (ASCII code 10), but encode them as
14
+ a single MESSAGE= field. Do not add multiple values of this field type to the same entry (also see above), as
15
+ consuming applications generally do not expect this and are unlikely to show all values in that case.
16
+ MESSAGE_ID=
17
+ A 128-bit message identifier ID for recognizing certain message types, if this is desirable. This should contain a
18
+ 128-bit ID formatted as a lower-case hexadecimal string, without any separating dashes or suchlike. This is
19
+ recommended to be a UUID-compatible ID, but this is not enforced, and formatted differently. Developers can generate
20
+ a new ID for this purpose with systemd-id128 new.
21
+ PRIORITY=
22
+ A priority value between 0 ("emerg") and 7 ("debug") formatted as a decimal string. This field is compatible with
23
+ syslog's priority concept.
24
+ CODE_FILE=, CODE_LINE=, CODE_FUNC=
25
+ The code location generating this message, if known. Contains the source filename, the line number and the function
26
+ name.
27
+ ERRNO=
28
+ The low-level Unix error number causing this entry, if any. Contains the numeric value of errno(3) formatted as a
29
+ decimal string.
30
+ INVOCATION_ID=, USER_INVOCATION_ID=
31
+ A randomized, unique 128-bit ID identifying each runtime cycle of the unit. This is different from
32
+ _SYSTEMD_INVOCATION_ID in that it is only used for messages coming from systemd code (e.g. logs from the system/user
33
+ manager or from forked processes performing systemd-related setup).
34
+ SYSLOG_FACILITY=, SYSLOG_IDENTIFIER=, SYSLOG_PID=, SYSLOG_TIMESTAMP=
35
+ Syslog compatibility fields containing the facility (formatted as decimal string), the identifier string (i.e.
36
+ "tag"), the client PID, and the timestamp as specified in the original datagram. (Note that the tag is usually
37
+ derived from glibc's program_invocation_short_name variable, see program_invocation_short_name(3).) Note that the
38
+ journal service does not validate the values of any structured journal fields whose name is not prefixed with an
39
+ underscore, and this includes any syslog related fields such as these. Hence, applications that supply a facility,
40
+ PID, or log level are expected to do so properly formatted, i.e. as numeric integers formatted as decimal strings.
41
+ SYSLOG_RAW=
42
+ The original contents of the syslog line as received in the syslog datagram. This field is only included if the
43
+ MESSAGE= field was modified compared to the original payload or the timestamp could not be located properly and is
44
+ not included in SYSLOG_TIMESTAMP=. Message truncation occurs when the message contains leading or trailing
45
+ whitespace (trailing and leading whitespace is stripped), or it contains an embedded NUL byte (the NUL byte and
46
+ anything after it is not included). Thus, the original syslog line is either stored as SYSLOG_RAW= or it can be
47
+ recreated based on the stored priority and facility, timestamp, identifier, and the message payload in MESSAGE=.
48
+ DOCUMENTATION=
49
+ A documentation URL with further information about the topic of the log message. Tools such as journalctl will
50
+ include a hyperlink to a URL specified this way in their output. Should be an "http://", "https://", "file:/",
51
+ "man:" or "info:" URL.
52
+ TID=
53
+ The numeric thread ID (TID) the log message originates from.
54
+ UNIT=, USER_UNIT=
55
+ The name of a unit. Used by the system and user managers when logging about specific units. When --unit=name or
56
+ --user-unit=name are used with journalctl(1), a match pattern that includes "UNIT=name.service" or
57
+ "USER_UNIT=name.service" will be generated.
58
+
59
+ ==
60
+
61
+ TRUSTED JOURNAL FIELDS
62
+ Fields prefixed with an underscore are trusted fields, i.e. fields that are implicitly added by the journal and cannot
63
+ be altered by client code.
64
+
65
+ _PID=, _UID=, _GID=
66
+ The process, user, and group ID of the process the journal entry originates from formatted as a decimal string. Note
67
+ that entries obtained via "stdout" or "stderr" of forked processes will contain credentials valid for a parent
68
+ process (that initiated the connection to systemd-journald).
69
+ _COMM=, _EXE=, _CMDLINE=
70
+ The name, the executable path, and the command line of the process the journal entry originates from.
71
+ _CAP_EFFECTIVE=
72
+ The effective capabilities(7) of the process the journal entry originates from.
73
+ _AUDIT_SESSION=, _AUDIT_LOGINUID=
74
+ The session and login UID of the process the journal entry originates from, as maintained by the kernel audit
75
+ subsystem.
76
+ _SYSTEMD_CGROUP=, _SYSTEMD_SLICE=, _SYSTEMD_UNIT=, _SYSTEMD_USER_UNIT=, _SYSTEMD_USER_SLICE=, _SYSTEMD_SESSION=,
77
+ _SYSTEMD_OWNER_UID=
78
+ The control group path in the systemd hierarchy, the systemd slice unit name, the systemd unit name, the unit name
79
+ in the systemd user manager (if any), the systemd session ID (if any), and the owner UID of the systemd user unit or
80
+ systemd session (if any) of the process the journal entry originates from.
81
+ _SELINUX_CONTEXT=
82
+ The SELinux security context (label) of the process the journal entry originates from.
83
+ _SOURCE_REALTIME_TIMESTAMP=
84
+ The earliest trusted timestamp of the message, if any is known that is different from the reception time of the
85
+ journal. This is the time in microseconds since the epoch UTC, formatted as a decimal string.
86
+ _BOOT_ID=
87
+ The kernel boot ID for the boot the message was generated in, formatted as a 128-bit hexadecimal string.
88
+ _MACHINE_ID=
89
+ The machine ID of the originating host, as available in machine-id(5).
90
+ _SYSTEMD_INVOCATION_ID=
91
+ The invocation ID for the runtime cycle of the unit the message was generated in, as available to processes of the
92
+ unit in $INVOCATION_ID (see systemd.exec(5)).
93
+ _HOSTNAME=
94
+ The name of the originating host.
95
+ _TRANSPORT=
96
+ How the entry was received by the journal service. Valid transports are:
97
+ audit - for those read from the kernel audit subsystem
98
+ driver - for internally generated messages
99
+ syslog - for those received via the local syslog socket with the syslog protocol
100
+ journal - for those received via the native journal protocol
101
+ stdout - for those read from a service's standard output or error output
102
+ kernel - for those read from the kernel
103
+ _STREAM_ID=
104
+ Only applies to "_TRANSPORT=stdout" records: specifies a randomized 128-bit ID assigned to the stream connection
105
+ when it was first created. This ID is useful to reconstruct individual log streams from the log records: all log
106
+ records carrying the same stream ID originate from the same stream.
107
+ _LINE_BREAK=
108
+ Only applies to "_TRANSPORT=stdout" records: indicates that the log message in the standard output/error stream was
109
+ not terminated with a normal newline character ("\n", i.e. ASCII 10). Specifically, when set this field is one of
110
+ nul (in case the line was terminated by a NUL byte), line-max (in case the maximum log line length was reached, as
111
+ configured with LineMax= in journald.conf(5)), eof (if this was the last log record of a stream and the stream ended
112
+ without a final newline character), or pid-change (if the process which generated the log output changed in the
113
+ middle of a line). Note that this record is not generated when a normal newline character was used for marking the
114
+ log line end.
115
+ _NAMESPACE=
116
+ If this file was written by a systemd-journald instance managing a journal namespace that is not the default, this
117
+ field contains the namespace identifier. See systemd-journald.service(8) for details about journal namespaces.
118
+ _RUNTIME_SCOPE=
119
+ A string field that specifies the runtime scope in which the message was logged. If "initrd", the log message was
120
+ processed while the system was running inside the initrd. If "system", the log message was generated after the
121
+ system switched execution to the host root filesystem.
122
+ KERNEL JOURNAL FIELDS
123
+ Kernel fields are fields that are used by messages originating in the kernel and stored in the journal.
124
+ _KERNEL_DEVICE=
125
+ The kernel device name. If the entry is associated to a block device, contains the major and minor numbers of the
126
+ device node, separated by ":" and prefixed by "b". Similarly for character devices, but prefixed by "c". For network
127
+ devices, this is the interface index prefixed by "n". For all other devices, this is the subsystem name prefixed by
128
+ "+", followed by ":", followed by the kernel device name.
129
+ _KERNEL_SUBSYSTEM=
130
+ The kernel subsystem name.
131
+ _UDEV_SYSNAME=
132
+ The kernel device name as it shows up in the device tree below /sys/.
133
+ _UDEV_DEVNODE=
134
+ The device node path of this device in /dev/.
135
+ _UDEV_DEVLINK=
136
+ Additional symlink names pointing to the device node in /dev/. This field is frequently set more than once per
137
+ entry.
138
+
139
+ ==
140
+
141
+ FIELDS TO LOG ON BEHALF OF A DIFFERENT PROGRAM
142
+ Fields in this section are used by programs to specify that they are logging on behalf of another program or unit.
143
+
144
+ Fields used by the systemd-coredump coredump kernel helper:
145
+
146
+ COREDUMP_UNIT=, COREDUMP_USER_UNIT=
147
+ Used to annotate messages containing coredumps from system and session units. See coredumpctl(1).
148
+
149
+ Privileged programs (currently UID 0) may attach OBJECT_PID= to a message. This will instruct systemd-journald to attach
150
+ additional fields on behalf of the caller:
151
+
152
+ OBJECT_PID=PID
153
+ PID of the program that this message pertains to.
154
+ OBJECT_UID=, OBJECT_GID=, OBJECT_COMM=, OBJECT_EXE=, OBJECT_CMDLINE=, OBJECT_AUDIT_SESSION=, OBJECT_AUDIT_LOGINUID=,
155
+ OBJECT_SYSTEMD_CGROUP=, OBJECT_SYSTEMD_SESSION=, OBJECT_SYSTEMD_OWNER_UID=, OBJECT_SYSTEMD_UNIT=,
156
+ OBJECT_SYSTEMD_USER_UNIT=
157
+ These are additional fields added automatically by systemd-journald. Their meaning is the same as _UID=, _GID=,
158
+ _COMM=, _EXE=, _CMDLINE=, _AUDIT_SESSION=, _AUDIT_LOGINUID=, _SYSTEMD_CGROUP=, _SYSTEMD_SESSION=, _SYSTEMD_UNIT=,
159
+ _SYSTEMD_USER_UNIT=, and _SYSTEMD_OWNER_UID= as described above, except that the process identified by PID is
160
+ described, instead of the process which logged the message.
161
+ OBJECT_SYSTEMD_INVOCATION_ID=
162
+ An additional field added automatically by systemd-journald. The meaning is mostly the same as
163
+ _SYSTEMD_INVOCATION_ID=, with the difference described above.
164
+
165
+ ==
166
+
167
+ ADDRESS FIELDS
168
+ During serialization into external formats, such as the Journal Export Format[1] or the Journal JSON Format[2], the
169
+ addresses of journal entries are serialized into fields prefixed with double underscores. Note that these are not proper
170
+ fields when stored in the journal but for addressing metadata of entries. They cannot be written as part of structured
171
+ log entries via calls such as sd_journal_send(3). They may also not be used as matches for sd_journal_add_match(3).
172
+
173
+ __CURSOR=
174
+ The cursor for the entry. A cursor is an opaque text string that uniquely describes the position of an entry in the
175
+ journal and is portable across machines, platforms and journal files.
176
+ __REALTIME_TIMESTAMP=
177
+ The wallclock time (CLOCK_REALTIME) at the point in time the entry was received by the journal, in microseconds
178
+ since the epoch UTC, formatted as a decimal string. This has different properties from
179
+ "_SOURCE_REALTIME_TIMESTAMP=", as it is usually a bit later but more likely to be monotonic.
180
+ __MONOTONIC_TIMESTAMP=
181
+ The monotonic time (CLOCK_MONOTONIC) at the point in time the entry was received by the journal in microseconds,
182
+ formatted as a decimal string. To be useful as an address for the entry, this should be combined with the boot ID in
183
+ "_BOOT_ID=".
184
+ __SEQNUM=, __SEQNUM_ID=
185
+ The sequence number (and associated sequence number ID) of this journal entry in the journal file it originates
186
+ from. See sd_journal_get_seqnum(3) for details.
187
+ """