Struct LogField
pub struct LogField<'a>(/* private fields */);Expand description
Structure representing a single field in a structured log entry.
See g_log_structured for details. Log fields may contain UTF-8 strings, binary with
embedded nul bytes, or arbitrary pointers.
Implementations§
§impl<'a> LogField<'a>
impl<'a> LogField<'a>
pub fn new(key: &'a GStr, value: &[u8]) -> LogField<'a>
pub fn new(key: &'a GStr, value: &[u8]) -> LogField<'a>
Creates a field from a borrowed key and value.
pub fn new_user_data(key: &'a GStr, data: usize) -> LogField<'a>
pub fn new_user_data(key: &'a GStr, data: usize) -> LogField<'a>
Creates a field with an empty value and data as a user data key. Fields created with this
function are ignored by the default log writer. These fields are used to pass custom data
into a writer function set with log_set_writer_func, where it can be retrieved using
Self::user_data.
The passed usize can be used by the log writer as a key into a static data structure.
Thread locals are preferred since the log writer function will run in the same thread that
invoked log_structured_array.
pub fn value_bytes(&self) -> Option<&[u8]>
pub fn value_bytes(&self) -> Option<&[u8]>
Retrieves a byte array of the field value. Returns None if the field was created with
Self::new_user_data.
pub fn value_str(&self) -> Option<&str>
pub fn value_str(&self) -> Option<&str>
Retrieves a string of the field value, or None if the string is not valid UTF-8. Also
returns None if the field was created with Self::new_user_data.
pub fn user_data(&self) -> Option<usize>
pub fn user_data(&self) -> Option<usize>
Retrieves the the user data value from a field created with Self::new_user_data.
Returns None if the field was created with Self::new.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for LogField<'a>
impl<'a> RefUnwindSafe for LogField<'a>
impl<'a> !Send for LogField<'a>
impl<'a> !Sync for LogField<'a>
impl<'a> Unpin for LogField<'a>
impl<'a> UnwindSafe for LogField<'a>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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