[go: up one dir, main page]

paris 1.2.3

A simple logger for your CLI apps or other things you want in the terminal
Documentation
<h1 align="center">paris</h1>

<p align="center">Simple way to output beautiful text in your CLI applications. Only limit is your imagination.</p>


<p align="center">
   <img alt="Build status badge" src="https://github.com/0x20F/logger/workflows/build/badge.svg"/>
   <img alt="Crates io badge" src="https://img.shields.io/crates/v/paris.svg"/>
   <a href="https://www.gnu.org/licenses/gpl-3.0"><img alt="License badge" src="https://img.shields.io/badge/License-GPLv3-blue.svg"/></a>
</p>


<p align="center">
   <img src="https://github.com/0x20F/logger/blob/master/example/paris_example.gif"/>
</p>


## How to use
```toml
[dependencies]
paris = "1"
```

```rust
use paris::Logger;

// false to exclude timestamps
let mut log = Logger::new(false);

log.info("It's that simple!");
```


### Simple methods
```rust
// 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](https://docs.rs/paris/) 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.
```rust
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.
```rust
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)`.
```rust
// 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.
```rust
log.info("<blue><on bright red> This text is blue on a bright red background</> it's a pain");
```

###### Scroll down for a full list of keys if you're not feeling confident in your ability to name colors. It happens.

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 color to default"_ tag, You might
decide you don't ever want to use it. It's up to you.


## Color keys
To use a key just add the color name surrounded by `<`, `>` to your log string. Include spaces
or use underlines(`_`) or dashes(`-`) instead if you wish.

#### Foreground
`black`, `red`, `green`, `yellow`, `blue`, `cyan`, `magenta`, `white`

##### Bright
`bright black`, `bright red`, `bright green`, `bright yellow`, `bright blue`, `bright cyan`, `bright magenta`,
 `bright white`


#### Background
`on black`, `on red`, `on green`, `on yellow`, `on blue`, `on cyan`, `on magenta`, `on white`

##### Bright
`on bright black`, `on bright red`, `on bright green`, `on bright yellow`, `on bright blue`, `on bright cyan`, 
`on bright magenta`, `on bright white`

#### Styles
`bold`, `underline`, `dimmed`, `italic` 

#### Icons
`info`, `cross`, `warn`, `tick`, `heart`