Skip to content

WASDetchan/logcast

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logcast

rust

A simple helper that sends logs over TCP, for programs without terminal output, such as TUIs.

Example

logcast

Usage

See examples/log.rs for an example of integration with the log crate.

Add logcast

cargo add logcast

Create Macro

// src/macros.rs
macro_rules! log {
    ($($arg:tt)*) => {{
        crate::LOGGER.log(&format!($($arg)*));
    }};
}

Make the macro available globally and create the LOGGER

// src/main.rs
#[macro_use]
mod macros;

use std::sync::LazyLock;
use logcast::Logger;

pub static LOGGER: LazyLock<Logger> = LazyLock::new(|| Logger::new("127.0.0.1:8080"));

Use macro with log!

log!("Test");
log!("{:?}", service);

Output

To view the logs, open another terminal and run a program that listens for TCP connections, such as ncat -l --keep-open 8080, as shown in the example below.

└─$ ncat -l --keep-open 8080 
[2025-11-10 20:55:04] Test
[2025-11-10 20:55:04] Service { name: "cron.service", description: "Regular background program processing daemon", state: ServiceState { load: "loaded", active: "active", sub: "running", file: "enabled" } }

📝 License

This project is open-source under the MIT License.

About

A simple helper that sends logs over TCP, for programs without terminal output, such as TUIs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 100.0%