@@ -2,8 +2,7 @@ use lambda_http::{
2
2
lambda_runtime:: { self , Context , Error } ,
3
3
IntoResponse , Request , Response ,
4
4
} ;
5
- use log:: { info, LevelFilter } ;
6
- use simple_logger:: SimpleLogger ;
5
+ use tracing:: info;
7
6
8
7
async fn handler ( event : Request , _context : Context ) -> Result < impl IntoResponse , Error > {
9
8
info ! ( "[http-fn] Received event {} {}" , event. method( ) , event. uri( ) . path( ) ) ;
@@ -13,7 +12,16 @@ async fn handler(event: Request, _context: Context) -> Result<impl IntoResponse,
13
12
14
13
#[ tokio:: main]
15
14
async fn main ( ) -> Result < ( ) , Error > {
16
- SimpleLogger :: new ( ) . with_level ( LevelFilter :: Info ) . init ( ) . unwrap ( ) ;
15
+ // The runtime logging can be enabled here by initializing `tracing` with `tracing-subscriber`
16
+ // While `tracing` is used internally, `log` can be used as well if preferred.
17
+ tracing_subscriber:: fmt ( )
18
+ . with_max_level ( tracing:: Level :: INFO )
19
+ // this needs to be set to false, otherwise ANSI color codes will
20
+ // show up in a confusing manner in CloudWatch logs.
21
+ . with_ansi ( false )
22
+ // disabling time is handy because CloudWatch will add the ingestion time.
23
+ . without_time ( )
24
+ . init ( ) ;
17
25
18
26
lambda_runtime:: run ( lambda_http:: handler ( handler) ) . await
19
27
}
0 commit comments