From 34eee39085cd5a3c801ba753cd822649cea806ea Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Fri, 3 Dec 2021 19:18:31 +0100 Subject: [PATCH 1/4] :wrench: Tweak/adjust the logging verbosity ge Warn lvl --- charset_normalizer/api.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/charset_normalizer/api.py b/charset_normalizer/api.py index 62ef1819..42503dd7 100644 --- a/charset_normalizer/api.py +++ b/charset_normalizer/api.py @@ -70,13 +70,13 @@ def from_bytes( if explain: previous_logger_level = logger.level # type: int logger.addHandler(explain_handler) - logger.setLevel(logging.INFO) + logger.setLevel(logging.DEBUG) length = len(sequences) # type: int if length == 0: logger.warning( - "Given content is empty, stopping the process very early, returning empty utf_8 str match" + "Encoding detection on empty bytes, assuming utf_8 intention." ) if explain: logger.removeHandler(explain_handler) @@ -84,7 +84,7 @@ def from_bytes( return CharsetMatches([CharsetMatch(sequences, "utf_8", 0.0, False, [], "")]) if cp_isolation is not None: - logger.warning( + logger.debug( "cp_isolation is set. use this flag for debugging purpose. " "limited list of encoding allowed : %s.", ", ".join(cp_isolation), @@ -94,7 +94,7 @@ def from_bytes( cp_isolation = [] if cp_exclusion is not None: - logger.warning( + logger.debug( "cp_exclusion is set. use this flag for debugging purpose. " "limited list of encoding excluded : %s.", ", ".join(cp_exclusion), @@ -104,7 +104,7 @@ def from_bytes( cp_exclusion = [] if length <= (chunk_size * steps): - logger.warning( + logger.debug( "override steps (%i) and chunk_size (%i) as content does not fit (%i byte(s) given) parameters.", steps, chunk_size, @@ -190,7 +190,7 @@ def from_bytes( ) # type: bool if encoding_iana in {"utf_16", "utf_32"} and not bom_or_sig_available: - logger.info( + logger.debug( "Encoding %s wont be tested as-is because it require a BOM. Will try some sub-encoder LE/BE.", encoding_iana, ) @@ -221,7 +221,7 @@ def from_bytes( ) except (UnicodeDecodeError, LookupError) as e: if not isinstance(e, LookupError): - logger.warning( + logger.debug( "Code page %s does not fit given bytes sequence at ALL. %s", encoding_iana, str(e), @@ -237,7 +237,7 @@ def from_bytes( break if similar_soft_failure_test: - logger.warning( + logger.info( "%s is deemed too similar to code page %s and was consider unsuited already. Continuing!", encoding_iana, encoding_soft_failed, @@ -332,7 +332,7 @@ def from_bytes( ) # type: float if mean_mess_ratio >= threshold or early_stop_count >= max_chunk_gave_up: tested_but_soft_failure.append(encoding_iana) - logger.warning( + logger.info( "%s was excluded because of initial chaos probing. Gave up %i time(s). " "Computed mean chaos is %f %%.", encoding_iana, From 307366f01b59bd3f55b95d64b8dfdb8d6dc10a69 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Fri, 3 Dec 2021 19:27:44 +0100 Subject: [PATCH 2/4] :wrench: Add codecov explicit config --- .codecov.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .codecov.yml diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 00000000..f307895e --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,8 @@ +coverage: + status: + project: + default: + target: 88% + threshold: null + patch: false + changes: false From 5c33d751473234bdbd8a1ba0dff8b6d274585ca0 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Fri, 3 Dec 2021 19:29:36 +0100 Subject: [PATCH 3/4] :pencil: Add CHANGELOG entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13f56b38..f778189a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - [Short description of non-trivial change.] +### Changed +- Moderating the logging impact (since 2.0.8) for specific environments (PR #147) + ### Fixed - Wrong logging level applied when setting kwarg `explain` to True (PR #146) From e7a7cc3014e7975ae8b837e5722c30237fb6100c Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Fri, 3 Dec 2021 19:31:39 +0100 Subject: [PATCH 4/4] :art: reformat api.py --- charset_normalizer/api.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/charset_normalizer/api.py b/charset_normalizer/api.py index 42503dd7..d9e5866a 100644 --- a/charset_normalizer/api.py +++ b/charset_normalizer/api.py @@ -75,9 +75,7 @@ def from_bytes( length = len(sequences) # type: int if length == 0: - logger.warning( - "Encoding detection on empty bytes, assuming utf_8 intention." - ) + logger.warning("Encoding detection on empty bytes, assuming utf_8 intention.") if explain: logger.removeHandler(explain_handler) logger.setLevel(previous_logger_level or logging.WARNING)