use of com.amazonaws.services.logs.AWSLogsClientBuilder in project quarkus-logging-cloudwatch by quarkiverse.
the class LoggingCloudWatchHandlerValueFactory method create.
public RuntimeValue<Optional<Handler>> create(final LoggingCloudWatchConfig config) {
if (!config.enabled) {
LOGGER.fine("Quarkus Logging Cloudwatch Extension is not enabled");
return new RuntimeValue<>(Optional.empty());
}
config.validate();
LOGGER.info("Initializing Quarkus Logging Cloudwatch Extension");
LOGGER.info("Logging to log-group: " + config.logGroup.get() + " and log-stream: " + config.logStreamName.get());
AWSLogsClientBuilder clientBuilder = AWSLogsClientBuilder.standard();
clientBuilder.setCredentials(new CloudWatchCredentialsProvider(config));
clientBuilder.setRegion(config.region.get());
AWSLogs awsLogs = clientBuilder.build();
String token = createLogStreamIfNeeded(awsLogs, config);
LoggingCloudWatchHandler handler = new LoggingCloudWatchHandler(awsLogs, config.logGroup.get(), config.logStreamName.get(), token);
handler.setLevel(config.level);
return new RuntimeValue<>(Optional.of(handler));
}
Aggregations