pub struct EffectLogger;Expand description
Log sink for use as effectful::Service<EffectLogKey, Self>; forwards to tracing.
Extracted from the environment with bind* EffectLogger inside effectful::effect!.
After extraction its methods return Effect<(), EffectLoggerError, R> and
are themselves awaited with bind*.
Implementations§
Source§impl EffectLogger
impl EffectLogger
Sourcepub fn with_minimum_log_level<B, E, R>(
fiber_ref: FiberRef<LogLevel>,
level: LogLevel,
inner: Effect<B, E, R>,
) -> Effect<B, E, R>where
B: 'static,
E: 'static,
R: 'static,
pub fn with_minimum_log_level<B, E, R>(
fiber_ref: FiberRef<LogLevel>,
level: LogLevel,
inner: Effect<B, E, R>,
) -> Effect<B, E, R>where
B: 'static,
E: 'static,
R: 'static,
Run inner with this fiber’s minimum log level overridden to level (effectful::FiberRef::locally).
Sourcepub fn log<R: 'static>(
&self,
level: LogLevel,
msg: impl Into<Cow<'static, str>>,
) -> Effect<(), EffectLoggerError, R>
pub fn log<R: 'static>( &self, level: LogLevel, msg: impl Into<Cow<'static, str>>, ) -> Effect<(), EffectLoggerError, R>
Emit a log line at level. Returns an effect that, when run, forwards
to tracing. The environment R is ignored — the logger is
self-contained after extraction.
When layer_minimum_log_level has been built on this thread, messages below the current
fiber’s minimum LogLevel (from that FiberRef) are dropped without calling tracing.
msg may be a &'static str, String, or other Into<Cow<'static, str>>.
Sourcepub fn log_string<R: 'static>(
&self,
level: LogLevel,
msg: String,
) -> Effect<(), EffectLoggerError, R>
pub fn log_string<R: 'static>( &self, level: LogLevel, msg: String, ) -> Effect<(), EffectLoggerError, R>
Sourcepub fn trace<R: 'static>(
&self,
msg: impl Into<Cow<'static, str>>,
) -> Effect<(), EffectLoggerError, R>
pub fn trace<R: 'static>( &self, msg: impl Into<Cow<'static, str>>, ) -> Effect<(), EffectLoggerError, R>
Shorthand for Self::log at LogLevel::Trace.
Sourcepub fn debug<R: 'static>(
&self,
msg: impl Into<Cow<'static, str>>,
) -> Effect<(), EffectLoggerError, R>
pub fn debug<R: 'static>( &self, msg: impl Into<Cow<'static, str>>, ) -> Effect<(), EffectLoggerError, R>
Shorthand for Self::log at LogLevel::Debug.
Sourcepub fn info<R: 'static>(
&self,
msg: impl Into<Cow<'static, str>>,
) -> Effect<(), EffectLoggerError, R>
pub fn info<R: 'static>( &self, msg: impl Into<Cow<'static, str>>, ) -> Effect<(), EffectLoggerError, R>
Shorthand for Self::log at LogLevel::Info.
Sourcepub fn warn<R: 'static>(
&self,
msg: impl Into<Cow<'static, str>>,
) -> Effect<(), EffectLoggerError, R>
pub fn warn<R: 'static>( &self, msg: impl Into<Cow<'static, str>>, ) -> Effect<(), EffectLoggerError, R>
Shorthand for Self::log at LogLevel::Warn.
Sourcepub fn error<R: 'static>(
&self,
msg: impl Into<Cow<'static, str>>,
) -> Effect<(), EffectLoggerError, R>
pub fn error<R: 'static>( &self, msg: impl Into<Cow<'static, str>>, ) -> Effect<(), EffectLoggerError, R>
Shorthand for Self::log at LogLevel::Error.
Sourcepub fn fatal<R: 'static>(
&self,
msg: impl Into<Cow<'static, str>>,
) -> Effect<(), EffectLoggerError, R>
pub fn fatal<R: 'static>( &self, msg: impl Into<Cow<'static, str>>, ) -> Effect<(), EffectLoggerError, R>
Shorthand for Self::log at LogLevel::Fatal.
Trait Implementations§
Source§impl Clone for EffectLogger
impl Clone for EffectLogger
Source§fn clone(&self) -> EffectLogger
fn clone(&self) -> EffectLogger
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EffectLogger
impl Debug for EffectLogger
Source§impl Default for EffectLogger
impl Default for EffectLogger
Source§fn default() -> EffectLogger
fn default() -> EffectLogger
Source§impl<'a, R> IntoBind<'a, R, EffectLogger, EffectLoggerError> for EffectLogger
Implementing IntoBind for EffectLogger makes bind* EffectLogger valid
inside any effect! whose environment R holds an EffectLogger under
EffectLogKey. The zero-sized struct acts as its own “request token”:
passing it to bind* copies the concrete value out of R and binds it as a
local variable.
impl<'a, R> IntoBind<'a, R, EffectLogger, EffectLoggerError> for EffectLogger
Implementing IntoBind for EffectLogger makes bind* EffectLogger valid
inside any effect! whose environment R holds an EffectLogger under
EffectLogKey. The zero-sized struct acts as its own “request token”:
passing it to bind* copies the concrete value out of R and binds it as a
local variable.
Source§fn into_bind(
self,
r: &'a mut R,
) -> BoxFuture<'a, Result<EffectLogger, EffectLoggerError>>
fn into_bind( self, r: &'a mut R, ) -> BoxFuture<'a, Result<EffectLogger, EffectLoggerError>>
self into a boxed future given the environment r.