From 9c85bd262e6ff204e5754a6707153653b70beaa8 Mon Sep 17 00:00:00 2001 From: Philip Sampaio Date: Wed, 4 Oct 2023 21:47:15 -0300 Subject: [PATCH] Change log level from "info" to "debug" (#488) Closes https://github.com/philss/floki/issues/481 --- README.md | 8 ++++++++ lib/floki/finder.ex | 2 -- lib/floki/selector.ex | 2 +- lib/floki/selector/parser.ex | 6 +++--- lib/floki/selector/pseudo_class.ex | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2e175479..2960ef2f 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,14 @@ There are also some selectors based on non-standard specifications. They are: | E:fl-contains('foo') | an E element that contains "foo" inside a text node | | E:fl-icontains('foo') | an E element that contains "foo" inside a text node (case insensitive) | +## Suppressing log messages + +Floki may log debug messages related to problems in the parsing of selectors, or parsing of the HTML tree. +It also may log some "info" messages related to deprecated APIs. If you want to suppress these log messages, +please consider setting the `:compile_time_purge_matching` option for `:logger` in your compile time configuration. + +See https://hexdocs.pm/logger/Logger.html#module-compile-configuration for details. + ## Special thanks * [@arasatasaygin](https://github.com/arasatasaygin) for Floki's logo from the [Open Logos project](http://openlogos.org/). diff --git a/lib/floki/finder.ex b/lib/floki/finder.ex index 931d674b..3c893019 100644 --- a/lib/floki/finder.ex +++ b/lib/floki/finder.ex @@ -1,6 +1,4 @@ defmodule Floki.Finder do - require Logger - @moduledoc false # The finder engine traverse the HTML tree searching for nodes matching diff --git a/lib/floki/selector.ex b/lib/floki/selector.ex index b679684f..706e1659 100644 --- a/lib/floki/selector.ex +++ b/lib/floki/selector.ex @@ -229,7 +229,7 @@ defmodule Floki.Selector do end defp pseudo_class_match?(_html_node, %{name: unknown_pseudo_class}, _tree) do - Logger.info(fn -> + Logger.debug(fn -> "Pseudo-class #{inspect(unknown_pseudo_class)} is not implemented. Ignoring." end) diff --git a/lib/floki/selector/parser.ex b/lib/floki/selector/parser.ex index 7e483362..8ef96d2b 100644 --- a/lib/floki/selector/parser.ex +++ b/lib/floki/selector/parser.ex @@ -143,7 +143,7 @@ defmodule Floki.Selector.Parser do end defp do_parse([{:unknown, _, unknown} | t], selector) do - Logger.info(fn -> "Unknown token #{inspect(unknown)}. Ignoring." end) + Logger.debug(fn -> "Unknown token #{inspect(unknown)}. Ignoring." end) do_parse(t, selector) end @@ -179,7 +179,7 @@ defmodule Floki.Selector.Parser do end defp consume_attribute(:consuming, [unknown | t], attr_selector) do - Logger.info(fn -> "Unknown token #{inspect(unknown)}. Ignoring." end) + Logger.debug(fn -> "Unknown token #{inspect(unknown)}. Ignoring." end) consume_attribute(:consuming, t, attr_selector) end @@ -264,7 +264,7 @@ defmodule Floki.Selector.Parser do end defp update_pseudo_not_value(_pseudo_class, _pseudo_not_selector) do - Logger.info("Only simple selectors are allowed in :not() pseudo-class. Ignoring.") + Logger.debug("Only simple selectors are allowed in :not() pseudo-class. Ignoring.") nil end end diff --git a/lib/floki/selector/pseudo_class.ex b/lib/floki/selector/pseudo_class.ex index d0d75ca8..42ef0f90 100644 --- a/lib/floki/selector/pseudo_class.ex +++ b/lib/floki/selector/pseudo_class.ex @@ -102,7 +102,7 @@ defmodule Floki.Selector.PseudoClass do relative_position in s expression -> - Logger.info(fn -> + Logger.debug(fn -> "Pseudo-class #{name} with expressions like #{inspect(expression)} are not supported yet. Ignoring." end)