diff --git a/package/logger_36/catalog/handler/generic.py b/package/logger_36/catalog/handler/generic.py index eac8063a9ac4104266b9bcface489050b5718e22..bb49dcbf93bfef3e891b2334791fe9f8faced531 100644 --- a/package/logger_36/catalog/handler/generic.py +++ b/package/logger_36/catalog/handler/generic.py @@ -57,7 +57,7 @@ class generic_handler_t(lggg.Handler): formatter: d.InitVar[lggg.Formatter | None] = None supports_html: d.InitVar[bool] = False - should_record: d.InitVar[bool] = (False,) + should_record: d.InitVar[bool] = False rich_kwargs: d.InitVar[dict[str, h.Any] | None] = None interface: d.InitVar[interface_h | None] = None # Cannot be None actually. diff --git a/package/logger_36/catalog/logger/exception.py b/package/logger_36/catalog/logger/exception.py deleted file mode 100644 index ac94259729c4b95fca94f9a15fe8119f2c1576e1..0000000000000000000000000000000000000000 --- a/package/logger_36/catalog/logger/exception.py +++ /dev/null @@ -1,74 +0,0 @@ -""" -Copyright CNRS/Inria/UniCA -Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023 -SEE COPYRIGHT NOTICE BELOW -""" - -import traceback as tcbk - -from logger_36.instance.logger import LOGGER -from logger_36.type.logger import logger_t - - -def LogException( - exception: Exception, - /, - *, - logger: logger_t = LOGGER, - should_remove_caller: bool = False, -) -> None: - """""" - lines = tcbk.format_exception(exception) - if should_remove_caller: - message = "\n".join(lines[:1] + lines[2:]) - else: - formatted = "".join(lines) - message = f"{type(exception).__name__}:\n{formatted}" - logger.error(message) - - -""" -COPYRIGHT NOTICE - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root. - -This software is being developed by Eric Debreuve, a CNRS employee and -member of team Morpheme. -Team Morpheme is a joint team between Inria, CNRS, and UniCA. -It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory -I3S, and Laboratory iBV. - -CNRS: https://www.cnrs.fr/index.php/en -Inria: https://www.inria.fr/en/ -UniCA: https://univ-cotedazur.eu/ -Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/ -I3S: https://www.i3s.unice.fr/en/ -iBV: http://ibv.unice.fr/ -Team Morpheme: https://team.inria.fr/morpheme/ -""" diff --git a/package/logger_36/logger.py b/package/logger_36/logger.py index 5f69ead14a4405b897f80964c458f890d3bb265c..41502a26fb96908461cbc1c4608c42e8dc54bf19 100644 --- a/package/logger_36/logger.py +++ b/package/logger_36/logger.py @@ -5,7 +5,6 @@ SEE COPYRIGHT NOTICE BELOW """ from logger_36.catalog.logger.chronos import LogElapsedTime -from logger_36.catalog.logger.exception import LogException from logger_36.catalog.logger.memory import LogMaximumMemoryUsage, LogMemoryUsages from logger_36.catalog.logger.system import LogSystemDetails diff --git a/package/logger_36/type/logger.py b/package/logger_36/type/logger.py index da0084956561aa8257f58ecc3e0e2ed88d772a61..2abe775a27ee08f89904d4d2f903743938e827bd 100644 --- a/package/logger_36/type/logger.py +++ b/package/logger_36/type/logger.py @@ -7,7 +7,7 @@ SEE COPYRIGHT NOTICE BELOW import dataclasses as d import logging as lggg import sys as sstm -import traceback as tbck +import traceback as tcbk import types as t import typing as h from datetime import datetime as dttm @@ -221,6 +221,22 @@ class logger_t(lggg.Logger): # __post_init__ set self.exit_on_critical if self.exit_on_error. sstm.exit(1) + def error_for_exception( + self, + exception: Exception, + /, + *, + should_remove_caller: bool = False, + ) -> None: + """""" + lines = tcbk.format_exception(exception) + if should_remove_caller: + message = "\n".join(lines[:1] + lines[2:]) + else: + formatted = "".join(lines) + message = f"{type(exception).__name__}:\n{formatted}" + self.error(message) + def AddContextLevel(self, new_level: str, /) -> None: """""" self.context_levels.append(new_level) @@ -292,11 +308,11 @@ class logger_t(lggg.Logger): try: raise level("\n" + issues) except Exception as exception: - lines = ["Traceback (most recent call last):"] + tbck.format_stack()[ + lines = ["Traceback (most recent call last):"] + tcbk.format_stack()[ :-1 ] lines[-1] = lines[-1][:-1] - lines.extend(tbck.format_exception_only(exception)) + lines.extend(tcbk.format_exception_only(exception)) print("\n".join(lines), file=sstm.stderr) sstm.exit(1) diff --git a/package/logger_36/version.py b/package/logger_36/version.py index 5bc58c70ff5a463b68f20eb13b19ebc34cd6df05..693c5839ee5dc487f0d00e4def1e7c2d4e7348d0 100644 --- a/package/logger_36/version.py +++ b/package/logger_36/version.py @@ -4,7 +4,7 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023 SEE COPYRIGHT NOTICE BELOW """ -__version__ = "2024.19" +__version__ = "2024.20" """ COPYRIGHT NOTICE