use of com.amazonaws.services.lambda.runtime.LambdaLogger in project tutorials by csh0034.
the class APIGatewayEventHandler method handleRequest.
@Override
public String handleRequest(APIGatewayProxyRequestEvent input, Context context) {
LambdaLogger logger = context.getLogger();
logger.log("invoke APIGatewayEventHandler::handleRequest");
return input.getBody();
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-java-serverless by hermanlintvelt.
the class RoadmapsHandlerTest method setUp.
@BeforeEach
public void setUp() {
subject = new RoadmapsHandler();
testContext = new Context() {
@Override
public String getAwsRequestId() {
return null;
}
@Override
public String getLogGroupName() {
return null;
}
@Override
public String getLogStreamName() {
return null;
}
// implement all methods of this interface and setup your test context.
// For instance, the function name:
@Override
public String getFunctionName() {
return "ExampleAwsLambda";
}
@Override
public String getFunctionVersion() {
return null;
}
@Override
public String getInvokedFunctionArn() {
return null;
}
@Override
public CognitoIdentity getIdentity() {
return null;
}
@Override
public ClientContext getClientContext() {
return null;
}
@Override
public int getRemainingTimeInMillis() {
return 0;
}
@Override
public int getMemoryLimitInMB() {
return 0;
}
@Override
public LambdaLogger getLogger() {
return null;
}
};
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-java-serverless by hermanlintvelt.
the class HandlerTest method setUp.
@BeforeEach
public void setUp() {
subject = new Handler();
testContext = new Context() {
@Override
public String getAwsRequestId() {
return null;
}
@Override
public String getLogGroupName() {
return null;
}
@Override
public String getLogStreamName() {
return null;
}
// implement all methods of this interface and setup your test context.
// For instance, the function name:
@Override
public String getFunctionName() {
return "ExampleAwsLambda";
}
@Override
public String getFunctionVersion() {
return null;
}
@Override
public String getInvokedFunctionArn() {
return null;
}
@Override
public CognitoIdentity getIdentity() {
return null;
}
@Override
public ClientContext getClientContext() {
return null;
}
@Override
public int getRemainingTimeInMillis() {
return 0;
}
@Override
public int getMemoryLimitInMB() {
return 0;
}
@Override
public LambdaLogger getLogger() {
return null;
}
};
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project preston by bio-guoda.
the class AWSEventHandler method handleRequest.
@Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException {
LambdaLogger logger = context.getLogger();
RequestData requestData = gson.fromJson(IOUtils.toString(inputStream, StandardCharsets.UTF_8), RequestData.class);
logger.log("Received request with body " + gson.toJson(requestData));
CmdGet get = new CmdGet();
get.setDisableCache(true);
get.setInputStream(IOUtils.toInputStream(requestData.id, StandardCharsets.UTF_8));
get.setRemotes(Collections.singletonList(requestData.remote));
get.setOutputStream(outputStream);
get.run();
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-ingesting-click-logs-using-terraform by aws-samples.
the class ClickLoggerHandler method handleRequest.
@Override
public ClickLogResponse handleRequest(final ClickLogRequest clickLogRequest, final Context context) {
final LambdaLogger logger = context.getLogger();
final String success_response = new String("200 OK");
final String fail_response = new String("200 OK");
ResponseBuilder responseBuilder = new ResponseBuilder();
ClickLogResponse response = responseBuilder.badRequest(fail_response).build();
String req = clickLogRequest.getRequestid() + " - " + clickLogRequest.getCallerid() + " - " + clickLogRequest.getComponent() + " - " + clickLogRequest.getType() + " - " + clickLogRequest.getAction() + " - " + clickLogRequest.getUser() + " - " + clickLogRequest.getClientip() + " - " + clickLogRequest.getCreatedtime();
logger.log("Incoming request variables - " + req);
String env_stream_name = System.getenv("STREAM_NAME");
if (!StringUtils.isBlank(env_stream_name)) {
stream_name = env_stream_name;
}
// System.getenv("REGION");
String env_region = System.getenv("AWS_REGION");
logger.log("Environment region name - " + env_region);
if (!StringUtils.isBlank(env_region)) {
region = env_region;
}
if (clickLogRequest != null) {
logger.log("Validating inputs");
if (StringUtils.isBlank(clickLogRequest.getRequestid())) {
logger.log("error occurred - requestid missing");
return response;
}
if (StringUtils.isBlank(clickLogRequest.getContextid())) {
logger.log("error occurred - contextid missing");
return response;
}
if (StringUtils.isBlank(clickLogRequest.getCallerid())) {
logger.log("error occurred - caller missing");
return response;
}
if (StringUtils.isBlank(clickLogRequest.getType())) {
logger.log("error occurred - type missing");
return response;
}
if (StringUtils.isBlank(clickLogRequest.getAction())) {
logger.log("error occurred - action missing");
return response;
}
if (StringUtils.isBlank(clickLogRequest.getComponent())) {
logger.log("error occurred - component missing");
return response;
}
String user = "GUEST";
if (StringUtils.isBlank(clickLogRequest.getUser())) {
logger.log("setting default user");
clickLogRequest.setUser(user);
}
String clientip = "APIGWY";
if (StringUtils.isBlank(clickLogRequest.getClientip())) {
logger.log("setting default clientip");
clickLogRequest.setClientip(clientip);
}
String datetime = "";
if (StringUtils.isBlank(clickLogRequest.getCreatedtime())) {
logger.log("setting default createdtime");
Format f = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss");
datetime = f.format(new Date());
clickLogRequest.setCreatedtime(datetime);
}
logger.log("Validated inputs");
}
System.out.println("Calling updateclicklogs method for the received clicklogrequest");
updateClickLogRequestToStream(clickLogRequest);
logger.log(success_response);
responseBuilder = new ResponseBuilder();
responseBuilder.ok();
response = responseBuilder.originHeader("*").build();
return response;
}
Aggregations