Unverified Commit 169b001c authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Add cloudwatch logs & usage example (#526)

* Add cloudwatch logs & usage example

* Update author field
parent 46a9e817
Loading
Loading
Loading
Loading
+4239 −0

File added.

Preview size limit exceeded, changes collapsed.

+14 −0
Original line number Diff line number Diff line
[package]
name = "cloudwatchlogs-code-examples"
version = "0.1.0"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>", "Russell Cohen <rcoh@amazon.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cloudwatchlogs = { package = "aws-sdk-cloudwatchlogs", path = "../../build/aws-sdk/cloudwatchlogs" }
tokio = { version = "1", features = ["full"] }
structopt = { version = "0.3", default-features = false }
tracing-subscriber = { version = "0.2.16", features = ["fmt"] }
aws-types = { path = "../../build/aws-sdk/aws-types" }
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

use cloudwatchlogs::Client;

#[tokio::main]
async fn main() -> Result<(), cloudwatchlogs::Error> {
    tracing_subscriber::fmt::init();

    let client = Client::from_env();
    /* uncomment to create a log group */
    /*
    client
        .create_log_group()
        .log_group_name("test-logs")
        .send()
        .await?;

    client
        .create_log_stream()
        .log_group_name("test-logs")
        .log_stream_name("test-stream")
        .send()
        .await?;
     */
    let log_events = client
        .get_log_events()
        .log_group_name("test-logs")
        .log_stream_name("test-stream")
        .send()
        .await?;
    let events = log_events.events.unwrap_or_default();
    println!("number of events: {}", events.len());
    for event in events {
        println!("message: {}", event.message.unwrap_or_default());
    }
    Ok(())
}
+1 −1
Original line number Diff line number Diff line
[package]
name = "iam"
name = "iam-code-examples"
version = "0.1.0"
authors = ["Russell Cohen <rcoh@amazon.com>"]
edition = "2018"