logger-36 2024.1__py3-none-any.whl → 2024.3__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.
- logger_36/__init__.py +2 -7
- logger_36/catalog/config/console_rich.py +49 -0
- logger_36/catalog/handler/console.py +80 -0
- logger_36/{type/console.py → catalog/handler/console_rich.py} +77 -52
- logger_36/catalog/handler/file.py +90 -0
- logger_36/catalog/handler/generic.py +150 -0
- logger_36/catalog/logging/chronos.py +39 -0
- logger_36/catalog/{gpu.py → logging/gpu.py} +3 -1
- logger_36/catalog/logging/memory.py +105 -0
- logger_36/catalog/{system.py → logging/system.py} +5 -27
- logger_36/config/issue.py +35 -0
- logger_36/config/memory.py +33 -0
- logger_36/{config.py → config/message.py} +14 -14
- logger_36/config/system.py +49 -0
- logger_36/constant/generic.py +37 -0
- logger_36/constant/handler.py +35 -0
- logger_36/constant/issue.py +35 -0
- logger_36/{type/file.py → constant/logger.py} +13 -15
- logger_36/constant/memory.py +39 -0
- logger_36/{constant.py → constant/message.py} +11 -15
- logger_36/constant/record.py +35 -0
- logger_36/constant/system.py +39 -0
- logger_36/instance.py +5 -5
- logger_36/main.py +130 -32
- logger_36/{catalog → task/format}/memory.py +34 -33
- logger_36/task/format/message.py +112 -0
- logger_36/task/format/rule.py +47 -0
- logger_36/task/inspection.py +18 -18
- logger_36/{measure → task/measure}/chronos.py +4 -2
- logger_36/task/storage.py +64 -3
- logger_36/type/extension.py +73 -61
- logger_36/type/issue.py +57 -0
- logger_36/type/logger.py +346 -0
- logger_36/version.py +1 -1
- {logger_36-2024.1.dist-info → logger_36-2024.3.dist-info}/METADATA +2 -3
- logger_36-2024.3.dist-info/RECORD +39 -0
- {logger_36-2024.1.dist-info → logger_36-2024.3.dist-info}/WHEEL +1 -1
- logger_36/type/generic.py +0 -115
- logger_36-2024.1.dist-info/RECORD +0 -21
- /logger_36/{measure → task/measure}/memory.py +0 -0
- {logger_36-2024.1.dist-info → logger_36-2024.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
# Copyright CNRS/Inria/UCA
|
2
|
+
# Contributor(s): Eric Debreuve (since 2023)
|
3
|
+
#
|
4
|
+
# eric.debreuve@cnrs.fr
|
5
|
+
#
|
6
|
+
# This software is governed by the CeCILL license under French law and
|
7
|
+
# abiding by the rules of distribution of free software. You can use,
|
8
|
+
# modify and/ or redistribute the software under the terms of the CeCILL
|
9
|
+
# license as circulated by CEA, CNRS and INRIA at the following URL
|
10
|
+
# "http://www.cecill.info".
|
11
|
+
#
|
12
|
+
# As a counterpart to the access to the source code and rights to copy,
|
13
|
+
# modify and redistribute granted by the license, users are provided only
|
14
|
+
# with a limited warranty and the software's author, the holder of the
|
15
|
+
# economic rights, and the successive licensors have only limited
|
16
|
+
# liability.
|
17
|
+
#
|
18
|
+
# In this respect, the user's attention is drawn to the risks associated
|
19
|
+
# with loading, using, modifying and/or developing or reproducing the
|
20
|
+
# software by the user in light of its specific status of free software,
|
21
|
+
# that may mean that it is complicated to manipulate, and that also
|
22
|
+
# therefore means that it is reserved for developers and experienced
|
23
|
+
# professionals having in-depth computer knowledge. Users are therefore
|
24
|
+
# encouraged to load and test the software's suitability as regards their
|
25
|
+
# requirements in conditions enabling the security of their systems and/or
|
26
|
+
# data to be ensured and, more generally, to use and operate it in the
|
27
|
+
# same conditions as regards security.
|
28
|
+
#
|
29
|
+
# The fact that you are presently reading this means that you have had
|
30
|
+
# knowledge of the CeCILL license and that you accept its terms.
|
31
|
+
|
32
|
+
from logger_36.config.memory import LENGTH_100, MAX_N_SAMPLES
|
33
|
+
from logger_36.constant.logger import HIDE_WHERE_KWARG
|
34
|
+
from logger_36.constant.memory import storage_units_h
|
35
|
+
from logger_36.instance import LOGGER
|
36
|
+
from logger_36.task.format.memory import FormattedUsage, UsageBar
|
37
|
+
from logger_36.task.format.message import FormattedMessage
|
38
|
+
|
39
|
+
|
40
|
+
def LogMemoryUsages(
|
41
|
+
*,
|
42
|
+
unit: storage_units_h | None = "a",
|
43
|
+
decimals: int = None,
|
44
|
+
max_n_samples: int | None = MAX_N_SAMPLES,
|
45
|
+
length_100: int = LENGTH_100,
|
46
|
+
) -> None:
|
47
|
+
""""""
|
48
|
+
if not LOGGER.any_handler_shows_memory:
|
49
|
+
return
|
50
|
+
|
51
|
+
where_s, usages = zip(*LOGGER.memory_usages)
|
52
|
+
|
53
|
+
where, max_usage = LOGGER.max_memory_usage_full
|
54
|
+
value, unit = FormattedUsage(max_usage, unit=unit, decimals=decimals)
|
55
|
+
title = f"Memory Usage: Max={value}{unit} near {where}\n"
|
56
|
+
|
57
|
+
if isinstance(max_n_samples, int):
|
58
|
+
if max_n_samples < 1:
|
59
|
+
raise ValueError(
|
60
|
+
FormattedMessage(
|
61
|
+
"Invalid maximum number of samples",
|
62
|
+
actual=max_n_samples,
|
63
|
+
expected=1,
|
64
|
+
expected_op=">=",
|
65
|
+
)
|
66
|
+
)
|
67
|
+
|
68
|
+
where_s = list(where_s)
|
69
|
+
usages = list(usages)
|
70
|
+
while usages.__len__() > max_n_samples:
|
71
|
+
index = usages.index(min(usages))
|
72
|
+
del where_s[index]
|
73
|
+
del usages[index]
|
74
|
+
|
75
|
+
usages = tuple(round(_elm, 1) for _elm in usages)
|
76
|
+
max_usage = max(usages)
|
77
|
+
|
78
|
+
plot = []
|
79
|
+
max_where_length = max(map(len, where_s))
|
80
|
+
usages_as_str = tuple(map(lambda _elm: f"{_elm:_}", usages))
|
81
|
+
max_usage_length = max(map(len, usages_as_str))
|
82
|
+
for where, usage, usage_as_str in zip(where_s, usages, usages_as_str):
|
83
|
+
bar = UsageBar(usage, max_usage, length_100=length_100)
|
84
|
+
plot.append(
|
85
|
+
f"{where:{max_where_length}} "
|
86
|
+
f"{bar:{length_100}} "
|
87
|
+
f"{usage_as_str: >{max_usage_length}}"
|
88
|
+
)
|
89
|
+
plot = "\n".join(plot)
|
90
|
+
|
91
|
+
LOGGER.info(title + plot, **HIDE_WHERE_KWARG)
|
92
|
+
|
93
|
+
|
94
|
+
def LogMaximumMemoryUsage(
|
95
|
+
*, unit: storage_units_h | None = "a", decimals: int = None
|
96
|
+
) -> None:
|
97
|
+
"""
|
98
|
+
unit: b or None=bytes, k=kilo, m=mega, g=giga, a=auto
|
99
|
+
"""
|
100
|
+
if LOGGER.any_handler_shows_memory:
|
101
|
+
where, max_usage = LOGGER.max_memory_usage_full
|
102
|
+
value, unit = FormattedUsage(max_usage, unit=unit, decimals=decimals)
|
103
|
+
LOGGER.info(
|
104
|
+
f"Max. Memory Usage: {value}{unit} near {where}", **HIDE_WHERE_KWARG
|
105
|
+
)
|
@@ -29,35 +29,11 @@
|
|
29
29
|
# The fact that you are presently reading this means that you have had
|
30
30
|
# knowledge of the CeCILL license and that you accept its terms.
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
from logger_36.constant.logger import HIDE_WHERE_KWARG
|
33
|
+
from logger_36.constant.system import MAX_DETAIL_NAME_LENGTH, SYSTEM_DETAILS_AS_DICT
|
34
34
|
from logger_36.instance import LOGGER
|
35
35
|
from logger_36.task.inspection import Modules
|
36
36
|
|
37
|
-
SYSTEM_DETAILS = (
|
38
|
-
"node",
|
39
|
-
"machine",
|
40
|
-
"processor",
|
41
|
-
"architecture",
|
42
|
-
#
|
43
|
-
"system",
|
44
|
-
"release",
|
45
|
-
"version",
|
46
|
-
"platform",
|
47
|
-
#
|
48
|
-
"python_implementation",
|
49
|
-
"python_version",
|
50
|
-
"python_revision",
|
51
|
-
"python_branch",
|
52
|
-
"python_compiler",
|
53
|
-
"python_build",
|
54
|
-
)
|
55
|
-
|
56
|
-
SYSTEM_DETAILS_AS_DICT = {
|
57
|
-
_dtl.capitalize(): getattr(pltf, _dtl)() for _dtl in SYSTEM_DETAILS
|
58
|
-
}
|
59
|
-
MAX_DETAIL_NAME_LENGTH = max(map(len, SYSTEM_DETAILS_AS_DICT.keys()))
|
60
|
-
|
61
37
|
|
62
38
|
def LogSystemDetails(
|
63
39
|
*,
|
@@ -74,11 +50,13 @@ def LogSystemDetails(
|
|
74
50
|
modules_with_version,
|
75
51
|
modules_formatted,
|
76
52
|
only_loaded=should_restrict_modules_to_loaded,
|
53
|
+
indent=4,
|
77
54
|
)
|
78
55
|
|
79
56
|
LOGGER.info(
|
80
57
|
f"SYSTEM DETAILS\n"
|
81
58
|
f"{details}\n"
|
82
59
|
f" {'Python Modules':>{MAX_DETAIL_NAME_LENGTH}}:\n"
|
83
|
-
f"
|
60
|
+
f"{modules}",
|
61
|
+
**HIDE_WHERE_KWARG,
|
84
62
|
)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright CNRS/Inria/UCA
|
2
|
+
# Contributor(s): Eric Debreuve (since 2023)
|
3
|
+
#
|
4
|
+
# eric.debreuve@cnrs.fr
|
5
|
+
#
|
6
|
+
# This software is governed by the CeCILL license under French law and
|
7
|
+
# abiding by the rules of distribution of free software. You can use,
|
8
|
+
# modify and/ or redistribute the software under the terms of the CeCILL
|
9
|
+
# license as circulated by CEA, CNRS and INRIA at the following URL
|
10
|
+
# "http://www.cecill.info".
|
11
|
+
#
|
12
|
+
# As a counterpart to the access to the source code and rights to copy,
|
13
|
+
# modify and redistribute granted by the license, users are provided only
|
14
|
+
# with a limited warranty and the software's author, the holder of the
|
15
|
+
# economic rights, and the successive licensors have only limited
|
16
|
+
# liability.
|
17
|
+
#
|
18
|
+
# In this respect, the user's attention is drawn to the risks associated
|
19
|
+
# with loading, using, modifying and/or developing or reproducing the
|
20
|
+
# software by the user in light of its specific status of free software,
|
21
|
+
# that may mean that it is complicated to manipulate, and that also
|
22
|
+
# therefore means that it is reserved for developers and experienced
|
23
|
+
# professionals having in-depth computer knowledge. Users are therefore
|
24
|
+
# encouraged to load and test the software's suitability as regards their
|
25
|
+
# requirements in conditions enabling the security of their systems and/or
|
26
|
+
# data to be ensured and, more generally, to use and operate it in the
|
27
|
+
# same conditions as regards security.
|
28
|
+
#
|
29
|
+
# The fact that you are presently reading this means that you have had
|
30
|
+
# knowledge of the CeCILL license and that you accept its terms.
|
31
|
+
|
32
|
+
ISSUE_BASE_CONTEXT = "BASE"
|
33
|
+
|
34
|
+
ISSUE_CONTEXT_SEPARATOR = ">"
|
35
|
+
ISSUE_CONTEXT_END = ":: "
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright CNRS/Inria/UCA
|
2
|
+
# Contributor(s): Eric Debreuve (since 2023)
|
3
|
+
#
|
4
|
+
# eric.debreuve@cnrs.fr
|
5
|
+
#
|
6
|
+
# This software is governed by the CeCILL license under French law and
|
7
|
+
# abiding by the rules of distribution of free software. You can use,
|
8
|
+
# modify and/ or redistribute the software under the terms of the CeCILL
|
9
|
+
# license as circulated by CEA, CNRS and INRIA at the following URL
|
10
|
+
# "http://www.cecill.info".
|
11
|
+
#
|
12
|
+
# As a counterpart to the access to the source code and rights to copy,
|
13
|
+
# modify and redistribute granted by the license, users are provided only
|
14
|
+
# with a limited warranty and the software's author, the holder of the
|
15
|
+
# economic rights, and the successive licensors have only limited
|
16
|
+
# liability.
|
17
|
+
#
|
18
|
+
# In this respect, the user's attention is drawn to the risks associated
|
19
|
+
# with loading, using, modifying and/or developing or reproducing the
|
20
|
+
# software by the user in light of its specific status of free software,
|
21
|
+
# that may mean that it is complicated to manipulate, and that also
|
22
|
+
# therefore means that it is reserved for developers and experienced
|
23
|
+
# professionals having in-depth computer knowledge. Users are therefore
|
24
|
+
# encouraged to load and test the software's suitability as regards their
|
25
|
+
# requirements in conditions enabling the security of their systems and/or
|
26
|
+
# data to be ensured and, more generally, to use and operate it in the
|
27
|
+
# same conditions as regards security.
|
28
|
+
#
|
29
|
+
# The fact that you are presently reading this means that you have had
|
30
|
+
# knowledge of the CeCILL license and that you accept its terms.
|
31
|
+
|
32
|
+
MAX_N_SAMPLES = 10
|
33
|
+
LENGTH_100 = 20
|
@@ -29,20 +29,20 @@
|
|
29
29
|
# The fact that you are presently reading this means that you have had
|
30
30
|
# knowledge of the CeCILL license and that you accept its terms.
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
LEVEL_CLOSING = "]"
|
36
|
-
CONTEXT_SEPARATOR = "- "
|
32
|
+
LEVEL_OPENING = "("
|
33
|
+
LEVEL_CLOSING = ")"
|
34
|
+
MESSAGE_MARKER = "| "
|
37
35
|
WHERE_SEPARATOR = "@"
|
38
36
|
ELAPSED_TIME_SEPARATOR = "+"
|
37
|
+
MEMORY_SEPARATOR = ":"
|
38
|
+
|
39
|
+
INTERCEPTED_LOG_SEPARATOR = " >>> "
|
40
|
+
|
41
|
+
DATE_FORMAT = "%Y-%m-%d"
|
42
|
+
TIME_FORMAT = "%H:%M:%S"
|
43
|
+
WHERE_FORMAT = f" {WHERE_SEPARATOR} {{module}}:{{funcName}}:{{lineno}}"
|
44
|
+
ELAPSED_TIME_FORMAT = f" {ELAPSED_TIME_SEPARATOR}%(elapsed_time)s"
|
45
|
+
MEMORY_FORMAT = f" {MEMORY_SEPARATOR}%(memory_usage)s"
|
39
46
|
|
40
|
-
|
41
|
-
|
42
|
-
f"{CONTEXT_SEPARATOR}"
|
43
|
-
f"%(message)s "
|
44
|
-
f"{WHERE_SEPARATOR} %(module)s:%(funcName)s:%(lineno)d "
|
45
|
-
f"{ELAPSED_TIME_SEPARATOR}%(elapsed_time)s"
|
46
|
-
f"%(memory_usage)s"
|
47
|
-
)
|
48
|
-
DATE_TIME_FORMAT = "%Y-%m-%d@%H:%M:%S"
|
47
|
+
ACTUAL_PATTERNS: str = r" Actual="
|
48
|
+
EXPECTED_PATTERNS: str = r" Expected([!<>]?=|: )"
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright CNRS/Inria/UCA
|
2
|
+
# Contributor(s): Eric Debreuve (since 2023)
|
3
|
+
#
|
4
|
+
# eric.debreuve@cnrs.fr
|
5
|
+
#
|
6
|
+
# This software is governed by the CeCILL license under French law and
|
7
|
+
# abiding by the rules of distribution of free software. You can use,
|
8
|
+
# modify and/ or redistribute the software under the terms of the CeCILL
|
9
|
+
# license as circulated by CEA, CNRS and INRIA at the following URL
|
10
|
+
# "http://www.cecill.info".
|
11
|
+
#
|
12
|
+
# As a counterpart to the access to the source code and rights to copy,
|
13
|
+
# modify and redistribute granted by the license, users are provided only
|
14
|
+
# with a limited warranty and the software's author, the holder of the
|
15
|
+
# economic rights, and the successive licensors have only limited
|
16
|
+
# liability.
|
17
|
+
#
|
18
|
+
# In this respect, the user's attention is drawn to the risks associated
|
19
|
+
# with loading, using, modifying and/or developing or reproducing the
|
20
|
+
# software by the user in light of its specific status of free software,
|
21
|
+
# that may mean that it is complicated to manipulate, and that also
|
22
|
+
# therefore means that it is reserved for developers and experienced
|
23
|
+
# professionals having in-depth computer knowledge. Users are therefore
|
24
|
+
# encouraged to load and test the software's suitability as regards their
|
25
|
+
# requirements in conditions enabling the security of their systems and/or
|
26
|
+
# data to be ensured and, more generally, to use and operate it in the
|
27
|
+
# same conditions as regards security.
|
28
|
+
#
|
29
|
+
# The fact that you are presently reading this means that you have had
|
30
|
+
# knowledge of the CeCILL license and that you accept its terms.
|
31
|
+
|
32
|
+
SYSTEM_DETAILS = (
|
33
|
+
"node",
|
34
|
+
"machine",
|
35
|
+
"processor",
|
36
|
+
"architecture",
|
37
|
+
#
|
38
|
+
"system",
|
39
|
+
"release",
|
40
|
+
"version",
|
41
|
+
"platform",
|
42
|
+
#
|
43
|
+
"python_implementation",
|
44
|
+
"python_version",
|
45
|
+
"python_revision",
|
46
|
+
"python_branch",
|
47
|
+
"python_compiler",
|
48
|
+
"python_build",
|
49
|
+
)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Copyright CNRS/Inria/UCA
|
2
|
+
# Contributor(s): Eric Debreuve (since 2023)
|
3
|
+
#
|
4
|
+
# eric.debreuve@cnrs.fr
|
5
|
+
#
|
6
|
+
# This software is governed by the CeCILL license under French law and
|
7
|
+
# abiding by the rules of distribution of free software. You can use,
|
8
|
+
# modify and/ or redistribute the software under the terms of the CeCILL
|
9
|
+
# license as circulated by CEA, CNRS and INRIA at the following URL
|
10
|
+
# "http://www.cecill.info".
|
11
|
+
#
|
12
|
+
# As a counterpart to the access to the source code and rights to copy,
|
13
|
+
# modify and redistribute granted by the license, users are provided only
|
14
|
+
# with a limited warranty and the software's author, the holder of the
|
15
|
+
# economic rights, and the successive licensors have only limited
|
16
|
+
# liability.
|
17
|
+
#
|
18
|
+
# In this respect, the user's attention is drawn to the risks associated
|
19
|
+
# with loading, using, modifying and/or developing or reproducing the
|
20
|
+
# software by the user in light of its specific status of free software,
|
21
|
+
# that may mean that it is complicated to manipulate, and that also
|
22
|
+
# therefore means that it is reserved for developers and experienced
|
23
|
+
# professionals having in-depth computer knowledge. Users are therefore
|
24
|
+
# encouraged to load and test the software's suitability as regards their
|
25
|
+
# requirements in conditions enabling the security of their systems and/or
|
26
|
+
# data to be ensured and, more generally, to use and operate it in the
|
27
|
+
# same conditions as regards security.
|
28
|
+
#
|
29
|
+
# The fact that you are presently reading this means that you have had
|
30
|
+
# knowledge of the CeCILL license and that you accept its terms.
|
31
|
+
|
32
|
+
|
33
|
+
class _not_passed_t:
|
34
|
+
pass
|
35
|
+
|
36
|
+
|
37
|
+
NOT_PASSED = _not_passed_t()
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright CNRS/Inria/UCA
|
2
|
+
# Contributor(s): Eric Debreuve (since 2023)
|
3
|
+
#
|
4
|
+
# eric.debreuve@cnrs.fr
|
5
|
+
#
|
6
|
+
# This software is governed by the CeCILL license under French law and
|
7
|
+
# abiding by the rules of distribution of free software. You can use,
|
8
|
+
# modify and/ or redistribute the software under the terms of the CeCILL
|
9
|
+
# license as circulated by CEA, CNRS and INRIA at the following URL
|
10
|
+
# "http://www.cecill.info".
|
11
|
+
#
|
12
|
+
# As a counterpart to the access to the source code and rights to copy,
|
13
|
+
# modify and redistribute granted by the license, users are provided only
|
14
|
+
# with a limited warranty and the software's author, the holder of the
|
15
|
+
# economic rights, and the successive licensors have only limited
|
16
|
+
# liability.
|
17
|
+
#
|
18
|
+
# In this respect, the user's attention is drawn to the risks associated
|
19
|
+
# with loading, using, modifying and/or developing or reproducing the
|
20
|
+
# software by the user in light of its specific status of free software,
|
21
|
+
# that may mean that it is complicated to manipulate, and that also
|
22
|
+
# therefore means that it is reserved for developers and experienced
|
23
|
+
# professionals having in-depth computer knowledge. Users are therefore
|
24
|
+
# encouraged to load and test the software's suitability as regards their
|
25
|
+
# requirements in conditions enabling the security of their systems and/or
|
26
|
+
# data to be ensured and, more generally, to use and operate it in the
|
27
|
+
# same conditions as regards security.
|
28
|
+
#
|
29
|
+
# The fact that you are presently reading this means that you have had
|
30
|
+
# knowledge of the CeCILL license and that you accept its terms.
|
31
|
+
|
32
|
+
import typing as h
|
33
|
+
|
34
|
+
handler_codes_h = h.Literal["g", "c", "f", "a"]
|
35
|
+
HANDLER_CODES: tuple[str, ...] = h.get_args(handler_codes_h)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright CNRS/Inria/UCA
|
2
|
+
# Contributor(s): Eric Debreuve (since 2023)
|
3
|
+
#
|
4
|
+
# eric.debreuve@cnrs.fr
|
5
|
+
#
|
6
|
+
# This software is governed by the CeCILL license under French law and
|
7
|
+
# abiding by the rules of distribution of free software. You can use,
|
8
|
+
# modify and/ or redistribute the software under the terms of the CeCILL
|
9
|
+
# license as circulated by CEA, CNRS and INRIA at the following URL
|
10
|
+
# "http://www.cecill.info".
|
11
|
+
#
|
12
|
+
# As a counterpart to the access to the source code and rights to copy,
|
13
|
+
# modify and redistribute granted by the license, users are provided only
|
14
|
+
# with a limited warranty and the software's author, the holder of the
|
15
|
+
# economic rights, and the successive licensors have only limited
|
16
|
+
# liability.
|
17
|
+
#
|
18
|
+
# In this respect, the user's attention is drawn to the risks associated
|
19
|
+
# with loading, using, modifying and/or developing or reproducing the
|
20
|
+
# software by the user in light of its specific status of free software,
|
21
|
+
# that may mean that it is complicated to manipulate, and that also
|
22
|
+
# therefore means that it is reserved for developers and experienced
|
23
|
+
# professionals having in-depth computer knowledge. Users are therefore
|
24
|
+
# encouraged to load and test the software's suitability as regards their
|
25
|
+
# requirements in conditions enabling the security of their systems and/or
|
26
|
+
# data to be ensured and, more generally, to use and operate it in the
|
27
|
+
# same conditions as regards security.
|
28
|
+
#
|
29
|
+
# The fact that you are presently reading this means that you have had
|
30
|
+
# knowledge of the CeCILL license and that you accept its terms.
|
31
|
+
|
32
|
+
import typing as h
|
33
|
+
|
34
|
+
order_h = h.Literal["when", "context"]
|
35
|
+
ORDER: tuple[str, ...] = h.get_args(order_h)
|
@@ -30,23 +30,21 @@
|
|
30
30
|
# knowledge of the CeCILL license and that you accept its terms.
|
31
31
|
|
32
32
|
import logging as lggg
|
33
|
-
|
33
|
+
import re as regx
|
34
|
+
import typing as h
|
34
35
|
|
35
|
-
from logger_36.
|
36
|
+
from logger_36.constant.record import HIDE_WHERE_ATTR
|
36
37
|
|
38
|
+
LOGGER_NAME = "logger-36"
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
handler_extension_t.__init__(self)
|
40
|
+
# https://docs.python.org/3/library/logging.html#logging.captureWarnings
|
41
|
+
WARNING_LOGGER_NAME = "py.warnings"
|
42
|
+
WARNING_TYPE_PATTERN = r"([^:]+):([0-9]+): ([^:]+): ([^\n]+)\n"
|
43
|
+
WARNING_TYPE_COMPILED_PATTERN = regx.compile(WARNING_TYPE_PATTERN)
|
43
44
|
|
44
|
-
|
45
|
+
HIDE_WHERE_KWARG = {"extra": {HIDE_WHERE_ATTR: True}}
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
self.stream.flush()
|
51
|
-
|
52
|
-
self.ExitOrNotIfError(record)
|
47
|
+
# Second version: with self as first parameter.
|
48
|
+
logger_handle_h = (
|
49
|
+
h.Callable[[lggg.LogRecord], None] | h.Callable[[lggg.Logger, lggg.LogRecord], None]
|
50
|
+
)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright CNRS/Inria/UCA
|
2
|
+
# Contributor(s): Eric Debreuve (since 2023)
|
3
|
+
#
|
4
|
+
# eric.debreuve@cnrs.fr
|
5
|
+
#
|
6
|
+
# This software is governed by the CeCILL license under French law and
|
7
|
+
# abiding by the rules of distribution of free software. You can use,
|
8
|
+
# modify and/ or redistribute the software under the terms of the CeCILL
|
9
|
+
# license as circulated by CEA, CNRS and INRIA at the following URL
|
10
|
+
# "http://www.cecill.info".
|
11
|
+
#
|
12
|
+
# As a counterpart to the access to the source code and rights to copy,
|
13
|
+
# modify and redistribute granted by the license, users are provided only
|
14
|
+
# with a limited warranty and the software's author, the holder of the
|
15
|
+
# economic rights, and the successive licensors have only limited
|
16
|
+
# liability.
|
17
|
+
#
|
18
|
+
# In this respect, the user's attention is drawn to the risks associated
|
19
|
+
# with loading, using, modifying and/or developing or reproducing the
|
20
|
+
# software by the user in light of its specific status of free software,
|
21
|
+
# that may mean that it is complicated to manipulate, and that also
|
22
|
+
# therefore means that it is reserved for developers and experienced
|
23
|
+
# professionals having in-depth computer knowledge. Users are therefore
|
24
|
+
# encouraged to load and test the software's suitability as regards their
|
25
|
+
# requirements in conditions enabling the security of their systems and/or
|
26
|
+
# data to be ensured and, more generally, to use and operate it in the
|
27
|
+
# same conditions as regards security.
|
28
|
+
#
|
29
|
+
# The fact that you are presently reading this means that you have had
|
30
|
+
# knowledge of the CeCILL license and that you accept its terms.
|
31
|
+
|
32
|
+
import typing as h
|
33
|
+
|
34
|
+
storage_units_h = h.Literal["b", "k", "m", "g", "a"]
|
35
|
+
STORAGE_UNITS: tuple[str, ...] = h.get_args(storage_units_h)
|
36
|
+
|
37
|
+
MEMORY_MEASURE_ERROR = (
|
38
|
+
"Cannot show memory usage: " 'Package "psutil" not installed or importable.'
|
39
|
+
)
|
@@ -29,24 +29,20 @@
|
|
29
29
|
# The fact that you are presently reading this means that you have had
|
30
30
|
# knowledge of the CeCILL license and that you accept its terms.
|
31
31
|
|
32
|
-
|
32
|
+
import time
|
33
|
+
import typing as h
|
33
34
|
|
34
|
-
from logger_36.config import (
|
35
|
-
CONTEXT_SEPARATOR,
|
36
|
-
DATE_TIME_FORMAT,
|
35
|
+
from logger_36.config.message import (
|
37
36
|
LEVEL_CLOSING,
|
38
37
|
LEVEL_OPENING,
|
38
|
+
MESSAGE_MARKER,
|
39
|
+
TIME_FORMAT,
|
39
40
|
)
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
TIME_LENGTH = time.strftime(TIME_FORMAT, time.gmtime(0)).__len__()
|
43
|
+
LOG_LEVEL_LENGTH = 1 + LEVEL_OPENING.__len__() + LEVEL_CLOSING.__len__()
|
44
|
+
CONTEXT_LENGTH = TIME_LENGTH + LOG_LEVEL_LENGTH
|
45
|
+
NEXT_LINE_PROLOGUE = "\n" + (CONTEXT_LENGTH + MESSAGE_MARKER.__len__() + 1) * " "
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
max(map(len, ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL")))
|
48
|
-
+ LEVEL_OPENING.__len__()
|
49
|
-
+ LEVEL_CLOSING.__len__()
|
50
|
-
)
|
51
|
-
CONTEXT_LENGTH = DATE_TIME_LENGTH + LOG_LEVEL_LENGTH
|
52
|
-
NEXT_LINE_PROLOGUE = "\n" + (CONTEXT_LENGTH + CONTEXT_SEPARATOR.__len__() + 1) * " "
|
47
|
+
expected_op_h = h.Literal[": ", "=", "!=", ">=", "<="]
|
48
|
+
EXPECTED_OP: tuple[str, ...] = h.get_args(expected_op_h)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright CNRS/Inria/UCA
|
2
|
+
# Contributor(s): Eric Debreuve (since 2023)
|
3
|
+
#
|
4
|
+
# eric.debreuve@cnrs.fr
|
5
|
+
#
|
6
|
+
# This software is governed by the CeCILL license under French law and
|
7
|
+
# abiding by the rules of distribution of free software. You can use,
|
8
|
+
# modify and/ or redistribute the software under the terms of the CeCILL
|
9
|
+
# license as circulated by CEA, CNRS and INRIA at the following URL
|
10
|
+
# "http://www.cecill.info".
|
11
|
+
#
|
12
|
+
# As a counterpart to the access to the source code and rights to copy,
|
13
|
+
# modify and redistribute granted by the license, users are provided only
|
14
|
+
# with a limited warranty and the software's author, the holder of the
|
15
|
+
# economic rights, and the successive licensors have only limited
|
16
|
+
# liability.
|
17
|
+
#
|
18
|
+
# In this respect, the user's attention is drawn to the risks associated
|
19
|
+
# with loading, using, modifying and/or developing or reproducing the
|
20
|
+
# software by the user in light of its specific status of free software,
|
21
|
+
# that may mean that it is complicated to manipulate, and that also
|
22
|
+
# therefore means that it is reserved for developers and experienced
|
23
|
+
# professionals having in-depth computer knowledge. Users are therefore
|
24
|
+
# encouraged to load and test the software's suitability as regards their
|
25
|
+
# requirements in conditions enabling the security of their systems and/or
|
26
|
+
# data to be ensured and, more generally, to use and operate it in the
|
27
|
+
# same conditions as regards security.
|
28
|
+
#
|
29
|
+
# The fact that you are presently reading this means that you have had
|
30
|
+
# knowledge of the CeCILL license and that you accept its terms.
|
31
|
+
|
32
|
+
SHOW_W_RULE_ATTR = "show_w_rule"
|
33
|
+
SHOW_WHERE_ATTR = "where"
|
34
|
+
HIDE_WHERE_ATTR = "hide_where"
|
35
|
+
SHOW_MEMORY_ATTR = "show_memory_usage"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright CNRS/Inria/UCA
|
2
|
+
# Contributor(s): Eric Debreuve (since 2023)
|
3
|
+
#
|
4
|
+
# eric.debreuve@cnrs.fr
|
5
|
+
#
|
6
|
+
# This software is governed by the CeCILL license under French law and
|
7
|
+
# abiding by the rules of distribution of free software. You can use,
|
8
|
+
# modify and/ or redistribute the software under the terms of the CeCILL
|
9
|
+
# license as circulated by CEA, CNRS and INRIA at the following URL
|
10
|
+
# "http://www.cecill.info".
|
11
|
+
#
|
12
|
+
# As a counterpart to the access to the source code and rights to copy,
|
13
|
+
# modify and redistribute granted by the license, users are provided only
|
14
|
+
# with a limited warranty and the software's author, the holder of the
|
15
|
+
# economic rights, and the successive licensors have only limited
|
16
|
+
# liability.
|
17
|
+
#
|
18
|
+
# In this respect, the user's attention is drawn to the risks associated
|
19
|
+
# with loading, using, modifying and/or developing or reproducing the
|
20
|
+
# software by the user in light of its specific status of free software,
|
21
|
+
# that may mean that it is complicated to manipulate, and that also
|
22
|
+
# therefore means that it is reserved for developers and experienced
|
23
|
+
# professionals having in-depth computer knowledge. Users are therefore
|
24
|
+
# encouraged to load and test the software's suitability as regards their
|
25
|
+
# requirements in conditions enabling the security of their systems and/or
|
26
|
+
# data to be ensured and, more generally, to use and operate it in the
|
27
|
+
# same conditions as regards security.
|
28
|
+
#
|
29
|
+
# The fact that you are presently reading this means that you have had
|
30
|
+
# knowledge of the CeCILL license and that you accept its terms.
|
31
|
+
|
32
|
+
import platform as pltf
|
33
|
+
|
34
|
+
from logger_36.config.system import SYSTEM_DETAILS
|
35
|
+
|
36
|
+
SYSTEM_DETAILS_AS_DICT = {
|
37
|
+
_dtl.capitalize(): getattr(pltf, _dtl)() for _dtl in SYSTEM_DETAILS
|
38
|
+
}
|
39
|
+
MAX_DETAIL_NAME_LENGTH = max(map(len, SYSTEM_DETAILS_AS_DICT.keys()))
|
logger_36/instance.py
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# Copyright CNRS/Inria/UCA
|
2
|
+
# Contributor(s): Eric Debreuve (since 2023)
|
3
|
+
#
|
1
4
|
# eric.debreuve@cnrs.fr
|
2
5
|
#
|
3
6
|
# This software is governed by the CeCILL license under French law and
|
@@ -26,9 +29,6 @@
|
|
26
29
|
# The fact that you are presently reading this means that you have had
|
27
30
|
# knowledge of the CeCILL license and that you accept its terms.
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
from logger_36.config import LOGGER_NAME
|
32
|
+
from logger_36.type.logger import logger_t
|
32
33
|
|
33
|
-
LOGGER =
|
34
|
-
LOGGER.setLevel(lggg.DEBUG)
|
34
|
+
LOGGER = logger_t()
|