logging works a bit more the way i want, but it's such a pfusch

This commit is contained in:
Sebastian Moser
2024-08-22 11:17:01 +02:00
parent 89c490fadb
commit 5a25fd7161
11 changed files with 276 additions and 40 deletions

View File

@@ -160,7 +160,7 @@ impl Instance {
}
pub fn migrate_to_store(&self, new_store: Box<dyn Store>) -> MizeResult<()> {
println!("MIGRATING");
info!("MIGRATING");
let mut old_store = self.store.lock()?;
let id = self.id_from_string("0".to_owned())?;

View File

@@ -57,8 +57,6 @@ pub fn handle_operation(operation: &mut Operation, instance: &Instance) -> MizeR
//check subs and handle them
let mut subs_inner = instance.subs.lock()?;
println!("goooooooooooooooooot some subs: {:?}", subs_inner);
println!("some subs id: {:?}", id);
if let Some(vec) = subs_inner.get_mut(&id) {
let update = Update {
instance: Arc::new(instance.to_owned()),

View File

@@ -1,6 +1,7 @@
use tracing::{debug, error, info, instrument, trace, warn, Instrument};
use serde::Serialize;
use core::fmt;
use std::fmt::Debug;
use std::{i128, string};
use std::{collections::HashMap, path::PathBuf, io::Cursor, fmt::Display};
use std::fs::File;
@@ -105,16 +106,17 @@ impl Item<'_> {
}
}
pub fn merge<V: Into<ItemData>>(&mut self, mut value: V) -> MizeResult<()> {
#[instrument(name = "fn.ItemData::merge")]
pub fn merge<V: Into<ItemData> + Debug >(&mut self, mut value: V) -> MizeResult<()> {
let mut data = self.as_data_full()?;
println!("item::merge data: {:?}", data);
println!("item::merge id: {:?}", self.id());
trace!("item::merge data: {:?}", data);
trace!("item::merge id: {:?}", self.id());
let new_data = value.into();
data.merge(new_data);
println!("item::merge new_data: {:?}", data);
trace!("item::merge new_data: {:?}", data);
if self.instance.we_are_namespace()? {
let store_inner = self.instance.store.lock()?;
@@ -212,7 +214,6 @@ pub fn item_data_get_path(data: &CborValue, path: Vec<String>) -> MizeResult<&Cb
//println!("path_el: {}", path_el);
if let CborValue::Text(key_str) = key {
if key_str == &path_el {
println!("setting sub_data to: {:?}", val);
sub_data = val;
}
}
@@ -332,7 +333,7 @@ pub fn item_data_merge(merge_into: &mut CborValue, other: &CborValue){
}
}
#[instrument]
#[instrument(name = "fn.get_raw_from_cbor")]
pub fn get_raw_from_cbor<'a>(value: &'a CborValue, path: Vec<&String>) -> MizeResult<&'a [u8]> {
trace!("[ {} ] value: {:?}", "ARG".yellow(), value);
trace!("[ {} ] path: {:?}", "ARG".yellow(), path);

View File

@@ -44,14 +44,14 @@ impl Store for MemStore {
Ok(Vec::new())
}
fn new_id(&self) -> MizeResult<String> {
println!("are we hereeeeeee memstore new_get");
let mut inner = self.inner.lock()?;
let id_string = format!("{}", inner.next_id);
inner.next_id += 1;
return Ok(id_string);
}
#[instrument(name="MemStore::get_value_raw" skip(self))]
#[instrument(name="fn.MemStore::get_value_raw" skip(self))]
fn get_value_raw(&self, id: MizeId) -> MizeResult<Vec<u8>> {
trace!("[ {} ] id: {:?}", "ARG".yellow(), id);
let inner = self.inner.lock()?;
@@ -90,7 +90,6 @@ impl Store for MemStore {
}
fn next_id(&self, prev_id_str: &str) -> MizeResult<Option<String>> {
println!("next_id: prev_id_str: {}", prev_id_str);
let inner = self.inner.lock()?;
let mut id = str_to_u64(prev_id_str)?;