io.fabric8.maven.docker.util.Logger.debug()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中io.fabric8.maven.docker.util.Logger.debug()方法的一些代码示例,展示了Logger.debug()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.debug()方法的具体详情如下:
包路径:io.fabric8.maven.docker.util.Logger
类名称:Logger
方法名:debug

Logger.debug介绍

[英]Debug message if debugging is enabled.
[中]调试消息(如果已启用调试)。

代码示例

代码示例来源:origin: fabric8io/docker-maven-plugin

@Override
  public void open() {
    logger.debug("Open LogWaitChecker callback");
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

@Override
public void close() {
  logger.debug("Closing LogWaitChecker callback");
}

代码示例来源:origin: fabric8io/docker-maven-plugin

@Override
public int read(byte[] b, int off, int len) throws IOException {
  int readed = super.read(b, off, len);
  log.debug("RESPONSE %s", new String(b, off, len, Charset.forName("UTF-8")));
  return readed;
}

代码示例来源:origin: fabric8io/docker-maven-plugin

private void setEnvironmentVariable(String line) {
  Matcher matcher = ENV_VAR_PATTERN.matcher(line);
  if (matcher.matches()) {
    String key = matcher.group("key");
    String value = matcher.group("value");
    log.debug("Env: %s=%s",key,value);
    env.put(key, value);
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

/**
 * Initialize an extended authentication for ecr registry.
 *
 * @param registry The registry, we may or may not be an ecr registry.
 */
public EcrExtendedAuth(Logger logger, String registry) {
  this.logger = logger;
  Matcher matcher = AWS_REGISTRY.matcher(registry);
  isAwsRegistry = matcher.matches();
  if (isAwsRegistry) {
    accountId = matcher.group(1);
    region = matcher.group(2);
  } else {
    accountId = null;
    region = null;
  }
  logger.debug("registry = %s, isValid= %b", registry, isAwsRegistry);
}

代码示例来源:origin: fabric8io/docker-maven-plugin

private void logRemoveResponse(JsonArray logElements) {
  for (int i = 0; i < logElements.size(); i++) {
    JsonObject entry = logElements.get(i).getAsJsonObject();
    for (Object key : entry.keySet()) {
      log.debug("%s: %s", key, entry.get(key.toString()));
    }
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

private JsonObject executeRequest(CloseableHttpClient client, HttpPost request) throws IOException, MojoExecutionException {
  try {
    CloseableHttpResponse response = client.execute(request);
    int statusCode = response.getStatusLine().getStatusCode();
    logger.debug("Response status %d", statusCode);
    if (statusCode != HttpStatus.SC_OK) {
      throw new MojoExecutionException("AWS authentication failure");
    }
    HttpEntity entity = response.getEntity();
    Reader jr = new InputStreamReader(entity.getContent(), StandardCharsets.UTF_8);
    return new Gson().fromJson(jr, JsonObject.class);
  }
  finally {
    client.close();
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

private Map<String, String> addBuildArgsFromProperties(Properties properties) {
  String argPrefix = "docker.buildArg.";
  Map<String, String> buildArgs = new HashMap<>();
  for (Object keyObj : properties.keySet()) {
    String key = (String) keyObj;
    if (key.startsWith(argPrefix)) {
      String argKey = key.replaceFirst(argPrefix, "");
      String value = properties.getProperty(key);
      if (!isEmpty(value)) {
        buildArgs.put(argKey, value);
      }
    }
  }
  log.debug("Build args set %s", buildArgs);
  return buildArgs;
}

代码示例来源:origin: fabric8io/docker-maven-plugin

HttpPost createSignedRequest(AuthConfig localCredentials, Date time) {
    String host = "ecr." + region + ".amazonaws.com";

    logger.debug("Get ECR AuthorizationToken from %s", host);

    HttpPost request = new HttpPost("https://" + host + '/');
    request.setHeader("host", host);
    request.setHeader("Content-Type", "application/x-amz-json-1.1");
    request.setHeader("X-Amz-Target", "AmazonEC2ContainerRegistry_V20150921.GetAuthorizationToken");
    request.setEntity(new StringEntity("{\"registryIds\":[\""+ accountId + "\"]}", StandardCharsets.UTF_8));

    AwsSigner4 signer = new AwsSigner4(region, "ecr");
    signer.sign(request, localCredentials, time);
    return request;
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

@Override
public void log(int type, Timestamp timestamp, String txt) throws DoneException {
  logger.debug("LogWaitChecker: Trying to match '%s' [Pattern: %s] [thread: %d]",
       txt, pattern.pattern(), Thread.currentThread().getId());
  final String toMatch;
  if (logBuffer != null) {
    logBuffer.append(txt).append("\n");
    toMatch = logBuffer.toString();
  } else {
    toMatch = txt;
  }
  if (pattern.matcher(toMatch).find()) {
    logger.debug("Found log-wait pattern in log output");
    callback.matched();
    throw new DoneException();
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

@Override
public void write(byte[] b, int off, int len) throws IOException {
  if(log.isDebugEnabled()){
    String request = new String(b, off, len, Charset.forName("UTF-8"));
    String logValue = ascii().matchesAllOf(request) ? request : "not logged due to non-ASCII characters. ";
    log.debug("REQUEST %s", logValue);
  }
  out.write(b, off, len);
}

代码示例来源:origin: fabric8io/docker-maven-plugin

private void removeContainer(ContainerTracker.ContainerShutdownDescriptor descriptor, boolean removeVolumes, String containerId)
  throws DockerAccessException {
  int shutdownGracePeriod = descriptor.getShutdownGracePeriod();
  if (shutdownGracePeriod != 0) {
    log.debug("Shutdown: Wait %d ms before removing container", shutdownGracePeriod);
    WaitUtil.sleep(shutdownGracePeriod);
  }
  // Remove the container
  docker.removeContainer(containerId, removeVolumes);
}

代码示例来源:origin: fabric8io/docker-maven-plugin

public void createCustomNetworkIfNotExistant(String customNetwork) throws DockerAccessException {
  if (!queryService.hasNetwork(customNetwork)) {
    docker.createNetwork(new NetworkCreateConfig(customNetwork));
  } else {
    log.debug("Custom Network " + customNetwork + " found");
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

@Override
public String createNetwork(NetworkCreateConfig networkConfig)
    throws DockerAccessException {
  String createJson = networkConfig.toJson();
  log.debug("Network create config: " + createJson);
  try {
    String url = urlBuilder.createNetwork();
    String response =
        delegate.post(url, createJson, new ApacheHttpClientDelegate.BodyResponseHandler(), HTTP_CREATED);
    log.debug(response);
    JsonObject json = JsonFactory.newJsonObject(response);
    if (json.has("Warnings")) {
      logWarnings(json);
    }
    // only need first 12 to id a container
    return json.get("Id").getAsString().substring(0, 12);
  } catch (IOException e) {
    throw new DockerAccessException(e, "Unable to create network for [%s]",
        networkConfig.getName());
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

@Override
public boolean check() {
  try {
    final ContainerDetails container = docker.getContainer(containerId);
    if (container == null) {
      log.debug("HealthWaitChecker: Container %s not found");
      return false;
    }
    if (container.getHealthcheck() == null) {
      throw new IllegalArgumentException("Can not wait for healthstate of " + imageConfigDesc +". No HEALTHCHECK configured.");
    }
    if (first) {
      log.info("%s: Waiting to become healthy", imageConfigDesc);
      log.debug("HealthWaitChecker: Waiting for healthcheck: '%s'", container.getHealthcheck());
      first = false;
    } else if (log.isDebugEnabled()) {
      log.debug("HealthWaitChecker: Waiting on healthcheck '%s'", container.getHealthcheck());
    }
    return container.isHealthy();
  } catch(DockerAccessException e) {
    log.warn("Error while checking health: %s", e.getMessage());
    return false;
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

private AuthConfig extractAuthConfigFromCredentialsHelper(String registryToLookup, String credConfig) throws MojoExecutionException {
  CredentialHelperClient credentialHelper = new CredentialHelperClient(log, credConfig);
  log.debug("AuthConfig: credentials from credential helper/store %s version %s",
       credentialHelper.getName(),
       credentialHelper.getVersion());
  return credentialHelper.getAuthConfig(registryToLookup);
}

代码示例来源:origin: fabric8io/docker-maven-plugin

@Override
public String createContainer(ContainerCreateConfig containerConfig, String containerName)
    throws DockerAccessException {
  String createJson = containerConfig.toJson();
  log.debug("Container create config: %s", createJson);
  try {
    String url = urlBuilder.createContainer(containerName);
    String response =
        delegate.post(url, createJson, new ApacheHttpClientDelegate.BodyResponseHandler(), HTTP_CREATED);
    JsonObject json = JsonFactory.newJsonObject(response);
    logWarnings(json);
    // only need first 12 to id a container
    return json.get("Id").getAsString().substring(0, 12);
  } catch (IOException e) {
    throw new DockerAccessException(e, "Unable to create container for [%s]",
                    containerConfig.getImageName());
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

public void tagImage(String imageName, ImageConfiguration imageConfig) throws DockerAccessException {
  List<String> tags = imageConfig.getBuildConfiguration().getTags();
  if (tags.size() > 0) {
    log.info("%s: Tag with %s", imageConfig.getDescription(), EnvUtil.stringJoin(tags, ","));
    for (String tag : tags) {
      if (tag != null) {
        docker.tag(imageName, new ImageName(imageName, tag).getFullName(), true);
      }
    }
    log.debug("Tagging image successful!");
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

@Override
public String createVolume(VolumeCreateConfig containerConfig)
    throws DockerAccessException
{
  String createJson = containerConfig.toJson();
  log.debug("Volume create config: %s", createJson);
  try
  {
    String url = urlBuilder.createVolume();
    String response =
        delegate.post(url,
               createJson,
               new ApacheHttpClientDelegate.BodyResponseHandler(),
               HTTP_CREATED);
    JsonObject json = JsonFactory.newJsonObject(response);
    logWarnings(json);
    return json.get("Name").getAsString();
  }
  catch (IOException e)
  {
    throw new DockerAccessException(e, "Unable to create volume for [%s]",
                    containerConfig.getName());
  }
}

代码示例来源:origin: fabric8io/docker-maven-plugin

private List<WaitChecker> prepareWaitCheckers(ImageConfiguration imageConfig, Properties projectProperties, String containerId) throws IOException {
  WaitConfiguration wait = getWaitConfiguration(imageConfig);
  if (wait == null) {
    return Collections.emptyList();
  }
  List<WaitChecker> checkers = new ArrayList<>();
  if (wait.getUrl() != null) {
    checkers.add(getUrlWaitChecker(imageConfig.getDescription(), projectProperties, wait));
  }
  if (wait.getLog() != null) {
    log.debug("LogWaitChecker: Waiting on %s", wait.getLog());
    checkers.add(new LogWaitChecker(wait.getLog(), dockerAccess, containerId, log));
  }
  if (wait.getTcp() != null) {
    try {
      Container container = queryService.getMandatoryContainer(containerId);
      checkers.add(getTcpWaitChecker(container, imageConfig.getDescription(), projectProperties, wait.getTcp()));
    } catch (DockerAccessException e) {
      throw new IOException("Unable to access container " + containerId, e);
    }
  }
  if (wait.getHealthy() == Boolean.TRUE) {
    checkers.add(new HealthCheckChecker(dockerAccess, containerId, imageConfig.getDescription(), log));
  }
  if (wait.getExit() != null) {
    checkers.add(new ExitCodeChecker(wait.getExit(), queryService, containerId));
  }
  return checkers;
}

相关文章