smokestack: add colours

This commit is contained in:
Astro 2022-11-17 00:08:39 +01:00
parent 0d179e3624
commit 52c5597459
3 changed files with 17 additions and 13 deletions

10
Cargo.lock generated
View File

@ -26,6 +26,15 @@ dependencies = [
"libc",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "anyhow"
version = "1.0.66"
@ -316,6 +325,7 @@ dependencies = [
name = "caveman-smokestack"
version = "0.0.0"
dependencies = [
"ansi_term",
"cave",
"futures",
"log",

View File

@ -9,13 +9,6 @@ futures = "0.3"
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
# serde_yaml = "0.9"
# chrono = "0.4"
# redis = { version = "0.22", features = ["tokio-comp", "connection-manager"] }
log = "0.4"
cave = { path = "../cave" }
# hyper = { version = "0.14", features = ["stream"] }
# axum = "0.5"
# axum-macros = "0.2"
# axum-extra = { version = "0.3", features = ["spa"] }
# askama = "0.11"
ansi_term = "0.12"

View File

@ -5,6 +5,7 @@ use std::{
RwLock,
},
};
use ansi_term::Colour::*;
use futures::{Stream, StreamExt};
use tokio::{
io::AsyncWriteExt,
@ -62,11 +63,11 @@ fn format_message(post: Post) -> Option<String> {
let text = html_to_text(&post.content);
Some(format!(
"[{}] {} {} <@{}@{}>\r\n{}\r\n\r\n",
language,
time,
display_name,
username,
host,
Black.on(Red).paint(language),
Red.paint(time),
Yellow.bold().paint(display_name),
Yellow.underline().paint(username),
Yellow.underline().paint(host),
text,
))
}