Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
feat: use fields for extra data in log messages
Lars Wirzenius committed 1 year ago
commit b4f379ad262b12392d349a56033efb3cc078efbd
parent ee177c8f202d52886e5d020ff837320eaa6d82ca
1 file changed +24 -24
modified src/logger.rs
@@ -223,7 +223,7 @@ pub fn queueadd_control_socket_close() {
}

pub fn queueadd_push_event(e: &CiEvent) {
-
    debug!(kind = %Kind::GotEvent, "insert broker event into queue: {e:?}");
+
    debug!(kind = %Kind::GotEvent, event = ?e, "insert broker event into queue: {e:?}");
}

pub fn queueadd_end() {
@@ -237,8 +237,8 @@ pub fn pages_directory_unset() {
pub fn pages_interval(interval: Duration) {
    debug!(
        kind = %Kind::Debug,
-
        "wait about {} seconds to update HTML report pages again",
-
        interval.as_secs()
+
        interval = interval.as_secs(),
+
        "interval for waiting between HTML page updates",
    );
}

@@ -263,17 +263,17 @@ pub fn event_end() {
}

pub fn broker_db(filename: &Path) {
-
    info!(kind = %Kind::Debug, "broker database: {}", filename.display());
+
    info!(kind = %Kind::Debug, filename = %filename.display(), "broker database");
}

pub fn broker_start_run(trigger: &Request) {
    info!(kind = %Kind::StartRun, "start CI run");
-
    debug!(kind = %Kind::Debug, "trigger event: {trigger:#?}");
+
    debug!(kind = %Kind::Debug, event = ?trigger, "trigger event");
}

pub fn broker_end_run(run: &Run) {
    info!(kind = %Kind::FinishRun, "Finish CI run");
-
    debug!(kind = %Kind::Debug, "finished CI run: {run:#?}");
+
    debug!(kind = %Kind::Debug, run = ?run, "finished CI run");
}

pub fn adapter_no_first_response() {
@@ -337,7 +337,7 @@ pub fn timeoutcmd_wait_on_child_to_end() {
}

pub fn timeoutcmd_wait_status(status: ExitStatus) {
-
    trace!(kind = %Kind::Debug, "wait: wait status: {status:?}");
+
    trace!(kind = %Kind::Debug, ?status, "wait: wait status");
}

pub fn timeoutcmd_ok() {
@@ -349,7 +349,7 @@ pub fn timeoutcmd_nanny_start() {
}

pub fn timeoutcmd_nanny_terminated_as_requested(result: Result<(), std::io::Error>) {
-
    trace!(kind = %Kind::Debug, "nanny: terminated child by request: {result:?}");
+
    trace!(kind = %Kind::Debug, ?result, "nanny: terminated child by request");
}

pub fn timeoutcmd_nanny_too_long(
@@ -360,11 +360,11 @@ pub fn timeoutcmd_nanny_too_long(
) {
    trace!(
        kind = %Kind::Debug,
-
        "nanny: child {} has run for too long ({} ms > {} ms); terminated it: {:?}",
-
        id,
-
        elapsed.as_millis(),
-
        max.as_millis(),
-
        result,
+
        %id,
+
        elapsed_ms = elapsed.as_millis(),
+
        max_ms = max.as_millis(),
+
        ?result,
+
        "nanny: child has run for too long",
    );
}

@@ -388,11 +388,11 @@ pub fn timeoutcmd_line_reader_tried_byte(
    name: &'static str,
    result: Result<u8, std::sync::mpsc::TryRecvError>,
) {
-
    trace!(kind = %Kind::Debug, "line receiver {}: tried to read line: {:?}", name, result);
+
    trace!(kind = %Kind::Debug, ?result, "line receiver {}: tried to read line", name);
}

pub fn timeoutcmd_line_reader_got_line(name: &'static str, line: &str) {
-
    trace!(kind = %Kind::Debug, "line-receiver {}: received line={line:?}", name,);
+
    trace!(kind = %Kind::Debug, ?line, "line-receiver {}: received line", name);
}

pub fn timeoutcmd_line_reader_got_disconnected(name: &'static str) {
@@ -424,9 +424,9 @@ pub fn timeoutcmd_line_reader_child_channel_disconnected(name: &'static str) {
pub fn timeoutcmd_nonblocking_try_byte(name: &'static str, count: usize) {
    trace!(
        kind = %Kind::Debug,
-
        "read_to_end {}: try to receive next byte ({} so far)",
+
        received_so_far = count,
+
        "read_to_end {}: try to receive next byte",
        name,
-
        count
    );
}

@@ -437,10 +437,10 @@ pub fn timeoutcmd_nonblocking_tried_byte(
) {
    trace!(
        kind = %Kind::Debug,
-
        "read_to_end {}: tried to receive byte: result={:?} byte={:?}",
+
        ?result,
+
        ?byte,
+
        "read_to_end {}: tried to receive byte",
        name,
-
        result,
-
        byte
    );
}

@@ -455,15 +455,15 @@ pub fn timeoutcmd_nonblocking_got_too_much(
) {
    trace!(
        kind = %Kind::Debug,
-
        "read_to_end {}: received too much: result={:?} byte={:?}",
+
        ?result,
+
        ?byte,
+
        "read_to_end {}: received too much",
        name,
-
        result,
-
        byte
    );
}

pub fn timeoutcmd_nonblocking_read_error(name: &'static str, err: &std::io::Error) {
-
    trace!(kind = %Kind::Debug, "read_to_end {}: read error: {}", name, err);
+
    trace!(kind = %Kind::Debug, ?err, "read_to_end {}: read error", name);
}

pub fn timeoutcmd_nonblocking_ends(name: &'static str) {