ominfra 0.0.0.dev424__py3-none-any.whl → 0.0.0.dev426__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/clouds/aws/journald2aws/cursor.py +4 -1
- ominfra/clouds/aws/journald2aws/driver.py +4 -1
- ominfra/clouds/aws/journald2aws/poster.py +4 -1
- ominfra/clouds/aws/models/services/ec2.py +31 -0
- ominfra/journald/messages.py +4 -1
- ominfra/journald/tailer.py +4 -1
- ominfra/manage/deploy/commands.py +4 -1
- ominfra/manage/main.py +4 -1
- ominfra/manage/remote/_main.py +4 -1
- ominfra/manage/remote/execution.py +4 -1
- ominfra/manage/system/commands.py +4 -1
- ominfra/manage/system/platforms.py +4 -1
- ominfra/scripts/journald2aws.py +379 -32
- ominfra/scripts/manage.py +384 -32
- ominfra/scripts/supervisor.py +385 -36
- ominfra/supervisor/dispatchersimpl.py +4 -1
- ominfra/supervisor/io.py +4 -1
- ominfra/supervisor/main.py +2 -2
- ominfra/supervisor/processimpl.py +4 -1
- ominfra/supervisor/setupimpl.py +4 -1
- ominfra/supervisor/signals.py +4 -1
- ominfra/supervisor/supervisor.py +4 -1
- ominfra/threadworkers.py +4 -1
- {ominfra-0.0.0.dev424.dist-info → ominfra-0.0.0.dev426.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev424.dist-info → ominfra-0.0.0.dev426.dist-info}/RECORD +30 -30
- /ominfra/{.manifests.json → .omlish-manifests.json} +0 -0
- {ominfra-0.0.0.dev424.dist-info → ominfra-0.0.0.dev426.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev424.dist-info → ominfra-0.0.0.dev426.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev424.dist-info → ominfra-0.0.0.dev426.dist-info}/licenses/LICENSE +0 -0
- {ominfra-0.0.0.dev424.dist-info → ominfra-0.0.0.dev426.dist-info}/top_level.txt +0 -0
ominfra/scripts/supervisor.py
CHANGED
@@ -112,8 +112,10 @@ TomlParseFloat = ta.Callable[[str], ta.Any] # ta.TypeAlias
|
|
112
112
|
TomlKey = ta.Tuple[str, ...] # ta.TypeAlias
|
113
113
|
TomlPos = int # ta.TypeAlias
|
114
114
|
|
115
|
-
# ../../omlish/lite/
|
115
|
+
# ../../omlish/lite/attrops.py
|
116
116
|
T = ta.TypeVar('T')
|
117
|
+
|
118
|
+
# ../../omlish/lite/cached.py
|
117
119
|
CallableT = ta.TypeVar('CallableT', bound=ta.Callable)
|
118
120
|
|
119
121
|
# ../../omlish/lite/check.py
|
@@ -1830,6 +1832,335 @@ class Abstract:
|
|
1830
1832
|
update_abstracts(cls, force=True)
|
1831
1833
|
|
1832
1834
|
|
1835
|
+
########################################
|
1836
|
+
# ../../../omlish/lite/attrops.py
|
1837
|
+
"""
|
1838
|
+
TODO:
|
1839
|
+
- dotted paths!
|
1840
|
+
- per-attr repr transform / filter
|
1841
|
+
- __ne__ ? cases where it still matters
|
1842
|
+
- ordering ?
|
1843
|
+
"""
|
1844
|
+
|
1845
|
+
|
1846
|
+
##
|
1847
|
+
|
1848
|
+
|
1849
|
+
@ta.final
|
1850
|
+
class AttrOps(ta.Generic[T]):
|
1851
|
+
@ta.final
|
1852
|
+
class Attr:
|
1853
|
+
def __init__(
|
1854
|
+
self,
|
1855
|
+
name: str,
|
1856
|
+
*,
|
1857
|
+
display: ta.Optional[str] = None,
|
1858
|
+
|
1859
|
+
repr: bool = True, # noqa
|
1860
|
+
hash: bool = True, # noqa
|
1861
|
+
eq: bool = True,
|
1862
|
+
) -> None:
|
1863
|
+
if '.' in name:
|
1864
|
+
raise NotImplementedError('Dotted paths not yet supported')
|
1865
|
+
if not name.isidentifier() or name.startswith('__'):
|
1866
|
+
raise AttributeError(f'Invalid attr: {name!r}')
|
1867
|
+
self._name = name
|
1868
|
+
|
1869
|
+
if display is None:
|
1870
|
+
display = name[1:] if name.startswith('_') and len(name) > 1 else name
|
1871
|
+
self._display = display
|
1872
|
+
|
1873
|
+
self._repr = repr
|
1874
|
+
self._hash = hash
|
1875
|
+
self._eq = eq
|
1876
|
+
|
1877
|
+
@classmethod
|
1878
|
+
def of(
|
1879
|
+
cls,
|
1880
|
+
o: ta.Union[
|
1881
|
+
str,
|
1882
|
+
ta.Tuple[str, str],
|
1883
|
+
'AttrOps.Attr',
|
1884
|
+
],
|
1885
|
+
) -> 'AttrOps.Attr':
|
1886
|
+
if isinstance(o, AttrOps.Attr):
|
1887
|
+
return o
|
1888
|
+
elif isinstance(o, str):
|
1889
|
+
return cls(o)
|
1890
|
+
else:
|
1891
|
+
name, disp = o
|
1892
|
+
return cls(
|
1893
|
+
name,
|
1894
|
+
display=disp,
|
1895
|
+
)
|
1896
|
+
|
1897
|
+
@property
|
1898
|
+
def name(self) -> str:
|
1899
|
+
return self._name
|
1900
|
+
|
1901
|
+
@property
|
1902
|
+
def display(self) -> str:
|
1903
|
+
return self._display
|
1904
|
+
|
1905
|
+
@property
|
1906
|
+
def hash(self) -> bool:
|
1907
|
+
return self._hash
|
1908
|
+
|
1909
|
+
@property
|
1910
|
+
def eq(self) -> bool:
|
1911
|
+
return self._eq
|
1912
|
+
|
1913
|
+
@ta.overload
|
1914
|
+
def __init__(
|
1915
|
+
self,
|
1916
|
+
*attrs: ta.Sequence[ta.Union[
|
1917
|
+
str,
|
1918
|
+
ta.Tuple[str, str],
|
1919
|
+
Attr,
|
1920
|
+
]],
|
1921
|
+
with_module: bool = False,
|
1922
|
+
use_qualname: bool = False,
|
1923
|
+
with_id: bool = False,
|
1924
|
+
repr_filter: ta.Optional[ta.Callable[[ta.Any], bool]] = None,
|
1925
|
+
recursive: bool = False,
|
1926
|
+
subtypes_eq: bool = False,
|
1927
|
+
) -> None:
|
1928
|
+
...
|
1929
|
+
|
1930
|
+
@ta.overload
|
1931
|
+
def __init__(
|
1932
|
+
self,
|
1933
|
+
attrs_fn: ta.Callable[[T], ta.Tuple[ta.Union[
|
1934
|
+
ta.Any,
|
1935
|
+
ta.Tuple[str, ta.Any],
|
1936
|
+
Attr,
|
1937
|
+
], ...]],
|
1938
|
+
/,
|
1939
|
+
*,
|
1940
|
+
with_module: bool = False,
|
1941
|
+
use_qualname: bool = False,
|
1942
|
+
with_id: bool = False,
|
1943
|
+
repr_filter: ta.Optional[ta.Callable[[ta.Any], bool]] = None,
|
1944
|
+
recursive: bool = False,
|
1945
|
+
subtypes_eq: bool = False,
|
1946
|
+
) -> None:
|
1947
|
+
...
|
1948
|
+
|
1949
|
+
def __init__(
|
1950
|
+
self,
|
1951
|
+
*args,
|
1952
|
+
with_module=False,
|
1953
|
+
use_qualname=False,
|
1954
|
+
with_id=False,
|
1955
|
+
repr_filter=None,
|
1956
|
+
recursive=False,
|
1957
|
+
subtypes_eq=False,
|
1958
|
+
) -> None:
|
1959
|
+
if args and len(args) == 1 and callable(args[0]):
|
1960
|
+
self._attrs: ta.Sequence[AttrOps.Attr] = self._capture_attrs(args[0])
|
1961
|
+
else:
|
1962
|
+
self._attrs = list(map(AttrOps.Attr.of, args))
|
1963
|
+
|
1964
|
+
self._with_module: bool = with_module
|
1965
|
+
self._use_qualname: bool = use_qualname
|
1966
|
+
self._with_id: bool = with_id
|
1967
|
+
self._repr_filter: ta.Optional[ta.Callable[[ta.Any], bool]] = repr_filter
|
1968
|
+
self._recursive: bool = recursive
|
1969
|
+
self._subtypes_eq: bool = subtypes_eq
|
1970
|
+
|
1971
|
+
@property
|
1972
|
+
def attrs(self) -> ta.Sequence[Attr]:
|
1973
|
+
return self._attrs
|
1974
|
+
|
1975
|
+
#
|
1976
|
+
|
1977
|
+
@ta.final
|
1978
|
+
class _AttrCapturer:
|
1979
|
+
def __init__(self, fn):
|
1980
|
+
self.__fn = fn
|
1981
|
+
|
1982
|
+
def __getattr__(self, attr):
|
1983
|
+
return self.__fn(self, attr)
|
1984
|
+
|
1985
|
+
@classmethod
|
1986
|
+
def _capture_attrs(cls, fn: ta.Callable) -> ta.Sequence[Attr]:
|
1987
|
+
def access(parent, attr):
|
1988
|
+
dct[(ret := cls._AttrCapturer(access))] = (parent, attr)
|
1989
|
+
return ret
|
1990
|
+
|
1991
|
+
dct: dict = {}
|
1992
|
+
raw = fn(root := cls._AttrCapturer(access))
|
1993
|
+
|
1994
|
+
def rec(cap): # noqa
|
1995
|
+
if cap is root:
|
1996
|
+
return
|
1997
|
+
parent, attr = dct[cap]
|
1998
|
+
yield from rec(parent)
|
1999
|
+
yield attr
|
2000
|
+
|
2001
|
+
attrs: ta.List[AttrOps.Attr] = []
|
2002
|
+
for o in raw:
|
2003
|
+
if isinstance(o, AttrOps.Attr):
|
2004
|
+
attrs.append(o)
|
2005
|
+
continue
|
2006
|
+
|
2007
|
+
if isinstance(o, tuple):
|
2008
|
+
disp, cap, = o
|
2009
|
+
else:
|
2010
|
+
disp, cap = None, o
|
2011
|
+
|
2012
|
+
path = tuple(rec(cap))
|
2013
|
+
|
2014
|
+
attrs.append(AttrOps.Attr(
|
2015
|
+
'.'.join(path),
|
2016
|
+
display=disp,
|
2017
|
+
))
|
2018
|
+
|
2019
|
+
return attrs
|
2020
|
+
|
2021
|
+
#
|
2022
|
+
|
2023
|
+
_repr: ta.Callable[[T], str]
|
2024
|
+
|
2025
|
+
@property
|
2026
|
+
def repr(self) -> ta.Callable[[T], str]:
|
2027
|
+
try:
|
2028
|
+
return self._repr
|
2029
|
+
except AttributeError:
|
2030
|
+
pass
|
2031
|
+
|
2032
|
+
def _repr(o: T) -> str:
|
2033
|
+
vs = ', '.join(
|
2034
|
+
f'{a._display}={v!r}' # noqa
|
2035
|
+
for a in self._attrs
|
2036
|
+
if a._repr # noqa
|
2037
|
+
for v in [getattr(o, a._name)] # noqa
|
2038
|
+
if self._repr_filter is None or self._repr_filter(v)
|
2039
|
+
)
|
2040
|
+
|
2041
|
+
return (
|
2042
|
+
f'{o.__class__.__module__ + "." if self._with_module else ""}'
|
2043
|
+
f'{o.__class__.__qualname__ if self._use_qualname else o.__class__.__name__}'
|
2044
|
+
f'{("@" + hex(id(o))[2:]) if self._with_id else ""}'
|
2045
|
+
f'({vs})'
|
2046
|
+
)
|
2047
|
+
|
2048
|
+
if self._recursive:
|
2049
|
+
_repr = self._reprlib().recursive_repr()(_repr)
|
2050
|
+
|
2051
|
+
self._repr = _repr
|
2052
|
+
return _repr
|
2053
|
+
|
2054
|
+
_reprlib_: ta.ClassVar[ta.Any]
|
2055
|
+
|
2056
|
+
@classmethod
|
2057
|
+
def _reprlib(cls) -> ta.Any:
|
2058
|
+
try:
|
2059
|
+
return cls._reprlib_
|
2060
|
+
except AttributeError:
|
2061
|
+
pass
|
2062
|
+
|
2063
|
+
import reprlib # noqa
|
2064
|
+
|
2065
|
+
cls._reprlib_ = reprlib
|
2066
|
+
return reprlib
|
2067
|
+
|
2068
|
+
#
|
2069
|
+
|
2070
|
+
_hash: ta.Callable[[T], int]
|
2071
|
+
|
2072
|
+
@property
|
2073
|
+
def hash(self) -> ta.Callable[[T], int]:
|
2074
|
+
try:
|
2075
|
+
return self._hash
|
2076
|
+
except AttributeError:
|
2077
|
+
pass
|
2078
|
+
|
2079
|
+
def _hash(o: T) -> int:
|
2080
|
+
return hash(tuple(
|
2081
|
+
getattr(o, a._name) # noqa
|
2082
|
+
for a in self._attrs
|
2083
|
+
if a._hash # noqa
|
2084
|
+
))
|
2085
|
+
|
2086
|
+
self._hash = _hash
|
2087
|
+
return _hash
|
2088
|
+
|
2089
|
+
#
|
2090
|
+
|
2091
|
+
_eq: ta.Callable[[T, ta.Any], ta.Union[bool, 'types.NotImplementedType']]
|
2092
|
+
|
2093
|
+
@property
|
2094
|
+
def eq(self) -> ta.Callable[[T, ta.Any], ta.Union[bool, 'types.NotImplementedType']]:
|
2095
|
+
try:
|
2096
|
+
return self._eq
|
2097
|
+
except AttributeError:
|
2098
|
+
pass
|
2099
|
+
|
2100
|
+
def _eq(o: T, x: ta.Any) -> 'ta.Union[bool, types.NotImplementedType]':
|
2101
|
+
if self._subtypes_eq:
|
2102
|
+
if not isinstance(x, type(o)):
|
2103
|
+
return NotImplemented
|
2104
|
+
else:
|
2105
|
+
if type(x) is not type(o):
|
2106
|
+
return NotImplemented
|
2107
|
+
|
2108
|
+
return all(
|
2109
|
+
getattr(o, a._name) == getattr(x, a._name) # noqa
|
2110
|
+
for a in self._attrs
|
2111
|
+
if a._eq # noqa
|
2112
|
+
)
|
2113
|
+
|
2114
|
+
self._eq = _eq
|
2115
|
+
return _eq
|
2116
|
+
|
2117
|
+
#
|
2118
|
+
|
2119
|
+
@property
|
2120
|
+
def hash_eq(self) -> ta.Tuple[
|
2121
|
+
ta.Callable[[T], int],
|
2122
|
+
ta.Callable[[T, ta.Any], ta.Union[bool, 'types.NotImplementedType']],
|
2123
|
+
]:
|
2124
|
+
return (self.hash, self.eq)
|
2125
|
+
|
2126
|
+
@property
|
2127
|
+
def repr_hash_eq(self) -> ta.Tuple[
|
2128
|
+
ta.Callable[[T], str],
|
2129
|
+
ta.Callable[[T], int],
|
2130
|
+
ta.Callable[[T, ta.Any], ta.Union[bool, 'types.NotImplementedType']],
|
2131
|
+
]:
|
2132
|
+
return (self.repr, self.hash, self.eq)
|
2133
|
+
|
2134
|
+
#
|
2135
|
+
|
2136
|
+
def install(
|
2137
|
+
self,
|
2138
|
+
locals_dct: ta.MutableMapping[str, ta.Any],
|
2139
|
+
*,
|
2140
|
+
all: bool = False, # noqa
|
2141
|
+
repr: bool = False, # noqa
|
2142
|
+
hash: bool = False, # noqa
|
2143
|
+
eq: bool = False,
|
2144
|
+
) -> 'AttrOps[T]':
|
2145
|
+
if repr or all:
|
2146
|
+
locals_dct.update(__repr__=self.repr)
|
2147
|
+
if hash or all:
|
2148
|
+
locals_dct.update(__hash__=self.hash)
|
2149
|
+
if eq or all:
|
2150
|
+
locals_dct.update(__eq__=self.eq)
|
2151
|
+
return self
|
2152
|
+
|
2153
|
+
|
2154
|
+
attr_ops = AttrOps[ta.Any]
|
2155
|
+
|
2156
|
+
|
2157
|
+
##
|
2158
|
+
|
2159
|
+
|
2160
|
+
def attr_repr(obj: ta.Any, *attrs: str, **kwargs: ta.Any) -> str:
|
2161
|
+
return AttrOps(*attrs, **kwargs).repr(obj)
|
2162
|
+
|
2163
|
+
|
1833
2164
|
########################################
|
1834
2165
|
# ../../../omlish/lite/cached.py
|
1835
2166
|
|
@@ -1848,7 +2179,7 @@ class _AbstractCachedNullary:
|
|
1848
2179
|
def __call__(self, *args, **kwargs): # noqa
|
1849
2180
|
raise TypeError
|
1850
2181
|
|
1851
|
-
def __get__(self, instance, owner): # noqa
|
2182
|
+
def __get__(self, instance, owner=None): # noqa
|
1852
2183
|
bound = instance.__dict__[self._fn.__name__] = self.__class__(self._fn.__get__(instance, owner))
|
1853
2184
|
return bound
|
1854
2185
|
|
@@ -2409,13 +2740,6 @@ json_dump_compact: ta.Callable[..., None] = functools.partial(json.dump, **JSON_
|
|
2409
2740
|
json_dumps_compact: ta.Callable[..., str] = functools.partial(json.dumps, **JSON_COMPACT_KWARGS)
|
2410
2741
|
|
2411
2742
|
|
2412
|
-
########################################
|
2413
|
-
# ../../../omlish/lite/logs.py
|
2414
|
-
|
2415
|
-
|
2416
|
-
log = logging.getLogger(__name__)
|
2417
|
-
|
2418
|
-
|
2419
2743
|
########################################
|
2420
2744
|
# ../../../omlish/lite/objects.py
|
2421
2745
|
|
@@ -2661,13 +2985,6 @@ def split_keep_delimiter(s, d):
|
|
2661
2985
|
##
|
2662
2986
|
|
2663
2987
|
|
2664
|
-
def attr_repr(obj: ta.Any, *attrs: str) -> str:
|
2665
|
-
return f'{type(obj).__name__}({", ".join(f"{attr}={getattr(obj, attr)!r}" for attr in attrs)})'
|
2666
|
-
|
2667
|
-
|
2668
|
-
##
|
2669
|
-
|
2670
|
-
|
2671
2988
|
FORMAT_NUM_BYTES_SUFFIXES: ta.Sequence[str] = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB']
|
2672
2989
|
|
2673
2990
|
|
@@ -2742,13 +3059,24 @@ def typing_annotations_attr() -> str:
|
|
2742
3059
|
|
2743
3060
|
|
2744
3061
|
########################################
|
2745
|
-
# ../../../omlish/logs/
|
3062
|
+
# ../../../omlish/logs/modules.py
|
2746
3063
|
|
2747
3064
|
|
2748
3065
|
##
|
2749
3066
|
|
2750
3067
|
|
2751
|
-
|
3068
|
+
def get_module_logger(mod_globals: ta.Mapping[str, ta.Any]) -> logging.Logger:
|
3069
|
+
return logging.getLogger(mod_globals.get('__name__'))
|
3070
|
+
|
3071
|
+
|
3072
|
+
########################################
|
3073
|
+
# ../../../omlish/logs/std/filters.py
|
3074
|
+
|
3075
|
+
|
3076
|
+
##
|
3077
|
+
|
3078
|
+
|
3079
|
+
class TidLoggingFilter(logging.Filter):
|
2752
3080
|
def filter(self, record):
|
2753
3081
|
# FIXME: handle better - missing from wasm and cosmos
|
2754
3082
|
if hasattr(threading, 'get_native_id'):
|
@@ -2759,13 +3087,13 @@ class TidLogFilter(logging.Filter):
|
|
2759
3087
|
|
2760
3088
|
|
2761
3089
|
########################################
|
2762
|
-
# ../../../omlish/logs/proxy.py
|
3090
|
+
# ../../../omlish/logs/std/proxy.py
|
2763
3091
|
|
2764
3092
|
|
2765
3093
|
##
|
2766
3094
|
|
2767
3095
|
|
2768
|
-
class
|
3096
|
+
class ProxyLoggingFilterer(logging.Filterer):
|
2769
3097
|
def __init__(self, underlying: logging.Filterer) -> None: # noqa
|
2770
3098
|
self._underlying = underlying
|
2771
3099
|
|
@@ -2791,9 +3119,9 @@ class ProxyLogFilterer(logging.Filterer):
|
|
2791
3119
|
return self._underlying.filter(record)
|
2792
3120
|
|
2793
3121
|
|
2794
|
-
class
|
3122
|
+
class ProxyLoggingHandler(ProxyLoggingFilterer, logging.Handler):
|
2795
3123
|
def __init__(self, underlying: logging.Handler) -> None: # noqa
|
2796
|
-
|
3124
|
+
ProxyLoggingFilterer.__init__(self, underlying)
|
2797
3125
|
|
2798
3126
|
_underlying: logging.Handler
|
2799
3127
|
|
@@ -5643,6 +5971,7 @@ class _Maybe(Maybe[T], Abstract):
|
|
5643
5971
|
return op and not sp
|
5644
5972
|
|
5645
5973
|
|
5974
|
+
@ta.final
|
5646
5975
|
class _JustMaybe(_Maybe[T]):
|
5647
5976
|
__slots__ = ('_v', '_hash')
|
5648
5977
|
|
@@ -5680,6 +6009,7 @@ class _JustMaybe(_Maybe[T]):
|
|
5680
6009
|
)
|
5681
6010
|
|
5682
6011
|
|
6012
|
+
@ta.final
|
5683
6013
|
class _EmptyMaybe(_Maybe[T]):
|
5684
6014
|
__slots__ = ()
|
5685
6015
|
|
@@ -5726,7 +6056,7 @@ def check_lite_runtime_version() -> None:
|
|
5726
6056
|
|
5727
6057
|
|
5728
6058
|
########################################
|
5729
|
-
# ../../../omlish/logs/json.py
|
6059
|
+
# ../../../omlish/logs/std/json.py
|
5730
6060
|
"""
|
5731
6061
|
TODO:
|
5732
6062
|
- translate json keys
|
@@ -5736,7 +6066,7 @@ TODO:
|
|
5736
6066
|
##
|
5737
6067
|
|
5738
6068
|
|
5739
|
-
class
|
6069
|
+
class JsonLoggingFormatter(logging.Formatter):
|
5740
6070
|
KEYS: ta.Mapping[str, bool] = {
|
5741
6071
|
'name': False,
|
5742
6072
|
'msg': False,
|
@@ -5855,7 +6185,7 @@ SD_LOG_LEVEL_MAP: ta.Mapping[int, int] = {
|
|
5855
6185
|
}
|
5856
6186
|
|
5857
6187
|
|
5858
|
-
class
|
6188
|
+
class JournaldLoggingHandler(logging.Handler):
|
5859
6189
|
"""
|
5860
6190
|
TODO:
|
5861
6191
|
- fallback handler for when this barfs
|
@@ -5924,7 +6254,7 @@ class JournaldLogHandler(logging.Handler):
|
|
5924
6254
|
self.handleError(record)
|
5925
6255
|
|
5926
6256
|
|
5927
|
-
def
|
6257
|
+
def journald_logging_handler_factory(
|
5928
6258
|
*,
|
5929
6259
|
no_tty_check: bool = False,
|
5930
6260
|
no_fallback: bool = False,
|
@@ -5934,7 +6264,7 @@ def journald_log_handler_factory(
|
|
5934
6264
|
(no_tty_check or not sys.stderr.isatty()) and
|
5935
6265
|
(no_fallback or sd_try_libsystemd() is not None)
|
5936
6266
|
):
|
5937
|
-
return
|
6267
|
+
return JournaldLoggingHandler()
|
5938
6268
|
|
5939
6269
|
return logging.StreamHandler()
|
5940
6270
|
|
@@ -7735,6 +8065,7 @@ inj = InjectionApi()
|
|
7735
8065
|
# ../../../omlish/logs/standard.py
|
7736
8066
|
"""
|
7737
8067
|
TODO:
|
8068
|
+
- !! move to std !!
|
7738
8069
|
- structured
|
7739
8070
|
- prefixed
|
7740
8071
|
- debug
|
@@ -7756,7 +8087,7 @@ STANDARD_LOG_FORMAT_PARTS = [
|
|
7756
8087
|
]
|
7757
8088
|
|
7758
8089
|
|
7759
|
-
class
|
8090
|
+
class StandardLoggingFormatter(logging.Formatter):
|
7760
8091
|
@staticmethod
|
7761
8092
|
def build_log_format(parts: ta.Iterable[ta.Tuple[str, str]]) -> str:
|
7762
8093
|
return ' '.join(v for k, v in parts)
|
@@ -7775,7 +8106,7 @@ class StandardLogFormatter(logging.Formatter):
|
|
7775
8106
|
##
|
7776
8107
|
|
7777
8108
|
|
7778
|
-
class
|
8109
|
+
class StandardConfiguredLoggingHandler(ProxyLoggingHandler):
|
7779
8110
|
def __init_subclass__(cls, **kwargs):
|
7780
8111
|
raise TypeError('This class serves only as a marker and should not be subclassed.')
|
7781
8112
|
|
@@ -7808,7 +8139,7 @@ def configure_standard_logging(
|
|
7808
8139
|
target: ta.Optional[logging.Logger] = None,
|
7809
8140
|
force: bool = False,
|
7810
8141
|
handler_factory: ta.Optional[ta.Callable[[], logging.Handler]] = None,
|
7811
|
-
) -> ta.Optional[
|
8142
|
+
) -> ta.Optional[StandardConfiguredLoggingHandler]:
|
7812
8143
|
with _locking_logging_module_lock():
|
7813
8144
|
if target is None:
|
7814
8145
|
target = logging.root
|
@@ -7816,7 +8147,7 @@ def configure_standard_logging(
|
|
7816
8147
|
#
|
7817
8148
|
|
7818
8149
|
if not force:
|
7819
|
-
if any(isinstance(h,
|
8150
|
+
if any(isinstance(h, StandardConfiguredLoggingHandler) for h in list(target.handlers)):
|
7820
8151
|
return None
|
7821
8152
|
|
7822
8153
|
#
|
@@ -7830,14 +8161,14 @@ def configure_standard_logging(
|
|
7830
8161
|
|
7831
8162
|
formatter: logging.Formatter
|
7832
8163
|
if json:
|
7833
|
-
formatter =
|
8164
|
+
formatter = JsonLoggingFormatter()
|
7834
8165
|
else:
|
7835
|
-
formatter =
|
8166
|
+
formatter = StandardLoggingFormatter(StandardLoggingFormatter.build_log_format(STANDARD_LOG_FORMAT_PARTS))
|
7836
8167
|
handler.setFormatter(formatter)
|
7837
8168
|
|
7838
8169
|
#
|
7839
8170
|
|
7840
|
-
handler.addFilter(
|
8171
|
+
handler.addFilter(TidLoggingFilter())
|
7841
8172
|
|
7842
8173
|
#
|
7843
8174
|
|
@@ -7850,7 +8181,7 @@ def configure_standard_logging(
|
|
7850
8181
|
|
7851
8182
|
#
|
7852
8183
|
|
7853
|
-
return
|
8184
|
+
return StandardConfiguredLoggingHandler(handler)
|
7854
8185
|
|
7855
8186
|
|
7856
8187
|
########################################
|
@@ -8639,6 +8970,9 @@ class Dispatchers(KeyedCollection[Fd, FdioHandler]):
|
|
8639
8970
|
# ../dispatchersimpl.py
|
8640
8971
|
|
8641
8972
|
|
8973
|
+
log = get_module_logger(globals()) # noqa
|
8974
|
+
|
8975
|
+
|
8642
8976
|
##
|
8643
8977
|
|
8644
8978
|
|
@@ -9066,6 +9400,9 @@ class PidHistory(ta.Dict[Pid, Process]):
|
|
9066
9400
|
# ../setupimpl.py
|
9067
9401
|
|
9068
9402
|
|
9403
|
+
log = get_module_logger(globals()) # noqa
|
9404
|
+
|
9405
|
+
|
9069
9406
|
##
|
9070
9407
|
|
9071
9408
|
|
@@ -9540,6 +9877,9 @@ class ProcessGroupManager(
|
|
9540
9877
|
# ../io.py
|
9541
9878
|
|
9542
9879
|
|
9880
|
+
log = get_module_logger(globals()) # noqa
|
9881
|
+
|
9882
|
+
|
9543
9883
|
##
|
9544
9884
|
|
9545
9885
|
|
@@ -9788,6 +10128,9 @@ class ProcessSpawningFactory(Func1[Process, ProcessSpawning]):
|
|
9788
10128
|
pass
|
9789
10129
|
|
9790
10130
|
|
10131
|
+
log = get_module_logger(globals()) # noqa
|
10132
|
+
|
10133
|
+
|
9791
10134
|
##
|
9792
10135
|
|
9793
10136
|
|
@@ -10264,6 +10607,9 @@ class ProcessImpl(Process):
|
|
10264
10607
|
# ../signals.py
|
10265
10608
|
|
10266
10609
|
|
10610
|
+
log = get_module_logger(globals()) # noqa
|
10611
|
+
|
10612
|
+
|
10267
10613
|
##
|
10268
10614
|
|
10269
10615
|
|
@@ -10636,6 +10982,9 @@ def check_execv_args(
|
|
10636
10982
|
# ../supervisor.py
|
10637
10983
|
|
10638
10984
|
|
10985
|
+
log = get_module_logger(globals()) # noqa
|
10986
|
+
|
10987
|
+
|
10639
10988
|
##
|
10640
10989
|
|
10641
10990
|
|
@@ -11023,7 +11372,7 @@ def main(
|
|
11023
11372
|
if not no_logging:
|
11024
11373
|
configure_standard_logging(
|
11025
11374
|
'INFO',
|
11026
|
-
handler_factory=
|
11375
|
+
handler_factory=journald_logging_handler_factory if not (args.no_journald or is_debugger_attached()) else None, # noqa
|
11027
11376
|
)
|
11028
11377
|
|
11029
11378
|
#
|
@@ -5,7 +5,7 @@ import os
|
|
5
5
|
import typing as ta
|
6
6
|
|
7
7
|
from omlish.lite.abstract import Abstract
|
8
|
-
from omlish.
|
8
|
+
from omlish.logs.modules import get_module_logger
|
9
9
|
|
10
10
|
from .configs import ProcessConfig
|
11
11
|
from .configs import ServerConfig
|
@@ -26,6 +26,9 @@ from .utils.strings import find_prefix_at_end
|
|
26
26
|
from .utils.strings import strip_escapes
|
27
27
|
|
28
28
|
|
29
|
+
log = get_module_logger(globals()) # noqa
|
30
|
+
|
31
|
+
|
29
32
|
##
|
30
33
|
|
31
34
|
|
ominfra/supervisor/io.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
import typing as ta
|
3
3
|
|
4
4
|
from omlish.io.fdio.pollers import FdioPoller
|
5
|
-
from omlish.
|
5
|
+
from omlish.logs.modules import get_module_logger
|
6
6
|
|
7
7
|
from .dispatchers import Dispatchers
|
8
8
|
from .types import ExitNow
|
@@ -10,6 +10,9 @@ from .types import HasDispatchers
|
|
10
10
|
from .utils.ostypes import Fd
|
11
11
|
|
12
12
|
|
13
|
+
log = get_module_logger(globals()) # noqa
|
14
|
+
|
15
|
+
|
13
16
|
##
|
14
17
|
|
15
18
|
|
ominfra/supervisor/main.py
CHANGED
@@ -42,7 +42,7 @@ from omlish.lite.configs import load_config_file_obj
|
|
42
42
|
from omlish.lite.inject import inj
|
43
43
|
from omlish.lite.runtime import is_debugger_attached
|
44
44
|
from omlish.logs.standard import configure_standard_logging
|
45
|
-
from omlish.os.journald import
|
45
|
+
from omlish.os.journald import journald_logging_handler_factory
|
46
46
|
|
47
47
|
from .configs import ServerConfig
|
48
48
|
from .configs import prepare_server_config
|
@@ -83,7 +83,7 @@ def main(
|
|
83
83
|
if not no_logging:
|
84
84
|
configure_standard_logging(
|
85
85
|
'INFO',
|
86
|
-
handler_factory=
|
86
|
+
handler_factory=journald_logging_handler_factory if not (args.no_journald or is_debugger_attached()) else None, # noqa
|
87
87
|
)
|
88
88
|
|
89
89
|
#
|
@@ -7,8 +7,8 @@ import traceback
|
|
7
7
|
import typing as ta
|
8
8
|
|
9
9
|
from omlish.lite.check import check
|
10
|
-
from omlish.lite.logs import log
|
11
10
|
from omlish.lite.typing import Func1
|
11
|
+
from omlish.logs.modules import get_module_logger
|
12
12
|
|
13
13
|
from .configs import ProcessConfig
|
14
14
|
from .configs import RestartUnconditionally
|
@@ -36,6 +36,9 @@ class ProcessSpawningFactory(Func1[Process, ProcessSpawning]):
|
|
36
36
|
pass
|
37
37
|
|
38
38
|
|
39
|
+
log = get_module_logger(globals()) # noqa
|
40
|
+
|
41
|
+
|
39
42
|
##
|
40
43
|
|
41
44
|
|