diff --git a/lambda-extension/Cargo.toml b/lambda-extension/Cargo.toml index f5b101c1..10c65e40 100644 --- a/lambda-extension/Cargo.toml +++ b/lambda-extension/Cargo.toml @@ -24,6 +24,4 @@ tokio-stream = "0.1.2" lambda_runtime_api_client = { version = "0.4", path = "../lambda-runtime-api-client" } [dev-dependencies] -simple_logger = "1.6.0" -log = "^0.4" simple-error = "0.2" diff --git a/lambda-extension/README.md b/lambda-extension/README.md index 4982779f..0dc297d9 100644 --- a/lambda-extension/README.md +++ b/lambda-extension/README.md @@ -10,17 +10,14 @@ The code below creates a simple extension that's registered to every `INVOKE` an ```rust,no_run use lambda_extension::{extension_fn, Error, NextEvent}; -use log::LevelFilter; -use simple_logger::SimpleLogger; -use tracing::info; async fn log_extension(event: NextEvent) -> Result<(), Error> { match event { NextEvent::Shutdown(event) => { - info!("{}", event); + println!("Shutdown {:?}", event); } NextEvent::Invoke(event) => { - info!("{}", event); + println!("Invoke {:?}", event); } } Ok(()) @@ -28,8 +25,6 @@ async fn log_extension(event: NextEvent) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { - SimpleLogger::new().with_level(LevelFilter::Info).init().unwrap(); - let func = extension_fn(log_extension); lambda_extension::run(func).await } @@ -55,4 +50,4 @@ Then, you can compile the extension against that target: $ cargo build -p lambda_extension --example basic --release --target x86_64-unknown-linux-musl ``` -This previous command will generate a binary file in `target/x86_64-unknown-linux-musl/release/examples` called `basic`. When the extension is registered with the [Runtime Extensions API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html#runtimes-extensions-api-reg), that's the name that the extension will be registered with. If you want to register the extension with a different name, you only have to rename this binary file and deploy it with the new name. \ No newline at end of file +This previous command will generate a binary file in `target/x86_64-unknown-linux-musl/release/examples` called `basic`. When the extension is registered with the [Runtime Extensions API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html#runtimes-extensions-api-reg), that's the name that the extension will be registered with. If you want to register the extension with a different name, you only have to rename this binary file and deploy it with the new name. diff --git a/lambda-extension/examples/basic.rs b/lambda-extension/examples/basic.rs index 573b3281..af089d17 100644 --- a/lambda-extension/examples/basic.rs +++ b/lambda-extension/examples/basic.rs @@ -1,6 +1,4 @@ use lambda_extension::{extension_fn, Error, NextEvent}; -use log::LevelFilter; -use simple_logger::SimpleLogger; async fn my_extension(event: NextEvent) -> Result<(), Error> { match event { @@ -16,10 +14,6 @@ async fn my_extension(event: NextEvent) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { - // required to enable CloudWatch error logging by the runtime - // can be replaced with any other method of initializing `log` - SimpleLogger::new().with_level(LevelFilter::Info).init().unwrap(); - let func = extension_fn(my_extension); lambda_extension::run(func).await } diff --git a/lambda-extension/examples/custom_events.rs b/lambda-extension/examples/custom_events.rs index 88f040aa..f8a116ef 100644 --- a/lambda-extension/examples/custom_events.rs +++ b/lambda-extension/examples/custom_events.rs @@ -1,6 +1,4 @@ use lambda_extension::{extension_fn, Error, NextEvent, Runtime}; -use log::LevelFilter; -use simple_logger::SimpleLogger; async fn my_extension(event: NextEvent) -> Result<(), Error> { match event { @@ -18,10 +16,6 @@ async fn my_extension(event: NextEvent) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { - // required to enable CloudWatch error logging by the runtime - // can be replaced with any other method of initializing `log` - SimpleLogger::new().with_level(LevelFilter::Info).init().unwrap(); - let func = extension_fn(my_extension); let runtime = Runtime::builder().with_events(&["SHUTDOWN"]).register().await?; diff --git a/lambda-extension/examples/custom_trait_implementation.rs b/lambda-extension/examples/custom_trait_implementation.rs index caef7730..6f42f437 100644 --- a/lambda-extension/examples/custom_trait_implementation.rs +++ b/lambda-extension/examples/custom_trait_implementation.rs @@ -1,6 +1,4 @@ use lambda_extension::{run, Error, Extension, InvokeEvent, NextEvent}; -use log::LevelFilter; -use simple_logger::SimpleLogger; use std::{ future::{ready, Future}, pin::Pin, @@ -28,9 +26,5 @@ impl Extension for MyExtension { #[tokio::main] async fn main() -> Result<(), Error> { - // required to enable CloudWatch error logging by the runtime - // can be replaced with any other method of initializing `log` - SimpleLogger::new().with_level(LevelFilter::Info).init().unwrap(); - run(MyExtension::default()).await }