use crate::evident::event::origin::Origin;
use crate::log_id::{LogId, LogLevel};
#[derive(Default, Clone)]
pub struct LogEventEntry {
pub(crate) event_id: LogId,
pub(crate) entry_id: crate::evident::uuid::Uuid,
pub(crate) msg: String,
pub(crate) infos: Vec<String>,
pub(crate) debugs: Vec<String>,
pub(crate) traces: Vec<String>,
pub(crate) origin: Origin,
#[cfg(feature = "diagnostics")]
pub(crate) diagnostics: Vec<crate::lsp_types::Diagnostic>,
#[cfg(feature = "payloads")]
pub(crate) payloads: Vec<serde_json::value::Value>,
}
impl crate::evident::event::entry::EventEntry<LogId> for LogEventEntry {
fn new(event_id: LogId, msg: &str, origin: Origin) -> Self {
LogEventEntry {
event_id,
entry_id: crate::evident::uuid::Uuid::new_v4(),
msg: msg.to_string(),
infos: Vec::new(),
debugs: Vec::new(),
traces: Vec::new(),
origin,
#[cfg(feature = "diagnostics")]
diagnostics: Vec::new(),
#[cfg(feature = "payloads")]
payloads: Vec::new(),
}
}
fn get_event_id(&self) -> &LogId {
&self.event_id
}
fn into_event_id(self) -> LogId {
self.event_id
}
fn get_entry_id(&self) -> crate::evident::uuid::Uuid {
self.entry_id
}
fn get_msg(&self) -> &str {
&self.msg
}
fn get_crate_name(&self) -> &'static str {
self.origin.crate_name
}
fn get_origin(&self) -> &crate::evident::event::origin::Origin {
&self.origin
}
}
impl LogEventEntry {
pub fn get_level(&self) -> LogLevel {
self.event_id.log_level
}
pub fn get_msg(&self) -> &String {
&self.msg
}
pub fn get_origin(&self) -> &Origin {
&self.origin
}
pub fn get_infos(&self) -> &Vec<String> {
&self.infos
}
pub fn get_debugs(&self) -> &Vec<String> {
&self.debugs
}
pub fn get_traces(&self) -> &Vec<String> {
&self.traces
}
#[cfg(feature = "diagnostics")]
pub fn get_diagnostics(&self) -> &Vec<crate::lsp_types::Diagnostic> {
&self.diagnostics
}
#[cfg(feature = "payloads")]
pub fn get_payloads(&self) -> &Vec<serde_json::value::Value> {
&self.payloads
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AddonKind {
Info(String),
Debug(String),
Trace(String),
#[cfg(feature = "diagnostics")]
Diagnostic(crate::lsp_types::Diagnostic),
#[cfg(feature = "payloads")]
Payload(serde_json::value::Value),
}