paris/lib.rs
1//! Simple way to output beautiful text in your
2//! CLI applications. Only limit is your imagination.
3//!
4//! # How to use
5//!
6//! # #[cfg(not(feature = "no_logger"))] {
7//! use paris::Logger;
8//!
9//! let mut log = Logger::new();
10//!
11//! log.info("It's that simple!");
12//! # }
13//!
14//! ### Simple api
15//!
16//! # #[cfg(not(feature = "no_logger"))] {
17//! # use paris::Logger;
18//! # let mut log = Logger::new();
19//! // You can have icons at the start of your message!
20//! log.info("Will add ℹ at the start");
21//! log.error("Will add ✖ at the start");
22//! # }
23//!
24//!
25//! # #[cfg(feature = "macros")] {
26//! # use paris::{ info, error };
27//!
28//! // or as macros
29//! info!("Will add ℹ at the start");
30//! error!("Will add ✖ at the start");
31//! # }
32//!
33//!
34//! See [the Logger struct](https://docs.rs/paris/) for all methods
35//!
36//!
37//! # Chaining
38//! All methods can be chained together to build more intricate
39//! log/message combinations, in hopes of minimizing the chaos
40//! that every log string becomes when you have to concatenate
41//! a bunch of strings and add tabs and newlines everywhere.
42//!
43//! # #[cfg(not(feature = "no_logger"))] {
44//! # use paris::Logger;
45//! # let mut log = Logger::new();
46//! log.info("this is some info")
47//! .indent(4).warn("this is now indented by 4")
48//! .newline(5)
49//! .success("and this is 5 lines under all other messages");
50//! # }
51//!
52//! # Customisation
53//! Outputting text is cool. Outputting text with a colored icon
54//! at the start is even cooler! But this crate is all about
55//! customisation, about making the logs feel like home, if you will.
56//! Included in the crate are a variety of keys you can use
57//! to colorize your logs just the way you want them to be.
58//!
59//! # #[cfg(not(feature = "no_logger"))] {
60//! # use paris::Logger;
61//! # let mut log = Logger::new();
62//! log.info("I can write normal text or use tags to <red>color it</>");
63//! log.warn("Every function can contain <on-green><black>tags</>");
64//!
65//! log.info("If you don't write them <what>correctly</>, you just get an ugly looking tag");
66//! # }
67//!
68//! There's a key for all colors supported by the terminal `(white, black, red, blue, magenta, etc.)`
69//! If you add the word `on` to any of those colors, it becomes the
70//! background color instead `(on red, on blue, on green)`.
71//!
72//! # #[cfg(not(feature = "no_logger"))] {
73//! # use paris::Logger;
74//! # let mut log = Logger::new();
75//! // How useful...
76//! log.info("<on-red> This has red background </>");
77//! # }
78//!
79//! Maybe you'd like to use your terminals brighter colors, if that's the case
80//! you just have to add `bright` to your tag. Makes sense.
81//!
82//! # #[cfg(not(feature = "no_logger"))] {
83//! # use paris::Logger;
84//! # let mut log = Logger::new();
85//! log.info("<blue><on-bright-red> This text is blue on a bright red background</> it's a pain");
86//! # }
87//!
88//! If you feel like writing a lot of colors by hand is too tedious, or if you know you're going
89//! to be using the same combination of colors over and over again you can create a `custom style`
90//! that encapsulates all those colors.
91//!
92//! # #[cfg(not(feature = "no_logger"))] {
93//! # use paris::Logger;
94//! # let mut log = Logger::new();
95//! log.add_style("lol", vec!["green", "bold", "on-bright-blue"]);
96//!
97//! // '<lol>' is now a key that you can use in your strings
98//! log.info("<lol>This is has all your new styles</>");
99//! # }
100//!
101//! See [the README](https://github.com/SirTheViking/logger/blob/master/README.md) for a full list of keys
102//! if you're not feeling confident in your ability to name colors. It happens.
103//!
104//! ### Resetting
105//! You've probably seen the `</>` tag in the above logs. It's not there to
106//! _"close the previously opened tag"_ no no. You can open as many tags as you want
107//! and only use `</>` once, it's just the _"reset everything to default"_ tag, You might
108//! decide you don't ever want to use it. It's up to you.
109
110//! However, resetting everything to default might not be what you want. Most of the time
111//! it'll be enough, but for those times when it isn't there are a few other tags such as:
112
113//! * `<///>` only resets the background
114//! * `<//>` only reset the foreground
115//!
116//! ### Macros
117//! With the macros feature enabled, you get access to macro equivalents
118//! of the logger functions.
119//!
120//! Advantages of using macros:
121//! * You don't have to instantiate the logger `Logger::new()`
122//! * Simple to write
123//! * Can format parameters like `print!` and `println!`
124//!
125//! Disadvantages of using macros:
126//! * Can't chain calls
127//! * Manual newlines and tabs with `\n` and `\t`
128//! * There's no loading animation for macros
129//!
130//! You get to decide whether you want to use macros or not.
131//! Every macro has the same functionality as its `Logger`
132//! equivalent. Colors and icon keys work just the same.
133//!
134//! See [the Logger struct](https://docs.rs/paris/) for all methods and their macro equivalents
135#![warn(missing_docs)]
136
137#[cfg(feature = "timestamps")]
138mod timestamp;
139
140#[cfg(feature = "macros")]
141mod macros;
142
143#[cfg(not(feature = "no_logger"))]
144mod logger;
145#[cfg(not(feature = "no_logger"))]
146pub use logger::Logger;
147
148pub mod formatter;
149pub mod output;
150
151pub use formatter::LogIcon;