Expand description
§rconsole - WebSocket-based logging library for Rust
A logging library that sends structured log messages to the Server Log app via WebSocket.
Mirrors the API of the Flutter nconsole package, providing
console.log/info/warn/error/group/clear equivalents.
§Architecture
┌──────────────┐
│ NConsole │ ← Public API façade (services layer)
└──────┬───────┘
│
┌──────▼───────┐
│ WebConsole │ ← Singleton, manages state & dispatch (console layer)
└──────┬───────┘
│
┌──────▼───────┐
│ WsConnection │ ← WebSocket transport (infrastructure layer)
└──────────────┘§Quick Start
use rconsole::*;
use serde_json::json;
// Point to your Server Log app
NConsole::set_uri("192.168.1.100");
// Log with mixed types — like console.log(a, b, c) in JavaScript
nlog!("Hello from Rust!", 42, true, json!({"key": "val"}));
ninfo!("Server started on port", 8080);
nwarn!("Memory usage:", 85.5, "%");
nerror!("Connection failed", json!({"code": 500}));
// Grouped logging
ngroup!("HTTP Request");
nlog!("GET", "/api/users");
nlog!("Status:", 200);
ngroup_end!();
// Clear console
nclear!();§Thread Safety
All public methods on NConsole are thread-safe. The internal
WebConsole singleton is protected by a Mutex.
Re-exports§
pub use console::ClientInfo;pub use domain::LogArg;pub use domain::LogType;pub use services::NConsole;
Modules§
- console
- Console layer - core WebConsole implementation, URI handling, and client info.
- domain
- Domain layer - core types and enums for nconsole.
- infrastructure
- Infrastructure layer - WebSocket transport implementation.
- services
- Services layer - public API façade.
Macros§
- nclear
- Clear the console.
- nerror
- Log an error message with any number of heterogeneous arguments.
- ngroup
- Start a named log group.
- ngroup_
collapsed - Start a collapsed named log group.
- ngroup_
end - End the current log group.
- ninfo
- Log an info message with any number of heterogeneous arguments.
- nlog
- Log a message with any number of heterogeneous arguments.
- nwarn
- Log a warning message with any number of heterogeneous arguments.