[−][src]Crate paris
Simple way to output beautiful text in your CLI applications. Only limit is your imagination.
How to use
use paris::Logger; let mut log = Logger::new(); log.info("It's that simple!");
Simple methods
// You can have icons at the start of your message! log.info("Will add ℹ at the start"); log.error("Will add ✖ at the start");
See the Logger
struct for all methods
Chaining
All methods can be chained together to build more intricate log/message combinations, in hopes of minimizing the chaos that every log string becomes when you have to concatenate a bunch of strings and add tabs and newlines everywhere.
log.info("this is some info") .indent(4).warn("this is now indented by 4") .newline(5) .success("and this is 5 lines under all other messages");
Customisation
Outputting text is cool. Outputting text with a colored icon at the start is even cooler! But this crate is all about customisation, about making the logs feel like home, if you will. Included in the crate are a variety of keys you can use to colorize your logs just the way you want them to be.
log.info("I can write normal text or use tags to <red>color it</>"); log.warn("Every function can contain <on green><black>tags</>"); log.info("If you don't write them <bleu>correctly</>, you just get an ugly looking tag");
There's a key for all colors supported by the terminal (white, black, red, blue, magenta, etc.)
If you add the word on
to any of those colors, it becomes the
background color instead (on red, on blue, on green)
.
// How useful... log.info("<on red> This has red background </>");
Maybe you'd like to use your terminals brighter colors, if that's the case
you just have to add bright
to your tag. Makes sense.
log.info("<blue><on bright red> This text is blue on a bright red background</> it's a pain");
See the README for a full list of keys if you're not feeling confident in your ability to name colors. It happens.
Resetting
You've probably seen the </>
tag in the above logs. It's not there to
"close the previously opened tag" no no. You can open as many tags as you want
and only use </>
once, it's just the "reset everything to default" tag, You might
decide you don't ever want to use it. It's up to you.
However, resetting everything to default might not be what you want. Most of the time
it'll be enough, but for those times when it isn't there are a few other tags such as:
<///>
only resets the background<//>
only reset the foreground
Structs
Formatter | A wrapper around a few functions to make finding and replacing keys inside a string easier. |
Logger |
Enums
LogIcon | Contains definitions for icons that can be used in the terminal. See this github repo for an entire list. Use this in combination with printing macros. |