use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-lambda-developer-guide by awsdocs.
the class Handler method handleRequest.
@Override
public String handleRequest(Map<String, String> event, Context context) {
LambdaLogger logger = context.getLogger();
String response = new String("200 OK");
// log execution details
logger.log("ENVIRONMENT VARIABLES: " + gson.toJson(System.getenv()));
logger.log("CONTEXT: " + gson.toJson(context));
// process event
logger.log("EVENT: " + gson.toJson(event));
logger.log("EVENT TYPE: " + event.getClass().toString());
return response;
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-lambda-developer-guide by awsdocs.
the class HandlerDivide method handleRequest.
@Override
public Integer handleRequest(List<Integer> event, Context context) {
LambdaLogger logger = context.getLogger();
// process event
if (event.size() != 2) {
throw new InputLengthException("Input must be an array that contains 2 numbers.");
}
int numerator = event.get(0);
int denominator = event.get(1);
logger.log("EVENT: " + gson.toJson(event));
logger.log("EVENT TYPE: " + event.getClass().toString());
return numerator / denominator;
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-lambda-developer-guide by awsdocs.
the class HandlerList method handleRequest.
@Override
public Integer handleRequest(List<Integer> event, Context context) {
LambdaLogger logger = context.getLogger();
// process event
logger.log("EVENT: " + gson.toJson(event));
logger.log("EVENT TYPE: " + event.getClass().toString());
return context.getRemainingTimeInMillis();
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-lambda-developer-guide by awsdocs.
the class HandlerStream method handleRequest.
@Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException {
LambdaLogger logger = context.getLogger();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("US-ASCII")));
PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream, Charset.forName("US-ASCII"))));
try {
HashMap event = gson.fromJson(reader, HashMap.class);
logger.log("STREAM TYPE: " + inputStream.getClass().toString());
logger.log("EVENT TYPE: " + event.getClass().toString());
writer.write(gson.toJson(event));
if (writer.checkError()) {
logger.log("WARNING: Writer encountered an error.");
}
} catch (IllegalStateException | JsonSyntaxException exception) {
logger.log(exception.toString());
} finally {
reader.close();
writer.close();
}
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-lambda-developer-guide by awsdocs.
the class HandlerWeatherData method handleRequest.
@Override
public WeatherData handleRequest(WeatherData event, Context context) {
LambdaLogger logger = context.getLogger();
// process event
logger.log("EVENT: " + gson.toJson(event));
logger.log("EVENT TYPE: " + event.getClass().toString());
return event;
}
Aggregations