[][src]Struct opentracingrust::Log

pub struct Log { /* fields omitted */ }

Structured logging information to attach to spans.

Each log has a set of vaules idenfied by strings. Values stored in fields can be of any type convertible to a LogValue.

Logs also have an optional timestamp. If set, the timestamp must be between the start and the end of the span.

Examples

extern crate opentracingrust;

use std::thread;
use std::time::Duration;
use std::time::SystemTime;

use opentracingrust::Log;
use opentracingrust::tracers::NoopTracer;


fn main() {
    let (tracer, _) = NoopTracer::new();
    let mut span = tracer.span("example");

    let time = SystemTime::now();
    thread::sleep(Duration::from_millis(50));

    let log = Log::new()
        .log("error", false)
        .log("event", "some-event")
        .log("line", 26)
        .at(time);
    span.log(log);
}

Methods

impl Log[src]

pub fn new() -> Log[src]

Creates an empty structured log.

impl Log[src]

pub fn at(self, timestamp: SystemTime) -> Log[src]

Sets the timestamp associated with the log.

pub fn at_or_now(&mut self)[src]

Sets the timestamp to now if not set.

pub fn log<LV: Into<LogValue>>(self, key: &str, value: LV) -> Log[src]

Extend the log fields with the given value.

If a value with the same key is already in the log the value is replaced.

pub fn iter(&self) -> Iter<String, LogValue>[src]

Access an iterator over stored fields.

pub fn timestamp(&self) -> Option<&SystemTime>[src]

Access the (optional) timestamp for the log.

Trait Implementations

impl Debug for Log[src]

impl Default for Log[src]

Auto Trait Implementations

impl RefUnwindSafe for Log

impl Send for Log

impl Sync for Log

impl Unpin for Log

impl UnwindSafe for Log

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,