1use std::{env, thread};
2
3use anyhow::Error;
4use baselime::Level;
5
6pub mod baselime;
7
8pub fn error(data: &str, namespace: &str) -> Result<(), Error> {
9 if let Ok(_) = env::var("BASELIME_API_KEY") {
10 let data = data.to_string();
11 let namespace = namespace.to_string();
12 thread::spawn(move || {
13 let baselime_client = baselime::new();
14 match baselime_client.send(data, Level::Error, namespace) {
15 Ok(_) => {}
16 Err(e) => {
17 println!("Error: {}", e);
18 }
19 }
20 });
21 }
22 Ok(())
23}
24
25pub fn info(data: &str, namespace: &str) -> Result<(), Error> {
26 if let Ok(_) = env::var("BASELIME_API_KEY") {
27 let data = data.to_string();
28 let namespace = namespace.to_string();
29 thread::spawn(move || {
30 let baselime_client = baselime::new();
31 match baselime_client.send(data, Level::Info, namespace) {
32 Ok(_) => {}
33 Err(e) => {
34 println!("Error: {}", e);
35 }
36 }
37 });
38 }
39 Ok(())
40}
41
42pub fn info_with_duration(data: &str, namespace: &str, duration: u128) -> Result<(), Error> {
43 if let Ok(_) = env::var("BASELIME_API_KEY") {
44 let data = data.to_string();
45 let namespace = namespace.to_string();
46 thread::spawn(move || {
47 let baselime_client = baselime::new();
48 match baselime_client.send_with_duration(data, Level::Info, namespace, duration) {
49 Ok(_) => {}
50 Err(e) => {
51 println!("Error: {}", e);
52 }
53 }
54 });
55 }
56 Ok(())
57}