Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excavator: Migrate to the logsafe SafeLogger API #712

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docker-compose-rule-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ dependencies {
testImplementation 'com.github.tomakehurst:wiremock'

integrationTestCompile project.sourceSets.test.output
implementation 'com.palantir.safe-logging:logger'
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import com.palantir.docker.compose.logging.LogDirectory;
import com.palantir.docker.compose.report.TestDescription;
import com.palantir.docker.compose.reporting.RunRecorder;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;
Expand All @@ -61,14 +63,12 @@
import org.immutables.value.Value;
import org.joda.time.Duration;
import org.joda.time.ReadableDuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Value.Immutable
@CustomImmutablesStyle
@SuppressWarnings("DesignForExtension")
public abstract class DockerComposeManager {
private static final Logger log = LoggerFactory.getLogger(DockerComposeManager.class);
private static final SafeLogger log = SafeLoggerFactory.get(DockerComposeManager.class);

public static final Duration DEFAULT_TIMEOUT = Duration.standardMinutes(2);
public static final int DEFAULT_RETRY_ATTEMPTS = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package com.palantir.docker.compose.connection.waiting;

import com.palantir.docker.compose.connection.Cluster;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.ThreadLocalRandom;
Expand All @@ -24,11 +26,9 @@
import org.awaitility.core.ConditionTimeoutException;
import org.joda.time.Duration;
import org.joda.time.ReadableDuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class ClusterWait {
private static final Logger log = LoggerFactory.getLogger(ClusterWait.class);
private static final SafeLogger log = SafeLoggerFactory.get(ClusterWait.class);
private final ClusterHealthCheck clusterHealthCheck;
private final Duration timeout;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
package com.palantir.docker.compose.execution;

import com.google.common.collect.ImmutableList;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import java.io.IOException;
import java.util.List;
import org.immutables.value.Value;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Value.Immutable
@SuppressWarnings("DesignForExtension")
public abstract class DockerExecutable implements Executable {
private static final Logger log = LoggerFactory.getLogger(DockerExecutable.class);
private static final SafeLogger log = SafeLoggerFactory.get(DockerExecutable.class);

private static final DockerCommandLocations DOCKER_LOCATIONS =
new DockerCommandLocations(System.getenv("DOCKER_LOCATION"), "/usr/local/bin/docker", "/usr/bin/docker");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
package com.palantir.docker.compose.execution;

import com.palantir.docker.compose.configuration.ShutdownStrategy;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Send SIGTERM to containers first, allowing them up to 10 seconds to
* terminate before killing and rm-ing them.
*/
public final class GracefulShutdownStrategy implements ShutdownStrategy {

private static final Logger log = LoggerFactory.getLogger(GracefulShutdownStrategy.class);
private static final SafeLogger log = SafeLoggerFactory.get(GracefulShutdownStrategy.class);

@Override
public void stop(DockerCompose dockerCompose) throws IOException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package com.palantir.docker.compose.execution;

import com.palantir.docker.compose.configuration.ShutdownStrategy;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Shuts down fast but cleanly by issuing a kill (fast shutdown) followed by a down (thorough cleanup)
Expand All @@ -30,7 +30,7 @@
*/
public final class KillDownShutdownStrategy implements ShutdownStrategy {

private static final Logger log = LoggerFactory.getLogger(KillDownShutdownStrategy.class);
private static final SafeLogger log = SafeLoggerFactory.get(KillDownShutdownStrategy.class);

@Override
public void stop(DockerCompose dockerCompose) throws IOException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package com.palantir.docker.compose.execution;

import com.palantir.docker.compose.configuration.ShutdownStrategy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;

public final class SkipShutdownStrategy implements ShutdownStrategy {

private static final Logger log = LoggerFactory.getLogger(SkipShutdownStrategy.class);
private static final SafeLogger log = SafeLoggerFactory.get(SkipShutdownStrategy.class);

@Override
public void shutdown(DockerCompose _dockerCompose, Docker _docker) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.palantir.docker.compose.reporting;

import com.google.common.io.CharStreams;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
Expand All @@ -25,11 +27,9 @@
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class HttpJsonPoster {
private static final Logger log = LoggerFactory.getLogger(HttpJsonPoster.class);
private static final SafeLogger log = SafeLoggerFactory.get(HttpJsonPoster.class);

private final ReportingConfig reportingConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.palantir.docker.compose.report.Versions;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.exceptions.SafeRuntimeException;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand All @@ -36,11 +38,9 @@
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import one.util.streamex.EntryStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

final class ReportCompiler implements Reporter {
private static final Logger log = LoggerFactory.getLogger(ReportCompiler.class);
private static final SafeLogger log = SafeLoggerFactory.get(ReportCompiler.class);

private static final String REPORT_API_VERSION = "2";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import com.palantir.docker.compose.configuration.DockerComposeRuleConfig;
import com.palantir.docker.compose.report.DockerComposeRun;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;

interface Reporter {
void addRun(DockerComposeRun dockerComposeRun);
Expand All @@ -29,7 +29,7 @@ interface Reporter {
void report();

final class NoOpReporter implements Reporter {
private static final Logger log = LoggerFactory.getLogger(NoOpReporter.class);
private static final SafeLogger log = SafeLoggerFactory.get(NoOpReporter.class);

public static final Reporter INSTANCE = new NoOpReporter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import com.palantir.docker.compose.events.EventConsumer;
import com.palantir.docker.compose.report.DockerComposeRun;
import com.palantir.docker.compose.report.TestDescription;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import java.time.Clock;
import java.time.ZoneOffset;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class RunRecorder implements EventConsumer {
private static final Logger log = LoggerFactory.getLogger(RunRecorder.class);
private static final SafeLogger log = SafeLoggerFactory.get(RunRecorder.class);

private final Clock clock;
private final Reporter reporter;
Expand Down