pub struct LogScaleStructuredLogger { /* private fields */ }Implementations§
Source§impl LogScaleStructuredLogger
impl LogScaleStructuredLogger
Sourcepub fn init(
url: String,
ingest_token: String,
options: LoggerOptions,
) -> Result<(), Box<dyn Error>>
pub fn init( url: String, ingest_token: String, options: LoggerOptions, ) -> Result<(), Box<dyn Error>>
Examples found in repository?
examples/log_structured.rs (lines 21-25)
13async fn main() {
14 let args: Vec<String> = env::args().collect();
15
16 let ingest_token = args
17 .get(1)
18 .expect("Missing '--ingest-token' parameter.")
19 .replace("--ingest-token=", "");
20
21 LogScaleStructuredLogger::init(
22 String::from("https://cloud.community.humio.com"),
23 ingest_token,
24 LoggerOptions::default()
25 )
26 .unwrap();
27
28 log::set_max_level(log::LevelFilter::Trace);
29
30 let nested = Nested {x: 42, y: String::from("some string parameter.")};
31 let mut count = 0;
32
33 // Loop to let the background sync task have time to do its thing.
34 loop {
35 info!("Plain log only with text, no variables");
36
37 error!("You can of course also use any other log level, like error.");
38
39 info!(count = format!("{}", count); "You can also add structured values to your logs, which will automatically be included as attributes in your LogScale logs.");
40
41 info!(target: "api",
42 method = "GET",
43 path = "/hello",
44 status = 200_u16,
45 elapsed = 10_u64,
46 nested = log::as_serde!(nested);
47 "You can also create logs with multiple structured values, and even nested JSON values.",);
48
49 std::thread::sleep(Duration::from_secs(1));
50
51 count += 1;
52 }
53}Trait Implementations§
Auto Trait Implementations§
impl Freeze for LogScaleStructuredLogger
impl !RefUnwindSafe for LogScaleStructuredLogger
impl Send for LogScaleStructuredLogger
impl Sync for LogScaleStructuredLogger
impl Unpin for LogScaleStructuredLogger
impl !UnwindSafe for LogScaleStructuredLogger
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