telegram_webapp_sdk/
logger.rs1#[cfg(debug_assertions)]
5use web_sys::console;
6
7#[cfg_attr(not(debug_assertions), allow(unused_variables))]
9fn styled_log(level: &str, emoji: &str, color: &str, msg: &str) {
10 #[cfg(debug_assertions)]
11 {
12 let prefix = format!("%c[SDK] {} {}", emoji, level.to_uppercase());
13 let style = format!("color: {}; font-weight: bold", color);
14 console::log_3(&prefix.into(), &style.into(), &msg.into());
15 }
16}
17
18pub fn success(msg: &str) {
20 styled_log("success", "✅", "lightgreen", msg);
21}
22
23pub fn error(msg: &str) {
25 styled_log("error", "❌", "red", msg);
26}
27
28pub fn warn(msg: &str) {
30 styled_log("warn", "⚠️", "orange", msg);
31}
32
33pub fn info(msg: &str) {
35 styled_log("info", "ℹ️", "#3399ff", msg);
36}
37
38pub fn debug(msg: &str) {
40 styled_log("debug", "🔧", "#888", msg);
41}
42
43pub fn trace(msg: &str) {
45 styled_log("trace", "📍", "#aaa", msg);
46}