Skip to content

Commit

Permalink
cargo like logs
Browse files Browse the repository at this point in the history
  • Loading branch information
orzklv committed Nov 22, 2023
1 parent 9d9b7f5 commit 061f9e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crates_io_api::AsyncClient;
use rustina::{
handler,
utils::{github::GitHub, groups::Groups, resources::Resources},
utils::{github::GitHub, groups::Groups, resources::Resources, cargo_like_log},
};
use std::error::Error;
use teloxide::{prelude::*, update_listeners::webhooks};
Expand Down Expand Up @@ -38,7 +38,7 @@ async fn main() -> Result<(), Box<dyn Error>> {

match std::env::var("WEBHOOK_URL") {
Ok(v) => {
println!("Starting webhook on {}", v);
cargo_like_log("Mode", &format!("Starting webhook on {}", v));
let addr = ([0, 0, 0, 0], 8443).into(); // port 8443
let listener = webhooks::axum(bot, webhooks::Options::new(addr, v.parse().unwrap()))
.await
Expand All @@ -54,7 +54,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
.await;
}
Err(_) => {
println!("Starting polling...");
cargo_like_log("Mode", "Starting polling on localhost");
dispatcher.dispatch().await;
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@ pub mod inlines;
pub mod keyboard;
pub mod message;
pub mod resources;

pub fn cargo_like_log(title: &str, message: &str) {
println!("{}{}{}{} {} {}",
" ".repeat(12 - title.len()),
"\x1b[1;32m",
title,
"\x1b[0m",
message,
" ".repeat(8)
);
}

0 comments on commit 061f9e6

Please sign in to comment.