notecrumbs

a nostr opengraph server build on nostrdb and egui
git clone git://jb55.com/notecrumbs
Log | Files | Refs | README | LICENSE

commit 5d664fbd4bf94fb2c9a20d36de08b7efc29a35ce
parent e8637be5c55c0aec585f59aeefe3fa18d9834374
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 31 Dec 2024 07:29:26 -0800

log: switch to tracing

This has less dependencies and is more compatible with other
libraries

Diffstat:
MCargo.lock | 60+++---------------------------------------------------------
MCargo.toml | 6+++---
Msrc/html.rs | 2+-
Msrc/main.rs | 6++++--
Msrc/render.rs | 2+-
5 files changed, 12 insertions(+), 64 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -666,19 +666,6 @@ dependencies = [ ] [[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - -[[package]] name = "epaint" version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -985,12 +972,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] -name = "hermit-abi" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" - -[[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1091,12 +1072,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] name = "hyper" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1332,17 +1307,6 @@ dependencies = [ ] [[package]] -name = "is-terminal" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.52.0", -] - -[[package]] name = "itertools" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1622,7 +1586,7 @@ dependencies = [ [[package]] name = "nostrdb" version = "0.5.1" -source = "git+https://github.com/damus-io/nostrdb-rs?rev=e8b6e258410ff8acb0f689f8cf2fe287e19c6280#e8b6e258410ff8acb0f689f8cf2fe287e19c6280" +source = "git+https://github.com/damus-io/nostrdb-rs?rev=77fbc99a55f6a5e939176085f9a95cf2a4e7eeb5#77fbc99a55f6a5e939176085f9a95cf2a4e7eeb5" dependencies = [ "bindgen 0.69.5", "cc", @@ -1643,7 +1607,6 @@ dependencies = [ "egui", "egui_extras", "egui_skia", - "env_logger", "hex", "html-escape", "http", @@ -1651,13 +1614,14 @@ dependencies = [ "hyper", "hyper-util", "image", - "log", "lru", "nostr", "nostr-sdk", "nostrdb", "skia-safe", "tokio", + "tracing", + "tracing-subscriber", ] [[package]] @@ -2361,15 +2325,6 @@ dependencies = [ ] [[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] name = "thiserror" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2938,15 +2893,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] -name = "winapi-util" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" -dependencies = [ - "windows-sys 0.59.0", -] - -[[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -11,9 +11,9 @@ hyper = { version = "1.1.0", features = ["full"] } tokio = { version = "1.1.0", features = ["full"] } hyper-util = { version = "0.1.1", features = ["full"] } http-body-util = "0.1" -log = "0.4.20" -env_logger = "0.10.1" -nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "e8b6e258410ff8acb0f689f8cf2fe287e19c6280" } +tracing = "0.1.41" +tracing-subscriber = "0.3.19" +nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "77fbc99a55f6a5e939176085f9a95cf2a4e7eeb5" } #nostrdb = { path = "/home/jb55/src/rust/nostrdb-rs" } #nostrdb = "0.1.6" #nostr-sdk = { git = "https://github.com/damus-io/nostr-sdk.git", rev = "fc0dc7b38f5060f171228b976b9700c0135245d3" } diff --git a/src/html.rs b/src/html.rs @@ -6,10 +6,10 @@ use crate::{ }; use http_body_util::Full; use hyper::{body::Bytes, header, Request, Response, StatusCode}; -use log::{error, warn}; use nostr_sdk::prelude::{Nip19, ToBech32}; use nostrdb::{BlockType, Blocks, Mention, Note, Transaction}; use std::io::Write; +use tracing::{error, warn}; pub fn render_note_content(body: &mut Vec<u8>, note: &Note, blocks: &Blocks) { for block in blocks.iter(note) { diff --git a/src/main.rs b/src/main.rs @@ -7,10 +7,10 @@ use hyper::server::conn::http1; use hyper::service::service_fn; use hyper::{Request, Response, StatusCode}; use hyper_util::rt::TokioIo; -use log::{error, info}; use std::io::Write; use std::sync::Arc; use tokio::net::TcpListener; +use tracing::{error, info}; use crate::{ error::Error, @@ -222,7 +222,9 @@ fn get_default_pfp() -> egui::ColorImage { #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { - env_logger::init(); + use tracing_subscriber; + + tracing_subscriber::fmt::init(); let addr = SocketAddr::from(([0, 0, 0, 0], 3000)); diff --git a/src/render.rs b/src/render.rs @@ -6,7 +6,7 @@ use egui::{ Color32, FontFamily, FontId, Mesh, Rect, RichText, Rounding, Shape, TextureHandle, Vec2, Visuals, }; -use log::{debug, error, warn}; +use tracing::{debug, error, warn}; use nostr::event::kind::Kind; use nostr::types::{SingleLetterTag, Timestamp}; use nostr_sdk::async_utility::futures_util::StreamExt;