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 56)
31async fn main() -> Result<(), Box<dyn Error>> {
32 let logger = NewVersaLog("detailed", false, true, "Request", false, false, false, Vec::new());
33
34 let api = "http://api.openweathermap.org/data/2.5/weather";
35
36 let params = [
37 ("q", "location name"),
38 ("appid", "api key"),
39 ("units", "metric"),
40 ("lang", "ja"),
41 ];
42
43 let client = reqwest::Client::new();
44 let req = client.get(api).query(¶ms).send().await?;
45
46 if req.status().is_success() {
47 let data: WeatherData = req.json().await?;
48
49 let location_name = data.name;
50 let weather_description = &data.weather[0].description;
51 let temperature = data.main.temp;
52 let humidity = data.main.humidity;
53 let pressure = data.main.pressure;
54 let wind_speed = data.wind.speed;
55
56 logger.info("success", &[]);
57
58 let msg = format!(
59 "< {}の天気予報 >\n\n> 天気\n・{}\n\n> 気温\n・{}°C\n\n> 湿度\n・{}%\n\n> 気圧\n・{} hPa\n\n> 風速\n・{} m/s",
60 location_name, weather_description, temperature, humidity, pressure, wind_speed
61 );
62
63 println!("{}", msg);
64 } else {
65 logger.error("failed", &[]);
66 }
67
68 Ok(())
69}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 65)
31async fn main() -> Result<(), Box<dyn Error>> {
32 let logger = NewVersaLog("detailed", false, true, "Request", false, false, false, Vec::new());
33
34 let api = "http://api.openweathermap.org/data/2.5/weather";
35
36 let params = [
37 ("q", "location name"),
38 ("appid", "api key"),
39 ("units", "metric"),
40 ("lang", "ja"),
41 ];
42
43 let client = reqwest::Client::new();
44 let req = client.get(api).query(¶ms).send().await?;
45
46 if req.status().is_success() {
47 let data: WeatherData = req.json().await?;
48
49 let location_name = data.name;
50 let weather_description = &data.weather[0].description;
51 let temperature = data.main.temp;
52 let humidity = data.main.humidity;
53 let pressure = data.main.pressure;
54 let wind_speed = data.wind.speed;
55
56 logger.info("success", &[]);
57
58 let msg = format!(
59 "< {}の天気予報 >\n\n> 天気\n・{}\n\n> 気温\n・{}°C\n\n> 湿度\n・{}%\n\n> 気圧\n・{} hPa\n\n> 風速\n・{} m/s",
60 location_name, weather_description, temperature, humidity, pressure, wind_speed
61 );
62
63 println!("{}", msg);
64 } else {
65 logger.error("failed", &[]);
66 }
67
68 Ok(())
69}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