1use std::fmt;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum LogKind {
6 Info,
7 Ok,
8 Ko,
9 Warning,
10}
11
12pub struct ConsoleLog;
14
15impl ConsoleLog {
16 pub fn log(kind: LogKind, msg: impl fmt::Display) {
18 match kind {
19 LogKind::Info => {
20 println!("\x1b[36m\u{2139} {}\x1b[0m", msg);
22 }
23 LogKind::Ok => {
24 println!("\x1b[32m\u{2705} {}\x1b[0m", msg);
26 }
27 LogKind::Ko => {
28 eprintln!("\x1b[31m\u{274C} {}\x1b[0m", msg);
30 }
31 LogKind::Warning => {
32 println!("\x1b[33m\u{26A0}\u{FE0F} {}\x1b[0m", msg);
34 }
35 }
36 }
37
38 pub fn info(msg: impl fmt::Display) {
39 Self::log(LogKind::Info, msg);
40 }
41
42 pub fn ok(msg: impl fmt::Display) {
43 Self::log(LogKind::Ok, msg);
44 }
45
46 pub fn ko(msg: impl fmt::Display) {
47 Self::log(LogKind::Ko, msg);
48 }
49
50 pub fn warn(msg: impl fmt::Display) {
51 Self::log(LogKind::Warning, msg);
52 }
53}