Add LogEncoder struct
The LogEncoder struct is a wrapper around a String, its main purpose is to make
setting the default value easier.
use std::convert::From;
use std::convert::TryFrom;
use std::convert::TryInto;
+use std::ops::Deref;
use log::Level;
@@ -83,6 +84,32 @@ pub enum RawLogTarget {
RollingFile,
}
+#[derive(Clone, Debug)]
+pub struct LogEncoder {
+ value: String,
+}
+
+impl From<String> for LogEncoder {
+ fn from(value: String) -> Self {
+ LogEncoder { value }
+ }
+}
+
+impl Default for LogEncoder {
+ fn default() -> Self {
+ Self {
+ value: DEFAULT_LOGGING_PATTERN.to_string(),
+ }
+ }
+}
+
+impl Deref for LogEncoder {
+ type Target = str;
+ fn deref(&self) -> &Self::Target {
+ &self.value
+ }
+}
+
impl AppenderConfig {
pub fn get_filename(&self) -> Option<&str> {
match &self.kind {
