Struct VersaLog

Source
pub struct VersaLog { /* private fields */ }

Implementations§

Source§

impl VersaLog

Source

pub fn log(&self, msg: String, level: String, tags: &[&str])

Source

pub fn Info(&self, msg: &str, tags: &[&str])

Source

pub fn Error(&self, msg: &str, tags: &[&str])

Source

pub fn Warning(&self, msg: &str, tags: &[&str])

Source

pub fn Debug(&self, msg: &str, tags: &[&str])

Source

pub fn Critical(&self, msg: &str, tags: &[&str])

Source

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(&params).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}
Source

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(&params).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}
Source

pub fn warning(&self, msg: &str, tags: &[&str])

Source

pub fn debug(&self, msg: &str, tags: &[&str])

Source

pub fn critical(&self, msg: &str, tags: &[&str])

Source

pub fn Info_no_tag(&self, msg: &str)

Source

pub fn Error_no_tag(&self, msg: &str)

Source

pub fn Warning_no_tag(&self, msg: &str)

Source

pub fn Debug_no_tag(&self, msg: &str)

Source

pub fn Critical_no_tag(&self, msg: &str)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more