File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed
Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ pub mod config;
1717pub mod context;
1818pub mod errors;
1919pub mod handlers;
20+ pub mod logger;
2021pub mod requests;
2122pub mod responses;
2223pub mod routes;
Original file line number Diff line number Diff line change 1+ // Copyright (c) wangeguo. All rights reserved.
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
15+ use tracing:: metadata:: LevelFilter ;
16+ use tracing_subscriber:: EnvFilter ;
17+
18+ pub fn setup ( ) {
19+ let filter =
20+ EnvFilter :: builder ( ) . with_default_directive ( LevelFilter :: DEBUG . into ( ) ) . from_env_lossy ( ) ;
21+ tracing_subscriber:: fmt ( ) . with_env_filter ( filter) . init ( ) ;
22+ }
Original file line number Diff line number Diff line change 1515use std:: sync:: Arc ;
1616
1717use clap:: Parser ;
18- use codecraft:: { app, config:: Config , context:: Context } ;
19- use tracing:: metadata:: LevelFilter ;
20- use tracing_subscriber:: EnvFilter ;
18+ use codecraft:: { app, config:: Config , context:: Context , logger} ;
2119
2220#[ tokio:: main]
2321async fn main ( ) -> anyhow:: Result < ( ) > {
24- let filter =
25- EnvFilter :: builder ( ) . with_default_directive ( LevelFilter :: DEBUG . into ( ) ) . from_env_lossy ( ) ;
26- tracing_subscriber:: fmt ( ) . with_env_filter ( filter) . init ( ) ;
22+ logger:: setup ( ) ;
2723
2824 // This returns an error if the `.env` file doesn't exist, but that's not what we want
2925 // since we're not going to use a `.env` file if we deploy this application.
You can’t perform that action at this time.
0 commit comments