Search in sources :

Example 1 with AWSLogsClientBuilder

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));
}
Also used : CloudWatchCredentialsProvider(io.quarkiverse.logging.cloudwatch.auth.CloudWatchCredentialsProvider) AWSLogsClientBuilder(com.amazonaws.services.logs.AWSLogsClientBuilder) RuntimeValue(io.quarkus.runtime.RuntimeValue) AWSLogs(com.amazonaws.services.logs.AWSLogs)

Aggregations

AWSLogs (com.amazonaws.services.logs.AWSLogs)1 AWSLogsClientBuilder (com.amazonaws.services.logs.AWSLogsClientBuilder)1 CloudWatchCredentialsProvider (io.quarkiverse.logging.cloudwatch.auth.CloudWatchCredentialsProvider)1 RuntimeValue (io.quarkus.runtime.RuntimeValue)1