https://github.com/kkrypt0nn/tangra.rs
🪵 A lightweight and easy to use Rust logging library
https://github.com/kkrypt0nn/tangra.rs
library logging logging-library logs rust rust-lang rust-log rust-logging
Last synced: 3 months ago
JSON representation
🪵 A lightweight and easy to use Rust logging library
- Host: GitHub
- URL: https://github.com/kkrypt0nn/tangra.rs
- Owner: kkrypt0nn
- License: mit
- Created: 2023-10-26T21:01:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-19T18:26:43.000Z (4 months ago)
- Last Synced: 2025-03-19T19:31:42.088Z (4 months ago)
- Topics: library, logging, logging-library, logs, rust, rust-lang, rust-log, rust-logging
- Language: Rust
- Homepage:
- Size: 705 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# tangra.rs
[](https://crates.io/crates/tangra)
[](https://github.com/kkrypt0nn/tangra.rs/actions)
[](https://deps.rs/repo/github/kkrypt0nn/tangra.rs)[](https://github.com/kkrypt0nn/tangra.rs/commits/main)
[](https://conventionalcommits.org/en/v1.0.0/)---
A lightweight and easy to use Rust logging library that includes logging functionalities with different levels and
custom
formatting. It can also be used as a library to simply format the various messages you print in the terminal.## Showcase
### macOS

### Linux

### Windows

## Installation
If you want to use this library for one of your projects, you can install it like any other Go library
```shell
cargo add tangra
```## Customizing
### Prefix
The prefix, what comes before the message, can be changed with the `set_prefix` method on a `Logger` structure.
> The default prefix is `$[datetime] $[level:color]$[level:name]$[reset]: `
### Placeholders
There are formatting placeholders that will be replaced in both the message and the prefix that can be
seen [here](PLACEHOLDERS.md).[For example](examples), logging the following message
```
$[fg:red]$[effect:blink]$[effect:bold]$[sys:username] says hello!
```Will print a red blinking message in bold that says ` says hello!`, where `` is the username on your
system.### Styling
You can choose whether you want to style your messages or not with the `SetStyling` method on a `Logger` structure.
Styling includes foreground colors, background colors and special effects such as bold, and others - see
the [`terminal.rs`](src/terminal.rs) file.> **Note**: The styling will **not** apply to the message if it is not supported by the terminal.
### Log File
Logs can also be written inside a log file with styling removed. [For example](examples/file.rs):
```rs
fn main() {
let mut logger = tangra::Logger::new();
logger.set_log_file_path("example.log");
logger.debug("$[fg:red]$[effect:blink]$[effect:bold]$[sys:username] says hello!");
}
```## License
This library was made with 💜 by Krypton and is under the [MIT](LICENSE.md) license.