ominfra 0.0.0.dev431__py3-none-any.whl → 0.0.0.dev432__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.
- ominfra/scripts/journald2aws.py +75 -20
- ominfra/scripts/manage.py +75 -20
- ominfra/scripts/supervisor.py +75 -20
- {ominfra-0.0.0.dev431.dist-info → ominfra-0.0.0.dev432.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev431.dist-info → ominfra-0.0.0.dev432.dist-info}/RECORD +9 -9
- {ominfra-0.0.0.dev431.dist-info → ominfra-0.0.0.dev432.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev431.dist-info → ominfra-0.0.0.dev432.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev431.dist-info → ominfra-0.0.0.dev432.dist-info}/licenses/LICENSE +0 -0
- {ominfra-0.0.0.dev431.dist-info → ominfra-0.0.0.dev432.dist-info}/top_level.txt +0 -0
ominfra/scripts/journald2aws.py
CHANGED
@@ -5467,6 +5467,16 @@ class LoggingContext(Abstract):
|
|
5467
5467
|
raise TypeError(f'LoggingContextInfo absent: {ty}')
|
5468
5468
|
return info
|
5469
5469
|
|
5470
|
+
|
5471
|
+
@ta.final
|
5472
|
+
class SimpleLoggingContext(LoggingContext):
|
5473
|
+
def __init__(self, *infos: LoggingContextInfo) -> None:
|
5474
|
+
self._infos: ta.Dict[ta.Type[LoggingContextInfo], LoggingContextInfo] = {type(i): i for i in infos}
|
5475
|
+
|
5476
|
+
def get_info(self, ty: ta.Type[LoggingContextInfoT]) -> ta.Optional[LoggingContextInfoT]:
|
5477
|
+
return self._infos.get(ty)
|
5478
|
+
|
5479
|
+
|
5470
5480
|
##
|
5471
5481
|
|
5472
5482
|
|
@@ -5668,10 +5678,14 @@ def _locking_logging_module_lock() -> ta.Iterator[None]:
|
|
5668
5678
|
def configure_standard_logging(
|
5669
5679
|
level: ta.Union[int, str] = logging.INFO,
|
5670
5680
|
*,
|
5671
|
-
json: bool = False,
|
5672
5681
|
target: ta.Optional[logging.Logger] = None,
|
5682
|
+
|
5673
5683
|
force: bool = False,
|
5684
|
+
|
5674
5685
|
handler_factory: ta.Optional[ta.Callable[[], logging.Handler]] = None,
|
5686
|
+
|
5687
|
+
formatter: ta.Optional[logging.Formatter] = None, # noqa
|
5688
|
+
json: bool = False,
|
5675
5689
|
) -> ta.Optional[StandardConfiguredLoggingHandler]:
|
5676
5690
|
with _locking_logging_module_lock():
|
5677
5691
|
if target is None:
|
@@ -5692,11 +5706,11 @@ def configure_standard_logging(
|
|
5692
5706
|
|
5693
5707
|
#
|
5694
5708
|
|
5695
|
-
formatter:
|
5696
|
-
|
5697
|
-
|
5698
|
-
|
5699
|
-
|
5709
|
+
if formatter is None:
|
5710
|
+
if json:
|
5711
|
+
formatter = JsonLoggingFormatter()
|
5712
|
+
else:
|
5713
|
+
formatter = StandardLoggingFormatter(StandardLoggingFormatter.build_log_format(STANDARD_LOG_FORMAT_PARTS)) # noqa
|
5700
5714
|
handler.setFormatter(formatter)
|
5701
5715
|
|
5702
5716
|
#
|
@@ -6278,8 +6292,23 @@ class LoggingContextInfoRecordAdapters:
|
|
6278
6292
|
|
6279
6293
|
def record_to_info(self, rec: logging.LogRecord) -> ta.Optional[LoggingContextInfos.Caller]:
|
6280
6294
|
# FIXME: piecemeal?
|
6281
|
-
|
6282
|
-
|
6295
|
+
if (
|
6296
|
+
rec.pathname != self._UNKNOWN_PATH_NAME and
|
6297
|
+
rec.lineno != 0 and
|
6298
|
+
rec.funcName != self._UNKNOWN_FUNC_NAME
|
6299
|
+
):
|
6300
|
+
if (sinfo := rec.stack_info) is not None and sinfo.startswith(self._STACK_INFO_PREFIX):
|
6301
|
+
sinfo = sinfo[len(self._STACK_INFO_PREFIX):]
|
6302
|
+
return LoggingContextInfos.Caller(
|
6303
|
+
file_path=rec.pathname,
|
6304
|
+
|
6305
|
+
line_no=rec.lineno,
|
6306
|
+
func_name=rec.funcName,
|
6307
|
+
|
6308
|
+
stack_info=sinfo,
|
6309
|
+
)
|
6310
|
+
|
6311
|
+
return None
|
6283
6312
|
|
6284
6313
|
class SourceFile(Adapter[LoggingContextInfos.SourceFile]):
|
6285
6314
|
info_cls: ta.ClassVar[ta.Type[LoggingContextInfos.SourceFile]] = LoggingContextInfos.SourceFile
|
@@ -6315,9 +6344,9 @@ class LoggingContextInfoRecordAdapters:
|
|
6315
6344
|
)
|
6316
6345
|
|
6317
6346
|
def record_to_info(self, rec: logging.LogRecord) -> ta.Optional[LoggingContextInfos.SourceFile]:
|
6318
|
-
if
|
6319
|
-
rec.module is None
|
6320
|
-
rec.module
|
6347
|
+
if (
|
6348
|
+
rec.module is not None and
|
6349
|
+
rec.module != self._UNKNOWN_MODULE
|
6321
6350
|
):
|
6322
6351
|
return LoggingContextInfos.SourceFile(
|
6323
6352
|
file_name=rec.filename,
|
@@ -6470,16 +6499,11 @@ _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS: ta.Mapping[ta.Type[LoggingContextInfo], L
|
|
6470
6499
|
##
|
6471
6500
|
|
6472
6501
|
|
6473
|
-
KNOWN_STD_LOGGING_RECORD_ATTR_SET: ta.FrozenSet[str] = frozenset(
|
6474
|
-
a for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS.values() for a in ad.record_attrs
|
6475
|
-
)
|
6476
|
-
|
6477
|
-
|
6478
6502
|
# Formatter:
|
6479
6503
|
# - https://github.com/python/cpython/blob/39b2f82717a69dde7212bc39b673b0f55c99e6a3/Lib/logging/__init__.py#L514 (3.8)
|
6480
6504
|
# - https://github.com/python/cpython/blob/f070f54c5f4a42c7c61d1d5d3b8f3b7203b4a0fb/Lib/logging/__init__.py#L554 (~3.14) # noqa
|
6481
6505
|
#
|
6482
|
-
|
6506
|
+
_KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTRS: ta.Dict[str, ta.Any] = dict(
|
6483
6507
|
# The logged message, computed as msg % args. Set to `record.getMessage()`.
|
6484
6508
|
message=str,
|
6485
6509
|
|
@@ -6493,7 +6517,15 @@ KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTRS: ta.Dict[str, ta.Any] = dict(
|
|
6493
6517
|
exc_text=ta.Optional[str],
|
6494
6518
|
)
|
6495
6519
|
|
6496
|
-
|
6520
|
+
|
6521
|
+
##
|
6522
|
+
|
6523
|
+
|
6524
|
+
_KNOWN_STD_LOGGING_RECORD_ATTR_SET: ta.FrozenSet[str] = frozenset(
|
6525
|
+
a for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS.values() for a in ad.record_attrs
|
6526
|
+
)
|
6527
|
+
|
6528
|
+
_KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTR_SET: ta.FrozenSet[str] = frozenset(_KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTRS)
|
6497
6529
|
|
6498
6530
|
|
6499
6531
|
class UnknownStdLoggingRecordAttrsWarning(LoggingSetupWarning):
|
@@ -6503,13 +6535,13 @@ class UnknownStdLoggingRecordAttrsWarning(LoggingSetupWarning):
|
|
6503
6535
|
def _check_std_logging_record_attrs() -> None:
|
6504
6536
|
if (
|
6505
6537
|
len([a for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS.values() for a in ad.record_attrs]) !=
|
6506
|
-
len(
|
6538
|
+
len(_KNOWN_STD_LOGGING_RECORD_ATTR_SET)
|
6507
6539
|
):
|
6508
6540
|
raise RuntimeError('Duplicate LoggingContextInfoRecordAdapter record attrs')
|
6509
6541
|
|
6510
6542
|
rec_dct = dict(logging.makeLogRecord({}).__dict__)
|
6511
6543
|
|
6512
|
-
if (unk_rec_fields := frozenset(rec_dct) -
|
6544
|
+
if (unk_rec_fields := frozenset(rec_dct) - _KNOWN_STD_LOGGING_RECORD_ATTR_SET):
|
6513
6545
|
import warnings # noqa
|
6514
6546
|
|
6515
6547
|
warnings.warn(
|
@@ -6537,10 +6569,33 @@ class LoggingContextLogRecord(logging.LogRecord):
|
|
6537
6569
|
# - sinfo: str | None = None -> stack_info
|
6538
6570
|
|
6539
6571
|
def __init__(self, *, _logging_context: LoggingContext) -> None: # noqa
|
6572
|
+
self._logging_context = _logging_context
|
6573
|
+
|
6540
6574
|
for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS_:
|
6541
6575
|
self.__dict__.update(ad.context_to_record(_logging_context))
|
6542
6576
|
|
6543
6577
|
|
6578
|
+
##
|
6579
|
+
|
6580
|
+
|
6581
|
+
@ta.final
|
6582
|
+
class LogRecordLoggingContext(LoggingContext):
|
6583
|
+
def __init__(self, rec: logging.LogRecord) -> None:
|
6584
|
+
if isinstance(rec, LoggingContextLogRecord):
|
6585
|
+
raise TypeError(rec)
|
6586
|
+
|
6587
|
+
self._rec = rec
|
6588
|
+
|
6589
|
+
self._infos: ta.Dict[ta.Type[LoggingContextInfo], LoggingContextInfo] = {
|
6590
|
+
type(info): info
|
6591
|
+
for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS_
|
6592
|
+
if (info := ad.record_to_info(rec)) is not None
|
6593
|
+
}
|
6594
|
+
|
6595
|
+
def get_info(self, ty: ta.Type[LoggingContextInfoT]) -> ta.Optional[LoggingContextInfoT]:
|
6596
|
+
return self._infos.get(ty)
|
6597
|
+
|
6598
|
+
|
6544
6599
|
########################################
|
6545
6600
|
# ../../../../../omlish/logs/std/loggers.py
|
6546
6601
|
|
ominfra/scripts/manage.py
CHANGED
@@ -10105,6 +10105,16 @@ class LoggingContext(Abstract):
|
|
10105
10105
|
raise TypeError(f'LoggingContextInfo absent: {ty}')
|
10106
10106
|
return info
|
10107
10107
|
|
10108
|
+
|
10109
|
+
@ta.final
|
10110
|
+
class SimpleLoggingContext(LoggingContext):
|
10111
|
+
def __init__(self, *infos: LoggingContextInfo) -> None:
|
10112
|
+
self._infos: ta.Dict[ta.Type[LoggingContextInfo], LoggingContextInfo] = {type(i): i for i in infos}
|
10113
|
+
|
10114
|
+
def get_info(self, ty: ta.Type[LoggingContextInfoT]) -> ta.Optional[LoggingContextInfoT]:
|
10115
|
+
return self._infos.get(ty)
|
10116
|
+
|
10117
|
+
|
10108
10118
|
##
|
10109
10119
|
|
10110
10120
|
|
@@ -10306,10 +10316,14 @@ def _locking_logging_module_lock() -> ta.Iterator[None]:
|
|
10306
10316
|
def configure_standard_logging(
|
10307
10317
|
level: ta.Union[int, str] = logging.INFO,
|
10308
10318
|
*,
|
10309
|
-
json: bool = False,
|
10310
10319
|
target: ta.Optional[logging.Logger] = None,
|
10320
|
+
|
10311
10321
|
force: bool = False,
|
10322
|
+
|
10312
10323
|
handler_factory: ta.Optional[ta.Callable[[], logging.Handler]] = None,
|
10324
|
+
|
10325
|
+
formatter: ta.Optional[logging.Formatter] = None, # noqa
|
10326
|
+
json: bool = False,
|
10313
10327
|
) -> ta.Optional[StandardConfiguredLoggingHandler]:
|
10314
10328
|
with _locking_logging_module_lock():
|
10315
10329
|
if target is None:
|
@@ -10330,11 +10344,11 @@ def configure_standard_logging(
|
|
10330
10344
|
|
10331
10345
|
#
|
10332
10346
|
|
10333
|
-
formatter:
|
10334
|
-
|
10335
|
-
|
10336
|
-
|
10337
|
-
|
10347
|
+
if formatter is None:
|
10348
|
+
if json:
|
10349
|
+
formatter = JsonLoggingFormatter()
|
10350
|
+
else:
|
10351
|
+
formatter = StandardLoggingFormatter(StandardLoggingFormatter.build_log_format(STANDARD_LOG_FORMAT_PARTS)) # noqa
|
10338
10352
|
handler.setFormatter(formatter)
|
10339
10353
|
|
10340
10354
|
#
|
@@ -11515,8 +11529,23 @@ class LoggingContextInfoRecordAdapters:
|
|
11515
11529
|
|
11516
11530
|
def record_to_info(self, rec: logging.LogRecord) -> ta.Optional[LoggingContextInfos.Caller]:
|
11517
11531
|
# FIXME: piecemeal?
|
11518
|
-
|
11519
|
-
|
11532
|
+
if (
|
11533
|
+
rec.pathname != self._UNKNOWN_PATH_NAME and
|
11534
|
+
rec.lineno != 0 and
|
11535
|
+
rec.funcName != self._UNKNOWN_FUNC_NAME
|
11536
|
+
):
|
11537
|
+
if (sinfo := rec.stack_info) is not None and sinfo.startswith(self._STACK_INFO_PREFIX):
|
11538
|
+
sinfo = sinfo[len(self._STACK_INFO_PREFIX):]
|
11539
|
+
return LoggingContextInfos.Caller(
|
11540
|
+
file_path=rec.pathname,
|
11541
|
+
|
11542
|
+
line_no=rec.lineno,
|
11543
|
+
func_name=rec.funcName,
|
11544
|
+
|
11545
|
+
stack_info=sinfo,
|
11546
|
+
)
|
11547
|
+
|
11548
|
+
return None
|
11520
11549
|
|
11521
11550
|
class SourceFile(Adapter[LoggingContextInfos.SourceFile]):
|
11522
11551
|
info_cls: ta.ClassVar[ta.Type[LoggingContextInfos.SourceFile]] = LoggingContextInfos.SourceFile
|
@@ -11552,9 +11581,9 @@ class LoggingContextInfoRecordAdapters:
|
|
11552
11581
|
)
|
11553
11582
|
|
11554
11583
|
def record_to_info(self, rec: logging.LogRecord) -> ta.Optional[LoggingContextInfos.SourceFile]:
|
11555
|
-
if
|
11556
|
-
rec.module is None
|
11557
|
-
rec.module
|
11584
|
+
if (
|
11585
|
+
rec.module is not None and
|
11586
|
+
rec.module != self._UNKNOWN_MODULE
|
11558
11587
|
):
|
11559
11588
|
return LoggingContextInfos.SourceFile(
|
11560
11589
|
file_name=rec.filename,
|
@@ -11707,16 +11736,11 @@ _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS: ta.Mapping[ta.Type[LoggingContextInfo], L
|
|
11707
11736
|
##
|
11708
11737
|
|
11709
11738
|
|
11710
|
-
KNOWN_STD_LOGGING_RECORD_ATTR_SET: ta.FrozenSet[str] = frozenset(
|
11711
|
-
a for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS.values() for a in ad.record_attrs
|
11712
|
-
)
|
11713
|
-
|
11714
|
-
|
11715
11739
|
# Formatter:
|
11716
11740
|
# - https://github.com/python/cpython/blob/39b2f82717a69dde7212bc39b673b0f55c99e6a3/Lib/logging/__init__.py#L514 (3.8)
|
11717
11741
|
# - https://github.com/python/cpython/blob/f070f54c5f4a42c7c61d1d5d3b8f3b7203b4a0fb/Lib/logging/__init__.py#L554 (~3.14) # noqa
|
11718
11742
|
#
|
11719
|
-
|
11743
|
+
_KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTRS: ta.Dict[str, ta.Any] = dict(
|
11720
11744
|
# The logged message, computed as msg % args. Set to `record.getMessage()`.
|
11721
11745
|
message=str,
|
11722
11746
|
|
@@ -11730,7 +11754,15 @@ KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTRS: ta.Dict[str, ta.Any] = dict(
|
|
11730
11754
|
exc_text=ta.Optional[str],
|
11731
11755
|
)
|
11732
11756
|
|
11733
|
-
|
11757
|
+
|
11758
|
+
##
|
11759
|
+
|
11760
|
+
|
11761
|
+
_KNOWN_STD_LOGGING_RECORD_ATTR_SET: ta.FrozenSet[str] = frozenset(
|
11762
|
+
a for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS.values() for a in ad.record_attrs
|
11763
|
+
)
|
11764
|
+
|
11765
|
+
_KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTR_SET: ta.FrozenSet[str] = frozenset(_KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTRS)
|
11734
11766
|
|
11735
11767
|
|
11736
11768
|
class UnknownStdLoggingRecordAttrsWarning(LoggingSetupWarning):
|
@@ -11740,13 +11772,13 @@ class UnknownStdLoggingRecordAttrsWarning(LoggingSetupWarning):
|
|
11740
11772
|
def _check_std_logging_record_attrs() -> None:
|
11741
11773
|
if (
|
11742
11774
|
len([a for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS.values() for a in ad.record_attrs]) !=
|
11743
|
-
len(
|
11775
|
+
len(_KNOWN_STD_LOGGING_RECORD_ATTR_SET)
|
11744
11776
|
):
|
11745
11777
|
raise RuntimeError('Duplicate LoggingContextInfoRecordAdapter record attrs')
|
11746
11778
|
|
11747
11779
|
rec_dct = dict(logging.makeLogRecord({}).__dict__)
|
11748
11780
|
|
11749
|
-
if (unk_rec_fields := frozenset(rec_dct) -
|
11781
|
+
if (unk_rec_fields := frozenset(rec_dct) - _KNOWN_STD_LOGGING_RECORD_ATTR_SET):
|
11750
11782
|
import warnings # noqa
|
11751
11783
|
|
11752
11784
|
warnings.warn(
|
@@ -11774,10 +11806,33 @@ class LoggingContextLogRecord(logging.LogRecord):
|
|
11774
11806
|
# - sinfo: str | None = None -> stack_info
|
11775
11807
|
|
11776
11808
|
def __init__(self, *, _logging_context: LoggingContext) -> None: # noqa
|
11809
|
+
self._logging_context = _logging_context
|
11810
|
+
|
11777
11811
|
for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS_:
|
11778
11812
|
self.__dict__.update(ad.context_to_record(_logging_context))
|
11779
11813
|
|
11780
11814
|
|
11815
|
+
##
|
11816
|
+
|
11817
|
+
|
11818
|
+
@ta.final
|
11819
|
+
class LogRecordLoggingContext(LoggingContext):
|
11820
|
+
def __init__(self, rec: logging.LogRecord) -> None:
|
11821
|
+
if isinstance(rec, LoggingContextLogRecord):
|
11822
|
+
raise TypeError(rec)
|
11823
|
+
|
11824
|
+
self._rec = rec
|
11825
|
+
|
11826
|
+
self._infos: ta.Dict[ta.Type[LoggingContextInfo], LoggingContextInfo] = {
|
11827
|
+
type(info): info
|
11828
|
+
for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS_
|
11829
|
+
if (info := ad.record_to_info(rec)) is not None
|
11830
|
+
}
|
11831
|
+
|
11832
|
+
def get_info(self, ty: ta.Type[LoggingContextInfoT]) -> ta.Optional[LoggingContextInfoT]:
|
11833
|
+
return self._infos.get(ty)
|
11834
|
+
|
11835
|
+
|
11781
11836
|
########################################
|
11782
11837
|
# ../../../omlish/subprocesses/base.py
|
11783
11838
|
|
ominfra/scripts/supervisor.py
CHANGED
@@ -8591,6 +8591,16 @@ class LoggingContext(Abstract):
|
|
8591
8591
|
raise TypeError(f'LoggingContextInfo absent: {ty}')
|
8592
8592
|
return info
|
8593
8593
|
|
8594
|
+
|
8595
|
+
@ta.final
|
8596
|
+
class SimpleLoggingContext(LoggingContext):
|
8597
|
+
def __init__(self, *infos: LoggingContextInfo) -> None:
|
8598
|
+
self._infos: ta.Dict[ta.Type[LoggingContextInfo], LoggingContextInfo] = {type(i): i for i in infos}
|
8599
|
+
|
8600
|
+
def get_info(self, ty: ta.Type[LoggingContextInfoT]) -> ta.Optional[LoggingContextInfoT]:
|
8601
|
+
return self._infos.get(ty)
|
8602
|
+
|
8603
|
+
|
8594
8604
|
##
|
8595
8605
|
|
8596
8606
|
|
@@ -8792,10 +8802,14 @@ def _locking_logging_module_lock() -> ta.Iterator[None]:
|
|
8792
8802
|
def configure_standard_logging(
|
8793
8803
|
level: ta.Union[int, str] = logging.INFO,
|
8794
8804
|
*,
|
8795
|
-
json: bool = False,
|
8796
8805
|
target: ta.Optional[logging.Logger] = None,
|
8806
|
+
|
8797
8807
|
force: bool = False,
|
8808
|
+
|
8798
8809
|
handler_factory: ta.Optional[ta.Callable[[], logging.Handler]] = None,
|
8810
|
+
|
8811
|
+
formatter: ta.Optional[logging.Formatter] = None, # noqa
|
8812
|
+
json: bool = False,
|
8799
8813
|
) -> ta.Optional[StandardConfiguredLoggingHandler]:
|
8800
8814
|
with _locking_logging_module_lock():
|
8801
8815
|
if target is None:
|
@@ -8816,11 +8830,11 @@ def configure_standard_logging(
|
|
8816
8830
|
|
8817
8831
|
#
|
8818
8832
|
|
8819
|
-
formatter:
|
8820
|
-
|
8821
|
-
|
8822
|
-
|
8823
|
-
|
8833
|
+
if formatter is None:
|
8834
|
+
if json:
|
8835
|
+
formatter = JsonLoggingFormatter()
|
8836
|
+
else:
|
8837
|
+
formatter = StandardLoggingFormatter(StandardLoggingFormatter.build_log_format(STANDARD_LOG_FORMAT_PARTS)) # noqa
|
8824
8838
|
handler.setFormatter(formatter)
|
8825
8839
|
|
8826
8840
|
#
|
@@ -10123,8 +10137,23 @@ class LoggingContextInfoRecordAdapters:
|
|
10123
10137
|
|
10124
10138
|
def record_to_info(self, rec: logging.LogRecord) -> ta.Optional[LoggingContextInfos.Caller]:
|
10125
10139
|
# FIXME: piecemeal?
|
10126
|
-
|
10127
|
-
|
10140
|
+
if (
|
10141
|
+
rec.pathname != self._UNKNOWN_PATH_NAME and
|
10142
|
+
rec.lineno != 0 and
|
10143
|
+
rec.funcName != self._UNKNOWN_FUNC_NAME
|
10144
|
+
):
|
10145
|
+
if (sinfo := rec.stack_info) is not None and sinfo.startswith(self._STACK_INFO_PREFIX):
|
10146
|
+
sinfo = sinfo[len(self._STACK_INFO_PREFIX):]
|
10147
|
+
return LoggingContextInfos.Caller(
|
10148
|
+
file_path=rec.pathname,
|
10149
|
+
|
10150
|
+
line_no=rec.lineno,
|
10151
|
+
func_name=rec.funcName,
|
10152
|
+
|
10153
|
+
stack_info=sinfo,
|
10154
|
+
)
|
10155
|
+
|
10156
|
+
return None
|
10128
10157
|
|
10129
10158
|
class SourceFile(Adapter[LoggingContextInfos.SourceFile]):
|
10130
10159
|
info_cls: ta.ClassVar[ta.Type[LoggingContextInfos.SourceFile]] = LoggingContextInfos.SourceFile
|
@@ -10160,9 +10189,9 @@ class LoggingContextInfoRecordAdapters:
|
|
10160
10189
|
)
|
10161
10190
|
|
10162
10191
|
def record_to_info(self, rec: logging.LogRecord) -> ta.Optional[LoggingContextInfos.SourceFile]:
|
10163
|
-
if
|
10164
|
-
rec.module is None
|
10165
|
-
rec.module
|
10192
|
+
if (
|
10193
|
+
rec.module is not None and
|
10194
|
+
rec.module != self._UNKNOWN_MODULE
|
10166
10195
|
):
|
10167
10196
|
return LoggingContextInfos.SourceFile(
|
10168
10197
|
file_name=rec.filename,
|
@@ -10315,16 +10344,11 @@ _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS: ta.Mapping[ta.Type[LoggingContextInfo], L
|
|
10315
10344
|
##
|
10316
10345
|
|
10317
10346
|
|
10318
|
-
KNOWN_STD_LOGGING_RECORD_ATTR_SET: ta.FrozenSet[str] = frozenset(
|
10319
|
-
a for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS.values() for a in ad.record_attrs
|
10320
|
-
)
|
10321
|
-
|
10322
|
-
|
10323
10347
|
# Formatter:
|
10324
10348
|
# - https://github.com/python/cpython/blob/39b2f82717a69dde7212bc39b673b0f55c99e6a3/Lib/logging/__init__.py#L514 (3.8)
|
10325
10349
|
# - https://github.com/python/cpython/blob/f070f54c5f4a42c7c61d1d5d3b8f3b7203b4a0fb/Lib/logging/__init__.py#L554 (~3.14) # noqa
|
10326
10350
|
#
|
10327
|
-
|
10351
|
+
_KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTRS: ta.Dict[str, ta.Any] = dict(
|
10328
10352
|
# The logged message, computed as msg % args. Set to `record.getMessage()`.
|
10329
10353
|
message=str,
|
10330
10354
|
|
@@ -10338,7 +10362,15 @@ KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTRS: ta.Dict[str, ta.Any] = dict(
|
|
10338
10362
|
exc_text=ta.Optional[str],
|
10339
10363
|
)
|
10340
10364
|
|
10341
|
-
|
10365
|
+
|
10366
|
+
##
|
10367
|
+
|
10368
|
+
|
10369
|
+
_KNOWN_STD_LOGGING_RECORD_ATTR_SET: ta.FrozenSet[str] = frozenset(
|
10370
|
+
a for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS.values() for a in ad.record_attrs
|
10371
|
+
)
|
10372
|
+
|
10373
|
+
_KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTR_SET: ta.FrozenSet[str] = frozenset(_KNOWN_STD_LOGGING_FORMATTER_RECORD_ATTRS)
|
10342
10374
|
|
10343
10375
|
|
10344
10376
|
class UnknownStdLoggingRecordAttrsWarning(LoggingSetupWarning):
|
@@ -10348,13 +10380,13 @@ class UnknownStdLoggingRecordAttrsWarning(LoggingSetupWarning):
|
|
10348
10380
|
def _check_std_logging_record_attrs() -> None:
|
10349
10381
|
if (
|
10350
10382
|
len([a for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS.values() for a in ad.record_attrs]) !=
|
10351
|
-
len(
|
10383
|
+
len(_KNOWN_STD_LOGGING_RECORD_ATTR_SET)
|
10352
10384
|
):
|
10353
10385
|
raise RuntimeError('Duplicate LoggingContextInfoRecordAdapter record attrs')
|
10354
10386
|
|
10355
10387
|
rec_dct = dict(logging.makeLogRecord({}).__dict__)
|
10356
10388
|
|
10357
|
-
if (unk_rec_fields := frozenset(rec_dct) -
|
10389
|
+
if (unk_rec_fields := frozenset(rec_dct) - _KNOWN_STD_LOGGING_RECORD_ATTR_SET):
|
10358
10390
|
import warnings # noqa
|
10359
10391
|
|
10360
10392
|
warnings.warn(
|
@@ -10382,10 +10414,33 @@ class LoggingContextLogRecord(logging.LogRecord):
|
|
10382
10414
|
# - sinfo: str | None = None -> stack_info
|
10383
10415
|
|
10384
10416
|
def __init__(self, *, _logging_context: LoggingContext) -> None: # noqa
|
10417
|
+
self._logging_context = _logging_context
|
10418
|
+
|
10385
10419
|
for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS_:
|
10386
10420
|
self.__dict__.update(ad.context_to_record(_logging_context))
|
10387
10421
|
|
10388
10422
|
|
10423
|
+
##
|
10424
|
+
|
10425
|
+
|
10426
|
+
@ta.final
|
10427
|
+
class LogRecordLoggingContext(LoggingContext):
|
10428
|
+
def __init__(self, rec: logging.LogRecord) -> None:
|
10429
|
+
if isinstance(rec, LoggingContextLogRecord):
|
10430
|
+
raise TypeError(rec)
|
10431
|
+
|
10432
|
+
self._rec = rec
|
10433
|
+
|
10434
|
+
self._infos: ta.Dict[ta.Type[LoggingContextInfo], LoggingContextInfo] = {
|
10435
|
+
type(info): info
|
10436
|
+
for ad in _LOGGING_CONTEXT_INFO_RECORD_ADAPTERS_
|
10437
|
+
if (info := ad.record_to_info(rec)) is not None
|
10438
|
+
}
|
10439
|
+
|
10440
|
+
def get_info(self, ty: ta.Type[LoggingContextInfoT]) -> ta.Optional[LoggingContextInfoT]:
|
10441
|
+
return self._infos.get(ty)
|
10442
|
+
|
10443
|
+
|
10389
10444
|
########################################
|
10390
10445
|
# ../dispatchers.py
|
10391
10446
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ominfra
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev432
|
4
4
|
Summary: ominfra
|
5
5
|
Author: wrmsr
|
6
6
|
License-Expression: BSD-3-Clause
|
@@ -14,8 +14,8 @@ Classifier: Programming Language :: Python :: 3.13
|
|
14
14
|
Requires-Python: >=3.13
|
15
15
|
Description-Content-Type: text/markdown
|
16
16
|
License-File: LICENSE
|
17
|
-
Requires-Dist: omdev==0.0.0.
|
18
|
-
Requires-Dist: omlish==0.0.0.
|
17
|
+
Requires-Dist: omdev==0.0.0.dev432
|
18
|
+
Requires-Dist: omlish==0.0.0.dev432
|
19
19
|
Provides-Extra: all
|
20
20
|
Requires-Dist: paramiko~=4.0; extra == "all"
|
21
21
|
Requires-Dist: asyncssh~=2.21; extra == "all"
|
@@ -112,9 +112,9 @@ ominfra/manage/targets/connection.py,sha256=mOHCsDVG-DZBhl3Mb7TTr1vhPb0gxDOOMW1x
|
|
112
112
|
ominfra/manage/targets/inject.py,sha256=3M4wBkxtvymq_yhiotHlTN8iydELMjVCndyp9Bq-4eo,1572
|
113
113
|
ominfra/manage/targets/targets.py,sha256=LjSQrDsHEjEQMDHcxtNKmLjy0YGLXJRGPFdUjazzFIM,1918
|
114
114
|
ominfra/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
115
|
-
ominfra/scripts/journald2aws.py,sha256=
|
116
|
-
ominfra/scripts/manage.py,sha256=
|
117
|
-
ominfra/scripts/supervisor.py,sha256=
|
115
|
+
ominfra/scripts/journald2aws.py,sha256=McTkVneQxcXxPs8tfs41tzdOtIM8dpY66d2vdXHCUrA,242352
|
116
|
+
ominfra/scripts/manage.py,sha256=TfQ9Z_K8rSPqQU_TRz3lEgk36qmPdLxkDRf-fnAyZcA,466073
|
117
|
+
ominfra/scripts/supervisor.py,sha256=ov3MqEzjHFfjPcbeSVD5QLSWlImKdBo3z1w-L8ZOv5U,375812
|
118
118
|
ominfra/supervisor/LICENSE.txt,sha256=ZrHY15PVR98y26Yg6iQfa-SXnUaYTDhrUsPVcEO5OKM,1874
|
119
119
|
ominfra/supervisor/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
120
120
|
ominfra/supervisor/__main__.py,sha256=I0yFw-C08OOiZ3BF6lF1Oiv789EQXu-_j6whDhQUTEA,66
|
@@ -156,9 +156,9 @@ ominfra/tailscale/api.py,sha256=XASv9C_CWI-u-yX5jVzhJrkJhlwQRkYQWQQG1uJwAd8,1375
|
|
156
156
|
ominfra/tailscale/cli.py,sha256=zRV7-tKB7kBah1oTVZlol-vwx1FBlnfzYAPGkeU5jX4,3543
|
157
157
|
ominfra/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
158
158
|
ominfra/tools/listresources.py,sha256=ePmo7cUAiBZARkM_3K4GKYZXxV73An_aioS1m-AAJis,6181
|
159
|
-
ominfra-0.0.0.
|
160
|
-
ominfra-0.0.0.
|
161
|
-
ominfra-0.0.0.
|
162
|
-
ominfra-0.0.0.
|
163
|
-
ominfra-0.0.0.
|
164
|
-
ominfra-0.0.0.
|
159
|
+
ominfra-0.0.0.dev432.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
160
|
+
ominfra-0.0.0.dev432.dist-info/METADATA,sha256=swTKFes6uHiyoeKWMtOraKxEFLH0EMD_edQR6p5ZBeE,2377
|
161
|
+
ominfra-0.0.0.dev432.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
162
|
+
ominfra-0.0.0.dev432.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
|
163
|
+
ominfra-0.0.0.dev432.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
|
164
|
+
ominfra-0.0.0.dev432.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|