Ruby: serialize timestamps as ISO8601

This commit is contained in:
Arthur Baars
2023-01-31 12:59:09 +01:00
parent d944c2bd79
commit 57012714d6
3 changed files with 3 additions and 5 deletions

BIN
ruby/Cargo.lock generated

Binary file not shown.

View File

@@ -22,3 +22,4 @@ encoding = "0.2"
lazy_static = "1.4.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
chrono = { version = "0.4.19", features = ["serde"] }

View File

@@ -56,7 +56,7 @@ pub struct Location {
#[serde(rename_all = "camelCase")]
pub struct DiagnosticMessage {
/** Unix timestamp */
pub timestamp: u64,
pub timestamp: chrono::DateTime<chrono::Utc>,
pub source: Source,
#[serde(skip_serializing_if = "String::is_empty")]
/** GitHub flavored Markdown formatted message. Should include inline links to any help pages. */
@@ -90,10 +90,7 @@ pub struct LogWriter {
impl LogWriter {
pub fn message(&self, id: &str, name: &str) -> DiagnosticMessage {
DiagnosticMessage {
timestamp: std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.expect("")
.as_millis() as u64,
timestamp: chrono::Utc::now(),
source: Source {
id: format!("{}/{}", self.extractor, id),
name: name.to_owned(),