VersaLog

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 set_silent(&mut self, silent: bool)

Source

pub fn install_panic_hook(self: Arc<Self>)

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

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