pub struct GlobalLogBuilder { /* private fields */ }
Expand description
The global log builder. See the GlobalLog
struct for more information.
Implementations§
Source§impl GlobalLogBuilder
impl GlobalLogBuilder
Sourcepub fn build(self) -> RResult<GlobalLog, AnyErr>
pub fn build(self) -> RResult<GlobalLog, AnyErr>
Build the global log from the configured builder.
Sourcepub fn stdout(self, pretty: bool, include_loc: bool) -> Self
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).
Sourcepub fn file(
self,
file_prefix: impl Into<String>,
dir: impl Into<PathBuf>,
) -> Self
Available on non-WebAssembly only.
pub fn file( self, file_prefix: impl Into<String>, dir: impl Into<PathBuf>, ) -> Self
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.
Sourcepub fn custom(
self,
pretty: bool,
include_loc: bool,
include_color: bool,
include_ts: bool,
writer: fn(&[u8]),
) -> Self
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);
Sourcepub fn otlp_grpc(
self,
port: u16,
service_name: impl Into<String>,
service_version: impl Into<String>,
) -> Self
Available on crate feature opentelemetry-grpc
only.
pub fn otlp_grpc( self, port: u16, service_name: impl Into<String>, service_version: impl Into<String>, ) -> Self
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:
Sourcepub 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.
pub fn otlp_http( self, endpoint: impl Into<String>, service_name: impl Into<String>, service_version: impl Into<String>, ) -> Self
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:
Sourcepub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
Available on crate feature opentelemetry-http
only.
pub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
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.
Sourcepub fn level_from(self, level: Level) -> RResult<Self, AnyErr>
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.
Sourcepub fn loc_matcher(self, loc_matcher: Regex) -> RResult<Self, AnyErr>
Available on crate feature log-filter
only.
pub fn loc_matcher(self, loc_matcher: Regex) -> RResult<Self, AnyErr>
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
impl Default for GlobalLogBuilder
Source§fn default() -> GlobalLogBuilder
fn default() -> GlobalLogBuilder
Auto Trait Implementations§
impl Freeze for GlobalLogBuilder
impl RefUnwindSafe for GlobalLogBuilder
impl Send for GlobalLogBuilder
impl Sync for GlobalLogBuilder
impl Unpin for GlobalLogBuilder
impl UnwindSafe for GlobalLogBuilder
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request