#[non_exhaustive]pub enum LogFormat {
CLF,
JSON,
CEF,
ELF,
W3C,
GELF,
ApacheAccessLog,
Logstash,
Log4jXML,
NDJSON,
}
Expand description
An enumeration of the different log formats that can be used.
§Variants
CLF
- Common Log Format.JSON
- JavaScript Object Notation.CEF
- Common Event Format.ELF
- Extended Log Format.W3C
- W3C Extended Log File Format.GELF
- Graylog Extended Log Format.ApacheAccessLog
- Apache HTTP server access logs.Logstash
- Logstash JSON format.Log4jXML
- Log4j’s XML format.NDJSON
- Newline Delimited JSON.
§Examples
use rlg::log_format::LogFormat;
let format: LogFormat = "CLF".parse().unwrap();
assert_eq!(format, LogFormat::CLF);
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
CLF
Common Log Format.
JSON
JavaScript Object Notation.
CEF
Common Event Format.
ELF
Extended Log Format.
W3C
W3C Extended Log File Format.
GELF
Graylog Extended Log Format.
ApacheAccessLog
Apache HTTP server access logs.
Logstash
Logstash JSON format.
Log4jXML
Log4j’s XML format.
NDJSON
Newline Delimited JSON.
Implementations§
Source§impl LogFormat
impl LogFormat
Sourcepub fn validate(&self, input: &str) -> bool
pub fn validate(&self, input: &str) -> bool
Validates if a given string adheres to a particular log format.
§Arguments
input
- A string slice that holds the log entry to be validated.
§Returns
bool
- Returnstrue
if the input matches the log format,false
otherwise.
§Example
use rlg::log_format::LogFormat;
let is_valid = LogFormat::CLF.validate("127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] \"GET /apache_pb.gif HTTP/1.0\" 200 2326");
assert!(is_valid);
Sourcepub fn format_log(&self, entry: &str) -> RlgResult<String>
pub fn format_log(&self, entry: &str) -> RlgResult<String>
Formats a log entry according to the specified log format.
§Arguments
entry
- A string slice that holds the log entry to be formatted.
§Returns
A RlgResult<String>
containing the formatted log entry or an error if the formatting fails.
§Example
use rlg::log_format::LogFormat;
let formatted_log = LogFormat::CLF.format_log("127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] \"GET /apache_pb.gif HTTP/1.0\" 200 2326").unwrap();
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LogFormat
impl<'de> Deserialize<'de> for LogFormat
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for LogFormat
impl Ord for LogFormat
Source§impl PartialOrd for LogFormat
impl PartialOrd for LogFormat
impl Copy for LogFormat
impl Eq 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 UnwindSafe for LogFormat
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.