Search in sources :

Example 51 with LambdaLogger

use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-lambda-developer-guide by awsdocs.

the class HandlerCWEvents method handleRequest.

@Override
public String handleRequest(ScheduledEvent event, Context context) {
    LambdaLogger logger = context.getLogger();
    String response = new String("200 OK");
    // log execution details
    Util.logEnvironment(event, context, gson);
    return response;
}
Also used : LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger)

Example 52 with LambdaLogger

use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-lambda-developer-guide by awsdocs.

the class HandlerCWLogs method handleRequest.

@Override
public String handleRequest(CloudWatchLogsEvent event, Context context) {
    LambdaLogger logger = context.getLogger();
    String response = new String("200 OK");
    Decoder decoder = Base64.getDecoder();
    byte[] decodedEvent = decoder.decode(event.getAwsLogs().getData());
    StringBuilder output = new StringBuilder();
    try {
        GZIPInputStream inputStream = new GZIPInputStream(new ByteArrayInputStream(decodedEvent));
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        bufferedReader.lines().forEach(line -> {
            logger.log(line);
            output.append(line);
        });
        logger.log(output.toString());
    } catch (IOException e) {
        logger.log("ERROR: " + e.toString());
    }
    // log execution details
    Util.logEnvironment(event, context, gson);
    return response;
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger) Decoder(java.util.Base64.Decoder)

Example 53 with LambdaLogger

use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-lambda-developer-guide by awsdocs.

the class HandlerCloudFront method handleRequest.

@Override
public String handleRequest(CloudFrontEvent event, Context context) {
    LambdaLogger logger = context.getLogger();
    String response = new String("200 OK");
    // log execution details
    Util.logEnvironment(event, context, gson);
    return response;
}
Also used : LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger)

Example 54 with LambdaLogger

use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-lambda-developer-guide by awsdocs.

the class HandlerCodeCommit method handleRequest.

@Override
public String handleRequest(CodeCommitEvent event, Context context) {
    LambdaLogger logger = context.getLogger();
    String response = new String("200 OK");
    // log execution details
    Util.logEnvironment(event, context, gson);
    return response;
}
Also used : LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger)

Example 55 with LambdaLogger

use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-lambda-developer-guide by awsdocs.

the class HandlerLex method handleRequest.

@Override
public String handleRequest(LexEvent event, Context context) {
    LambdaLogger logger = context.getLogger();
    String response = new String("200 OK");
    // log execution details
    Util.logEnvironment(event, context, gson);
    return response;
}
Also used : LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger)

Aggregations

LambdaLogger (com.amazonaws.services.lambda.runtime.LambdaLogger)59 HashMap (java.util.HashMap)10 Date (java.util.Date)9 List (java.util.List)8 Map (java.util.Map)8 Context (com.amazonaws.services.lambda.runtime.Context)6 ApiAuthorizer (com.formkiq.lambda.apigateway.ApiAuthorizer)6 ApiGatewayRequestEvent (com.formkiq.lambda.apigateway.ApiGatewayRequestEvent)6 ApiGatewayRequestEventUtil (com.formkiq.lambda.apigateway.ApiGatewayRequestEventUtil)6 ApiGatewayRequestHandler (com.formkiq.lambda.apigateway.ApiGatewayRequestHandler)6 ApiRequestHandlerResponse (com.formkiq.lambda.apigateway.ApiRequestHandlerResponse)6 IOException (java.io.IOException)6 SC_OK (com.formkiq.lambda.apigateway.ApiResponseStatus.SC_OK)5 AwsServiceCache (com.formkiq.lambda.apigateway.AwsServiceCache)5 BadException (com.formkiq.lambda.apigateway.exception.BadException)5 DynamicObject (com.formkiq.stacks.common.objects.DynamicObject)5 Collectors (java.util.stream.Collectors)5 ClientContext (com.amazonaws.services.lambda.runtime.ClientContext)4 CognitoIdentity (com.amazonaws.services.lambda.runtime.CognitoIdentity)4 ApiMapResponse (com.formkiq.lambda.apigateway.ApiMapResponse)4