@@ -2,8 +2,7 @@ use lambda_http::{
22 lambda_runtime:: { self , Context , Error } ,
33 IntoResponse , Request , Response ,
44} ;
5- use log:: { info, LevelFilter } ;
6- use simple_logger:: SimpleLogger ;
5+ use tracing:: info;
76
87async fn handler ( event : Request , _context : Context ) -> Result < impl IntoResponse , Error > {
98 info ! ( "[http-fn] Received event {} {}" , event. method( ) , event. uri( ) . path( ) ) ;
@@ -13,7 +12,16 @@ async fn handler(event: Request, _context: Context) -> Result<impl IntoResponse,
1312
1413#[ tokio:: main]
1514async 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 ( ) ;
1725
1826 lambda_runtime:: run ( lambda_http:: handler ( handler) ) . await
1927}
0 commit comments