Skip to content

lambda-extension: remove logging #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lambda-extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 3 additions & 8 deletions lambda-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,21 @@ 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(())
}

#[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
}
Expand All @@ -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.
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.
6 changes: 0 additions & 6 deletions lambda-extension/examples/basic.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
}
6 changes: 0 additions & 6 deletions lambda-extension/examples/custom_events.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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?;
Expand Down
6 changes: 0 additions & 6 deletions lambda-extension/examples/custom_trait_implementation.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
}