Skip to content

Commit

Permalink
java core 1.2.0 - added method to log byte array
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoffatt committed Nov 22, 2017
1 parent f0114f6 commit 36747fc
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
2 changes: 1 addition & 1 deletion aws-lambda-java-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
<packaging>jar</packaging>

<name>AWS Lambda Java Core Library</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
*
* Provides information about cLient configuration and execution environment.
* Provides information about client configuration and execution environment.
*
*/
public interface ClientContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface Context {
* is reused for retries on the same request.
* </p>
*/
public String getAwsRequestId();
String getAwsRequestId();

/**
* Gets the CloudWatch log group that this container is configured to log
Expand All @@ -27,13 +27,13 @@ public interface Context {
* <ul>
* <li>
* If the container is not configured to log to CloudWatch.</li>
* <li>
* <li>
* If the role provided to the function does not have sufficient
* permissions.</li>
* </ul>
* </p>
*/
public String getLogGroupName();
String getLogGroupName();

/**
* Gets the CloudWatch log stream that this container is configured to log
Expand All @@ -49,55 +49,55 @@ public interface Context {
* </ul>
* </p>
*/
public String getLogStreamName();
String getLogStreamName();

/**
* Gets the name of the function being executed.
*
*/
public String getFunctionName();
String getFunctionName();

/**
* Gets the version of the function being executed.
*
*/
public String getFunctionVersion();
String getFunctionVersion();

/**
* Gets the function Arn of the resource being invoked.
*
*/
public String getInvokedFunctionArn();
String getInvokedFunctionArn();

/**
* Gets information about the Amazon Cognito identity provider when invoked
* through the AWS Mobile SDK. It can be null
*
*/
public CognitoIdentity getIdentity();
CognitoIdentity getIdentity();

/**
* Gets information about the client application and device when invoked
* through the AWS Mobile SDK. It can be null.
*
*/
public ClientContext getClientContext();
ClientContext getClientContext();

/**
* Gets the time remaining for this execution in milliseconds
*/
public int getRemainingTimeInMillis();
int getRemainingTimeInMillis();

/**
* Gets the memory size configured for the Lambda function
*
*/
public int getMemoryLimitInMB();
int getMemoryLimitInMB();

/**
* Gets a the lambda logger instance associated with the context object
* Gets the lambda logger instance associated with the context object
*
*/
public LambdaLogger getLogger();
LambdaLogger getLogger();

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ public interface LambdaLogger {
* </ul>
* </p>
*
* @param string A string containing the event to log.
* @param message A string containing the event to log.
*/
public void log(String string);
public void log(String message);

/**
* Logs a byte array to AWS CloudWatch Logs
* @param message byte array containing logs
*/
public void log(byte[] message);
}

Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */

package com.amazonaws.services.lambda.runtime;

import java.io.IOException;

public final class LambdaRuntime {
private LambdaRuntime() {}

private static volatile LambdaLogger logger = new LambdaLogger() {
public void log(String string) {
System.out.print(string);

public void log(String message) {
System.out.print(message);
}

public void log(byte[] message) {
try {
System.out.write(message);
} catch (IOException e) {
// NOTE: When actually running on AWS Lambda, an IOException would never happen
e.printStackTrace();
}
}
};

Expand Down

0 comments on commit 36747fc

Please sign in to comment.