feat: replace logging with tracing

This commit is contained in:
Greg Heartsfield
2022-09-28 07:19:59 -05:00
parent 93dfed0a87
commit 6633f8b472
12 changed files with 118 additions and 64 deletions
+1 -1
View File
@@ -1,8 +1,8 @@
//! Configuration file and settings management
use config::{Config, ConfigError, File};
use log::warn;
use serde::{Deserialize, Serialize};
use std::time::Duration;
use tracing::warn;
#[derive(Debug, Serialize, Deserialize, Clone)]
#[allow(unused)]
+1 -1
View File
@@ -5,8 +5,8 @@ use crate::error::Result;
use crate::event::Event;
use crate::subscription::Subscription;
use log::{debug, info};
use std::collections::HashMap;
use tracing::{debug, info};
use uuid::Uuid;
/// A subscription identifier has a maximum length
+1 -1
View File
@@ -13,7 +13,6 @@ use crate::utils::{is_hex, is_lower_hex};
use governor::clock::Clock;
use governor::{Quota, RateLimiter};
use hex;
use log::{debug, info, trace, warn};
use r2d2;
use r2d2_sqlite::SqliteConnectionManager;
use rusqlite::params;
@@ -25,6 +24,7 @@ use std::thread;
use std::time::Duration;
use std::time::Instant;
use tokio::task;
use tracing::{debug, info, trace, warn};
pub type SqlitePool = r2d2::Pool<r2d2_sqlite::SqliteConnectionManager>;
pub type PooledConnection = r2d2::PooledConnection<r2d2_sqlite::SqliteConnectionManager>;
+1 -1
View File
@@ -5,7 +5,6 @@ use crate::nip05;
use crate::utils::unix_time;
use bitcoin_hashes::{sha256, Hash};
use lazy_static::lazy_static;
use log::*;
use secp256k1::{schnorr, Secp256k1, VerifyOnly, XOnlyPublicKey};
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::value::Value;
@@ -13,6 +12,7 @@ use serde_json::Number;
use std::collections::HashMap;
use std::collections::HashSet;
use std::str::FromStr;
use tracing::{debug, info};
lazy_static! {
/// Secp256k1 verification instance.
+4 -4
View File
@@ -1,11 +1,12 @@
//! Server process
use log::info;
use nostr_rs_relay::config;
use nostr_rs_relay::server::start_server;
use std::env;
use std::sync::mpsc as syncmpsc;
use std::sync::mpsc::{Receiver as MpscReceiver, Sender as MpscSender};
use std::thread;
use tracing::info;
use console_subscriber::ConsoleLayer;
@@ -19,10 +20,9 @@ fn db_from_args(args: &[String]) -> Option<String> {
/// Start running a Nostr relay server.
fn main() {
// setup logger
let _ = env_logger::try_init();
// setup tracing
let _trace_sub = tracing_subscriber::fmt::try_init();
info!("Starting up from main");
// get database directory from args
let args: Vec<String> = env::args().collect();
let db_dir: Option<String> = db_from_args(&args);
+1 -1
View File
@@ -13,13 +13,13 @@ use hyper::body::HttpBody;
use hyper::client::connect::HttpConnector;
use hyper::Client;
use hyper_tls::HttpsConnector;
use log::*;
use rand::Rng;
use rusqlite::params;
use std::time::Duration;
use std::time::Instant;
use std::time::SystemTime;
use tokio::time::Interval;
use tracing::{debug, info, warn};
/// NIP-05 verifier state
pub struct Verifier {
+1 -1
View File
@@ -3,11 +3,11 @@ use crate::db::PooledConnection;
use crate::error::Result;
use crate::event::{single_char_tagname, Event};
use crate::utils::is_lower_hex;
use log::*;
use rusqlite::limits::Limit;
use rusqlite::params;
use rusqlite::Connection;
use std::time::Instant;
use tracing::{debug, error, info};
/// Startup DB Pragmas
pub const STARTUP_SQL: &str = r##"
+1 -1
View File
@@ -19,7 +19,6 @@ use hyper::upgrade::Upgraded;
use hyper::{
header, server::conn::AddrStream, upgrade, Body, Request, Response, Server, StatusCode,
};
use log::*;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::collections::HashMap;
@@ -34,6 +33,7 @@ use tokio::sync::broadcast::{self, Receiver, Sender};
use tokio::sync::mpsc;
use tokio::sync::oneshot;
use tokio_tungstenite::WebSocketStream;
use tracing::*;
use tungstenite::error::CapacityError::MessageTooLong;
use tungstenite::error::Error as WsError;
use tungstenite::handshake;