Skip to content

Commit 36747fc

Browse files
committed
java core 1.2.0 - added method to log byte array
1 parent f0114f6 commit 36747fc

File tree

5 files changed

+37
-20
lines changed

5 files changed

+37
-20
lines changed

aws-lambda-java-core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>com.amazonaws</groupId>
55
<artifactId>aws-lambda-java-core</artifactId>
6-
<version>1.1.0</version>
6+
<version>1.2.0</version>
77
<packaging>jar</packaging>
88

99
<name>AWS Lambda Java Core Library</name>

aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/ClientContext.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
*
9-
* Provides information about cLient configuration and execution environment.
9+
* Provides information about client configuration and execution environment.
1010
*
1111
*/
1212
public interface ClientContext {

aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/Context.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public interface Context {
1717
* is reused for retries on the same request.
1818
* </p>
1919
*/
20-
public String getAwsRequestId();
20+
String getAwsRequestId();
2121

2222
/**
2323
* Gets the CloudWatch log group that this container is configured to log
@@ -27,13 +27,13 @@ public interface Context {
2727
* <ul>
2828
* <li>
2929
* If the container is not configured to log to CloudWatch.</li>
30-
* <li>
30+
* <li>
3131
* If the role provided to the function does not have sufficient
3232
* permissions.</li>
3333
* </ul>
3434
* </p>
3535
*/
36-
public String getLogGroupName();
36+
String getLogGroupName();
3737

3838
/**
3939
* Gets the CloudWatch log stream that this container is configured to log
@@ -49,55 +49,55 @@ public interface Context {
4949
* </ul>
5050
* </p>
5151
*/
52-
public String getLogStreamName();
52+
String getLogStreamName();
5353

5454
/**
5555
* Gets the name of the function being executed.
5656
*
5757
*/
58-
public String getFunctionName();
58+
String getFunctionName();
5959

6060
/**
6161
* Gets the version of the function being executed.
6262
*
6363
*/
64-
public String getFunctionVersion();
64+
String getFunctionVersion();
6565

6666
/**
6767
* Gets the function Arn of the resource being invoked.
6868
*
6969
*/
70-
public String getInvokedFunctionArn();
70+
String getInvokedFunctionArn();
7171

7272
/**
7373
* Gets information about the Amazon Cognito identity provider when invoked
7474
* through the AWS Mobile SDK. It can be null
7575
*
7676
*/
77-
public CognitoIdentity getIdentity();
77+
CognitoIdentity getIdentity();
7878

7979
/**
8080
* Gets information about the client application and device when invoked
8181
* through the AWS Mobile SDK. It can be null.
8282
*
8383
*/
84-
public ClientContext getClientContext();
84+
ClientContext getClientContext();
8585

8686
/**
8787
* Gets the time remaining for this execution in milliseconds
8888
*/
89-
public int getRemainingTimeInMillis();
89+
int getRemainingTimeInMillis();
9090

9191
/**
9292
* Gets the memory size configured for the Lambda function
9393
*
9494
*/
95-
public int getMemoryLimitInMB();
95+
int getMemoryLimitInMB();
9696

9797
/**
98-
* Gets a the lambda logger instance associated with the context object
98+
* Gets the lambda logger instance associated with the context object
9999
*
100100
*/
101-
public LambdaLogger getLogger();
101+
LambdaLogger getLogger();
102102

103103
}

aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/LambdaLogger.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ public interface LambdaLogger {
2323
* </ul>
2424
* </p>
2525
*
26-
* @param string A string containing the event to log.
26+
* @param message A string containing the event to log.
2727
*/
28-
public void log(String string);
28+
public void log(String message);
29+
30+
/**
31+
* Logs a byte array to AWS CloudWatch Logs
32+
* @param message byte array containing logs
33+
*/
34+
public void log(byte[] message);
2935
}
3036

aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/LambdaRuntime.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
2-
32
package com.amazonaws.services.lambda.runtime;
43

4+
import java.io.IOException;
5+
56
public final class LambdaRuntime {
67
private LambdaRuntime() {}
78

89
private static volatile LambdaLogger logger = new LambdaLogger() {
9-
public void log(String string) {
10-
System.out.print(string);
10+
11+
public void log(String message) {
12+
System.out.print(message);
13+
}
14+
15+
public void log(byte[] message) {
16+
try {
17+
System.out.write(message);
18+
} catch (IOException e) {
19+
// NOTE: When actually running on AWS Lambda, an IOException would never happen
20+
e.printStackTrace();
21+
}
1122
}
1223
};
1324

0 commit comments

Comments
 (0)