From 9da75eae0c1ad9af7454166850470eb3295c34cb Mon Sep 17 00:00:00 2001 From: "Nathanael G. Reese" Date: Wed, 8 Oct 2025 13:27:01 -0400 Subject: [PATCH 1/5] Create main.yml --- .github/workflows/main.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9968546 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,29 @@ +name: Rust + +on: + push: + branches: [ "*" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Format + run: cargo fmt -- --check + - name: Clippy + run: cargo clippy + - name: Unit Tests + run: cargo test --verbose + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build + run: cargo build --release --verbose From aed51ec3f4d228cc6fe32e1be5080efa8efb5fbd Mon Sep 17 00:00:00 2001 From: "Nathanael G. Reese" Date: Wed, 8 Oct 2025 13:33:43 -0400 Subject: [PATCH 2/5] Add Logger5424 struct, constructor, and impl Log trait --- src/lib.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 945aba9..f5687f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,6 +63,7 @@ use std::os::unix::net::{UnixDatagram, UnixStream}; use std::path::Path; use std::process; use std::sync::{Arc, Mutex}; +use std::collections::BTreeMap; use log::{Level, Log, Metadata, Record}; @@ -366,6 +367,44 @@ impl Log for BasicLogger { } } +pub struct Logger5424 { + logger: Arc>>, +} + +impl Logger5424 { + pub fn new(logger: Logger) -> Logger5424 { + Logger5424 { + logger: Arc::new(Mutex::new(logger)), + } + } +} + +impl Log for Logger5424 { + fn enabled(&self, metadata: &Metadata) -> bool { + metadata.level() <= log::max_level() && metadata.level() <= log::STATIC_MAX_LEVEL + } + + fn log(&self, record: &Record) { + if self.enabled(record.metadata()) { + //FIXME: temporary patch to compile + let msg = format!("{}", record.args()); + let btree: BTreeMap> = BTreeMap::new(); + let mut logger = self.logger.lock().unwrap(); + let _ = match record.level() { + Level::Error => logger.err((1, btree.clone(), msg)), + Level::Warn => logger.warning((1, btree.clone(), msg)), + Level::Info => logger.info((1, btree.clone(), msg)), + Level::Debug => logger.debug((1, btree.clone(), msg)), + Level::Trace => logger.debug((1, btree.clone(), msg)), + }; + } + } + + fn flush(&self) { + let _ = self.logger.lock().unwrap().backend.flush(); + } +} + /// Unix socket Logger init function compatible with log crate #[cfg(unix)] pub fn init_unix(facility: Facility, log_level: log::LevelFilter) -> Result<()> { From 2d8a5a511f6030a068d5d823425bc5ad8be0e1b8 Mon Sep 17 00:00:00 2001 From: "Nathanael G. Reese" Date: Wed, 8 Oct 2025 13:35:03 -0400 Subject: [PATCH 3/5] format --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f5687f5..1933099 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,6 +54,7 @@ extern crate log; extern crate time; +use std::collections::BTreeMap; use std::env; use std::fmt::{self, Arguments}; use std::io::{self, BufWriter, Write}; @@ -63,7 +64,6 @@ use std::os::unix::net::{UnixDatagram, UnixStream}; use std::path::Path; use std::process; use std::sync::{Arc, Mutex}; -use std::collections::BTreeMap; use log::{Level, Log, Metadata, Record}; From 05b286e3b8518147e316b254887d542f3197a2ed Mon Sep 17 00:00:00 2001 From: "Nathanael G. Reese" Date: Wed, 8 Oct 2025 13:39:36 -0400 Subject: [PATCH 4/5] Delete hanging actions yaml --- .github/workflows/main.yml | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 9968546..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Rust - -on: - push: - branches: [ "*" ] - pull_request: - branches: [ "main" ] - -env: - CARGO_TERM_COLOR: always - -jobs: - checks: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Format - run: cargo fmt -- --check - - name: Clippy - run: cargo clippy - - name: Unit Tests - run: cargo test --verbose - - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --release --verbose From f7e61c302286e82c0493f0b4b6bec2393d5833b3 Mon Sep 17 00:00:00 2001 From: "Nathanael G. Reese" Date: Wed, 8 Oct 2025 13:40:47 -0400 Subject: [PATCH 5/5] Remove unnecessary clone --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 1933099..4f5b4ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -395,7 +395,7 @@ impl Log for Logger5424 { Level::Warn => logger.warning((1, btree.clone(), msg)), Level::Info => logger.info((1, btree.clone(), msg)), Level::Debug => logger.debug((1, btree.clone(), msg)), - Level::Trace => logger.debug((1, btree.clone(), msg)), + Level::Trace => logger.debug((1, btree, msg)), }; } }