tealdeer-rs / tealdeer

A very fast implementation of tldr in Rust.
https://tealdeer-rs.github.io/tealdeer/
Apache License 2.0
4.17k stars 123 forks source link

Add helper functions: print_warning / print_error #223

Closed dbrgn closed 2 years ago

dbrgn commented 2 years ago

These functions prepend a consistend prefix and they also use colors (when enabled).

Messages are written to stderr.

dbrgn commented 2 years ago

Hm, I think logging and regular program output should be separate. We don't use an info-level logger to print the tldr pages either. For me, logging should be about "what the program is doing", and not be part of an end user API. On the other hand, the warning about missing cache is not something that should be hidden by a logger reconfiguration.

Having the function like this means that we need to use format! at call sites instead of having the flexibility of a eprintln or so.

Well, that's not really something we need an external library for. We can easily convert those functions to a macro. However, in the interest of getting out a release soon, I'd postpone that for now 🙂