Struct GlobalLogBuilder

Source
pub struct GlobalLogBuilder { /* private fields */ }
Expand description

The global log builder. See the GlobalLog struct for more information.

Implementations§

Source§

impl GlobalLogBuilder

Source

pub fn build(self) -> RResult<GlobalLog, AnyErr>

Build the global log from the configured builder.

Source

pub fn stdout(self, pretty: bool, include_loc: bool) -> Self

Write to stdout:

Arguments:

  • pretty: When enabled, logs are formatted more verbosely, but easier on the eyes.
  • include_loc: When enabled, log contains write location (file and line).
Source

pub fn file( self, file_prefix: impl Into<String>, dir: impl Into<PathBuf>, ) -> Self

Available on non-WebAssembly only.

Write to a file:

Arguments:

  • file_prefix: The prefix for the filenames, e.g. “graphs.log” which will come out as “graphs.log.2021-01-21,
  • dir: The directory to hold the log files, e.g. “./logs/”, will create if missing.
Source

pub fn custom( self, pretty: bool, include_loc: bool, include_color: bool, include_ts: bool, writer: fn(&[u8]), ) -> Self

Write to a custom writer.

Arguments:

  • pretty: When enabled, logs are formatted more verbosely, but easier on the eyes.
  • include_loc: When enabled, log contains write location (file and line).
  • include_color: When enabled, log contains colors.
  • include_ts: When enabled, log contains timestamp.
  • writer: The fn to handle writing, passed the raw byte string.

If needing a string in the writer, can do:

let log = String::from_utf8_lossy(log);

Source

pub fn otlp_grpc( self, port: u16, service_name: impl Into<String>, service_version: impl Into<String>, ) -> Self

Available on crate feature opentelemetry-grpc only.

Write to an open telemetry provider via grpc. This works with the tokio runtime.

Arguments:

  • port: The localhost port the open telemetry collector is running on and accepting grpc connections:
  • service_name: The name of the service:
  • service_version: The active version/deployment of the service:
Source

pub fn otlp_http( self, endpoint: impl Into<String>, service_name: impl Into<String>, service_version: impl Into<String>, ) -> Self

Available on crate feature opentelemetry-http only.

Write to an open telemetry provider via http. This works with wasm!

Arguments:

  • endpoint: The url string to connect via http to, e.g. “/otlp” or “http://localhost/otlp”:
  • service_name: The name of the service:
  • service_version: The active version/deployment of the service:
Source

pub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self

Available on crate feature opentelemetry-http only.

Add a header to the last configured otlp http requests, this will be a no-op if the last output is not an otlp http output.

Source

pub fn level_from(self, level: Level) -> RResult<Self, AnyErr>

Set the minimum level to log for.

NOTE: Applies to the last set output type only.

Source

pub fn loc_matcher(self, loc_matcher: Regex) -> RResult<Self, AnyErr>

Available on crate feature log-filter only.

A regex that must be satisfied for a log to be accepted by this target. E.g. if regex is ‘logging::tests’ then only locations containing this will be logged by this target. Note that when None, will match all locations other than those matched by other layers with a loc_matcher.

NOTE: Applies to the last set output type only.

Trait Implementations§

Source§

impl Default for GlobalLogBuilder

Source§

fn default() -> GlobalLogBuilder

Returns the “default value” for a type. Read more

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> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,