mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Start reworking the manager system
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
pub mod config;
|
||||
mod error;
|
||||
pub mod logger;
|
||||
pub mod manager;
|
||||
|
||||
mod announcement;
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/// Implement logging for the manager
|
||||
use crossbeam_channel::Sender;
|
||||
|
||||
use crate::{
|
||||
logger::{Logger, Record},
|
||||
manager::Manager,
|
||||
};
|
||||
|
||||
pub struct ManagerLogger {
|
||||
tx: Sender<Record>,
|
||||
}
|
||||
|
||||
impl ManagerLogger {
|
||||
pub fn new(tx: Sender<Record>) -> Self {
|
||||
Self { tx }
|
||||
}
|
||||
}
|
||||
|
||||
// impl Manager {
|
||||
// /// Initiate the unshell logger, piped through the manager
|
||||
// /// This will allow access to the logs through the tree
|
||||
// pub fn init_logger(&self) {
|
||||
// // Create the logger through the TX element of the manager
|
||||
// let logger = ManagerLogger::new(self.logs_tx.clone());
|
||||
|
||||
// // Set the logger through unshell
|
||||
// crate::logger::set_logger_box(Box::new(logger));
|
||||
// }
|
||||
// }
|
||||
|
||||
impl Logger for ManagerLogger {
|
||||
fn log(&self, log: crate::logger::Record) {
|
||||
// This will never panic if the program is operating properly
|
||||
self.tx.send(log).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
mod log;
|
||||
|
||||
pub struct Manager {
|
||||
// logs_tx: Sender<Record>,
|
||||
// logs_rx: Receiver<Record>,
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
|
||||
// let (tx, rx) = crossbeam_channel::unbounded();
|
||||
|
||||
// Self {
|
||||
// logs_tx: tx,
|
||||
// logs_rx: rx,
|
||||
// }
|
||||
}
|
||||
|
||||
// pub fn log_count(&self) -> usize {
|
||||
// self.logs_rx.len()
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user