Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub trait Env: Sized + Clone + Default + PartialEq + Debug + Send + Sync + 'stat
type ValidState: ValidState;
type Message: 'static;
//type Commit: Eq + Ord;
type Log: crate::log::Logger;
}

pub trait EnvFlexCtxHandler: Env {
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod util;
pub mod validation;
pub mod aliases;
pub mod widgets;
pub mod log;

pub(crate) use aliases::*;
pub(crate) use backend::*;
Expand Down
27 changes: 27 additions & 0 deletions src/log/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use std::error::Error;
use std::fmt::Arguments;

use crate::env::Env;

pub trait Logger {
//TODO static, Context, or extra immutable type shit which then needs to be added to every single fn
type LW: LogWriter;

fn info<R>(f: impl FnOnce(&mut Self::LW) -> R) -> R;
fn warn<R>(f: impl FnOnce(&mut Self::LW) -> R) -> R;
fn debug<R>(f: impl FnOnce(&mut Self::LW) -> R) -> R;
fn trace<R>(f: impl FnOnce(&mut Self::LW) -> R) -> R;
}

pub trait LogWriter {
type Err: Error;

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Self::Err>;
}

fn akw<E>(id: &E::WidgetID)
where
E: Env,
{
E::Log::info(|w| write!(w, "{}: {:?}", "FuZ", id)).unwrap();
}