1
1
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
2
2
use std:: sync:: Arc ;
3
3
4
+ use kv_log_macro:: trace;
4
5
use tide:: http:: mime;
5
6
use tide:: utils:: { After , Before } ;
6
7
use tide:: { Middleware , Next , Request , Response , Result , StatusCode } ;
@@ -25,7 +26,7 @@ impl UserDatabase {
25
26
// it would likely be closely tied to a specific application
26
27
async fn user_loader ( mut request : Request , next : Next ) -> Result {
27
28
if let Some ( user) = request. state :: < UserDatabase > ( ) . find_user ( ) . await {
28
- tide :: log :: trace!( "user loaded" , { user: user. name} ) ;
29
+ trace ! ( "user loaded" , { user: user. name} ) ;
29
30
request. set_ext ( user) ;
30
31
Ok ( next. run ( request) . await )
31
32
// this middleware only needs to run before the endpoint, so
@@ -57,7 +58,7 @@ struct RequestCount(usize);
57
58
impl Middleware for RequestCounterMiddleware {
58
59
async fn handle ( & self , mut req : Request , next : Next ) -> Result {
59
60
let count = self . requests_counted . fetch_add ( 1 , Ordering :: Relaxed ) ;
60
- tide :: log :: trace!( "request counter" , { count: count } ) ;
61
+ trace ! ( "request counter" , { count: count } ) ;
61
62
req. set_ext ( RequestCount ( count) ) ;
62
63
63
64
let mut res = next. run ( req) . await ;
@@ -84,7 +85,7 @@ const INTERNAL_SERVER_ERROR_HTML_PAGE: &str = "<html><body>
84
85
85
86
#[ async_std:: main]
86
87
async fn main ( ) -> Result < ( ) > {
87
- tide :: log :: start ( ) ;
88
+ femme :: start ( ) ;
88
89
let mut app = tide:: with_state ( UserDatabase :: default ( ) ) ;
89
90
90
91
app. with ( After ( |response : Response | async move {
0 commit comments