pub enum LogFormat {
Auto,
Pretty,
Compact,
Json,
}Expand description
The shape of a log line.
use rainier_support::Setting;
use rainier_telemetry::LogFormat;
assert_eq!(LogFormat::parse("json").unwrap(), LogFormat::Json);
assert!(LogFormat::parse("jsn").is_err());Variants§
Auto
JSON in production and staging, pretty everywhere else.
The default, because it is right far more often than either fixed answer, and because the failure it prevents — a production deployment logging prose into an aggregator that wanted objects — is one nobody notices until they are searching for something.
Pretty
The human format: coloured, aligned, one event per line.
tracing_subscriber’s default, which is what a Rainier
application has always printed — so this is the format nobody
asked for and everybody recognises.
Compact
Denser than pretty and still readable. For docker logs and CI,
where the terminal is narrow and nothing is colouring anything.
Json
One JSON object per line. For anything that indexes fields.
Implementations§
Source§impl LogFormat
impl LogFormat
Sourcepub fn resolve(self, environment: &str) -> LogFormat
pub fn resolve(self, environment: &str) -> LogFormat
What Auto means in this environment.
Production and staging get JSON; everything else gets pretty. Staging
is included deliberately — it exists to be production-shaped, and a
staging deployment whose logs are not searchable the same way is one
that cannot rehearse an incident.
use rainier_telemetry::LogFormat;
assert_eq!(LogFormat::Auto.resolve("production"), LogFormat::Json);
assert_eq!(LogFormat::Auto.resolve("local"), LogFormat::Pretty);
// Anything explicit is left alone.
assert_eq!(LogFormat::Compact.resolve("production"), LogFormat::Compact);Sourcepub fn is_structured(self) -> bool
pub fn is_structured(self) -> bool
Whether lines in this format are meant to be parsed rather than read.
Trait Implementations§
impl Copy for LogFormat
Source§impl<'de> Deserialize<'de> for LogFormat
impl<'de> Deserialize<'de> for LogFormat
Source§fn deserialize<D>(
deserializer: D,
) -> Result<LogFormat, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<LogFormat, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Eq for LogFormat
Source§impl Serialize for LogFormat
impl Serialize for LogFormat
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl Setting for LogFormat
impl Setting for LogFormat
impl StructuralPartialEq for LogFormat
Auto Trait Implementations§
impl Freeze for LogFormat
impl RefUnwindSafe for LogFormat
impl Send for LogFormat
impl Sync for LogFormat
impl Unpin for LogFormat
impl UnsafeUnpin for LogFormat
impl UnwindSafe for LogFormat
Blanket Implementations§
impl<T> Actor for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
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 more