pub struct VersaLog { /* private fields */ }Implementations§
Source§impl VersaLog
impl VersaLog
pub fn log(&self, msg: String, level: String, tags: &[&str])
pub fn Info(&self, msg: &str, tags: &[&str])
pub fn Error(&self, msg: &str, tags: &[&str])
pub fn Warning(&self, msg: &str, tags: &[&str])
pub fn Debug(&self, msg: &str, tags: &[&str])
pub fn Critical(&self, msg: &str, tags: &[&str])
Sourcepub fn info(&self, msg: &str, tags: &[&str])
pub fn info(&self, msg: &str, tags: &[&str])
Examples found in repository?
examples/api_req.rs (line 65)
31async fn main() -> Result<(), Box<dyn Error>> {
32 let logger = NewVersaLog(
33 "detailed",
34 false,
35 true,
36 "Request",
37 false,
38 false,
39 false,
40 vec![],
41 );
42
43 let api = "http://api.openweathermap.org/data/2.5/weather";
44
45 let params = [
46 ("q", "location name"),
47 ("appid", "api key"),
48 ("units", "metric"),
49 ("lang", "ja"),
50 ];
51
52 let client = reqwest::Client::new();
53 let req = client.get(api).query(¶ms).send().await?;
54
55 if req.status().is_success() {
56 let data: WeatherData = req.json().await?;
57
58 let location_name = data.name;
59 let weather_description = &data.weather[0].description;
60 let temperature = data.main.temp;
61 let humidity = data.main.humidity;
62 let pressure = data.main.pressure;
63 let wind_speed = data.wind.speed;
64
65 logger.info("success", &[]);
66
67 let msg = format!(
68 "< {}の天気予報 >\n\n> 天気\n・{}\n\n> 気温\n・{}°C\n\n> 湿度\n・{}%\n\n> 気圧\n・{} hPa\n\n> 風速\n・{} m/s",
69 location_name, weather_description, temperature, humidity, pressure, wind_speed
70 );
71
72 println!("{}", msg);
73 } else {
74 logger.error("failed", &[]);
75 }
76
77 Ok(())
78}Sourcepub fn error(&self, msg: &str, tags: &[&str])
pub fn error(&self, msg: &str, tags: &[&str])
Examples found in repository?
examples/api_req.rs (line 74)
31async fn main() -> Result<(), Box<dyn Error>> {
32 let logger = NewVersaLog(
33 "detailed",
34 false,
35 true,
36 "Request",
37 false,
38 false,
39 false,
40 vec![],
41 );
42
43 let api = "http://api.openweathermap.org/data/2.5/weather";
44
45 let params = [
46 ("q", "location name"),
47 ("appid", "api key"),
48 ("units", "metric"),
49 ("lang", "ja"),
50 ];
51
52 let client = reqwest::Client::new();
53 let req = client.get(api).query(¶ms).send().await?;
54
55 if req.status().is_success() {
56 let data: WeatherData = req.json().await?;
57
58 let location_name = data.name;
59 let weather_description = &data.weather[0].description;
60 let temperature = data.main.temp;
61 let humidity = data.main.humidity;
62 let pressure = data.main.pressure;
63 let wind_speed = data.wind.speed;
64
65 logger.info("success", &[]);
66
67 let msg = format!(
68 "< {}の天気予報 >\n\n> 天気\n・{}\n\n> 気温\n・{}°C\n\n> 湿度\n・{}%\n\n> 気圧\n・{} hPa\n\n> 風速\n・{} m/s",
69 location_name, weather_description, temperature, humidity, pressure, wind_speed
70 );
71
72 println!("{}", msg);
73 } else {
74 logger.error("failed", &[]);
75 }
76
77 Ok(())
78}pub fn warning(&self, msg: &str, tags: &[&str])
pub fn debug(&self, msg: &str, tags: &[&str])
pub fn critical(&self, msg: &str, tags: &[&str])
pub fn Info_no_tag(&self, msg: &str)
pub fn Error_no_tag(&self, msg: &str)
pub fn Warning_no_tag(&self, msg: &str)
pub fn Debug_no_tag(&self, msg: &str)
pub fn Critical_no_tag(&self, msg: &str)
Auto Trait Implementations§
impl Freeze for VersaLog
impl RefUnwindSafe for VersaLog
impl Send for VersaLog
impl Sync for VersaLog
impl Unpin for VersaLog
impl UnwindSafe for VersaLog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more