philss / floki

Floki is a simple HTML parser that enables search for nodes using CSS selectors.
https://hex.pm/packages/floki
MIT License
2.07k stars 156 forks source link

IO.puts bloat #63

Closed teamon closed 8 years ago

teamon commented 8 years ago

ref https://github.com/philss/floki/blob/ba3b1e3587e7fff90c38df1da7ede09f86d8fcf3/lib/floki/selector_parser.ex#L62-L63

How about

Logger.debug("[floki] Unknown token #{inspect unknown}. Ignoring.")

?

justgage commented 8 years ago

I'm not a maintainer but I'm curious how this is different or less "bloat"

teamon commented 8 years ago

@justgage If you set the logger level to info (or warn, or error) it won't be displayed.

justgage commented 8 years ago

Ah, makes sense

On Wed, Aug 24, 2016, 9:00 AM Tymon Tobolski notifications@github.com wrote:

@justgage https://github.com/justgage If you set the logger level to info (or warn, or error) it won't be displayed.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/philss/floki/issues/63#issuecomment-242095439, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKAwcyUcUQ2EVVeelxixnibOR6jTPlSks5qjFx7gaJpZM4JrU1Y .

philss commented 8 years ago

@teamon I agree with you. But I think this message should be a warn instead of debug. This is because the user may want to know that misspelled selectors are affecting the results of a given search.

I added this commit 5d4c0a9 that fixes the issue. I gonna release it soon.

Thank you! :)

illia-danko commented 1 year ago

@philss Hello back to this discussion and for sure indirectly connected to the topic itself, but is it possible to change logging level for the library only? I'm seeking for something like:

# in my app config/config.exs

config :floki, :logger, level: :error

Which could work from both develop and prod environments.

Any advice or workaround is welcome :)

philss commented 1 year ago

hey @illia-danko, I think you can use the :compile_time_purge_matching config from Logger. I recently added a note to the README.md about that: https://github.com/philss/floki#suppressing-log-messages I honestly didn't test it though. Please let me know if this works for you.

PS: I should release a new version soon, which is going to decrease the majority of messages to :debug. See https://github.com/philss/floki/pull/488

illia-danko commented 1 year ago

@philss I do not use log lever lower than info for development as well, and after a new 0.35.0 release I can set global logger level to info and the messages disappear. Thank you