io.fabric8.maven.docker.util.Logger类的使用及代码示例

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

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

Logger介绍

[英]Simple log handler for printing used during the maven build
[中]maven构建期间使用的用于打印的简单日志处理程序

代码示例

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

@Override
public void matched() {
  latch.countDown();
  log.info("Pattern '%s' matched for container %s", logPattern, containerId);
}

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

private int adjustGracePeriod(int gracePeriod) {
  int killGracePeriodInSeconds = (gracePeriod + 500) / 1000;
  if (gracePeriod != 0 && killGracePeriodInSeconds == 0) {
    log.warn("A kill grace period of %d ms leads to no wait at all since its rounded to seconds. " +
         "Please use at least 500 as value for wait.kill", gracePeriod);
  }
  return killGracePeriodInSeconds;
}

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

@Override
public void error(String error) {
  logger.error("%s", error);
}

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

private void callBuildPlugin(File outputDir, String buildPluginClass) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
  Class buildPlugin = Class.forName(buildPluginClass);
  try {
    Method method = buildPlugin.getMethod("addExtraFiles", File.class);
    method.invoke(null, outputDir);
    log.info("Extra files from %s extracted", buildPluginClass);
  } catch (NoSuchMethodException exp) {
    log.verbose("Build plugin %s does not support 'addExtraFiles' method", buildPluginClass);
  }
}

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

@Override
protected void processLine(String line) {
  if (log.isDebugEnabled()) {
    log.verbose("%s", line);
  }
  if (line.startsWith(prefix)) {
    setEnvironmentVariable(line.substring(prefix.length()));
  }
}

代码示例来源: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

execInContainer(containerId, descriptor.getPreStop(), descriptor.getImageConfiguration());
  } catch (DockerAccessException e) {
    log.error("%s", e.getMessage());
  } catch (ExecException e) {
    if (descriptor.isBreakOnError()) {
      throw e;
    } else {
      log.warn("Cannot run preStop: %s", e.getMessage());
log.debug("shutdown will wait max of %d seconds before removing container", killGracePeriod);
log.info("%s: Stop%s container %s after %s ms",
    descriptor.getDescription(),
    (keepContainer ? "" : " and removed"),

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

public void wait(ImageConfiguration imageConfig, Properties projectProperties, String containerId) throws IOException {
  List<WaitChecker> checkers = prepareWaitCheckers(imageConfig, projectProperties, containerId);
  int timeout = getTimeOut(imageConfig);
  if (checkers.isEmpty()) {
    if (timeout > 0) {
      log.info("%s: Pausing for %d ms", imageConfig.getDescription(), timeout);
      WaitUtil.sleep(timeout);
    }
    return;
  }
  String logLine = extractCheckerLog(checkers);
  ContainerRunningPrecondition precondition = new ContainerRunningPrecondition(dockerAccess, containerId);
  try {
    long waited = WaitUtil.wait(precondition, timeout, checkers);
    log.info("%s: Waited %s %d ms", imageConfig.getDescription(), logLine, waited);
  } catch (WaitTimeoutException exp) {
    String desc = String.format("%s: Timeout after %d ms while waiting %s",
                  imageConfig.getDescription(), exp.getWaited(),
                  logLine);
    log.error(desc);
    throw new IOException(desc);
  } catch (PreconditionFailedException exp) {
    String desc = String.format("%s: Container stopped with exit code %d unexpectedly after %d ms while waiting %s",
                  imageConfig.getDescription(), precondition.getExitCode(), exp.getWaited(),
                  logLine);
    log.error(desc);
    throw new IOException(desc);
  }
}

代码示例来源: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

@Override
protected void processLine(String line) {
  log.verbose("Credentials helper reply for \"%s\" is %s",CredentialHelperClient.this.credentialHelperName,line);
  version = line;
}

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

log.info("Watching " + imageConfig.getName() + (watchMode != null ? " using " + watchMode.getDescription() : ""));
      log.info("%s: Watch for %s", imageConfig.getDescription(), StringUtils.join(tasks.toArray(), " and "));
  log.info("Waiting ...");
  if (!context.isKeepRunning()) {
    runService.addShutdownHookForStoppingContainers(context.isKeepContainer(), context.isRemoveVolumes(), context.isAutoCreateCustomNetworks());
  log.warn("Interrupted");
} finally {
  if (executor != null) {

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

log.warn("Interrupted");
Thread.currentThread().interrupt();
throw new MojoExecutionException("interrupted", e);
  log.error("Error occurred during container startup, shutting down...");
  runService.stopStartedContainers(keepContainer, removeVolumes, autoCreateCustomNetworks, getGavLabel());

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

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

代码示例来源: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 TarArchiver customize(TarArchiver archiver) throws IOException {
  log.warn("/--------------------- SECURITY WARNING ---------------------\\");
  log.warn("|You are building a Docker image with normalized permissions.|");
  log.warn("|All files and directories added to build context will have  |");
  log.warn("|'-rwxr-xr-x' permissions. It is recommended to double check |");
  log.warn("|and reset permissions for sensitive files and directories.  |");
  log.warn("\\------------------------------------------------------------/");
      log.debug("Changing permissions of '%s' from %o to %o.", name, mode, newMode);

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

} catch (IOException | ExecException exp) {
  logException(exp);
  throw new MojoExecutionException(log.errorMessage(exp.getMessage()), exp);
} catch (MojoExecutionException exp) {
  logException(exp);

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

@Override
  public void run() {
    List<AssemblyFiles.Entry> entries = files.getUpdatedEntriesAndRefresh();
    if (entries != null && entries.size() > 0) {
      try {
        log.info("%s: Assembly changed. Copying changed files to container ...", imageConfig.getDescription());
        File changedFilesArchive = archiveService.createChangedFilesArchive(entries, files.getAssemblyDirectory(),
            imageConfig.getName(), mojoParameters);
        dockerAccess.copyArchive(watcher.getContainerId(), changedFilesArchive, containerBaseDir);
        callPostExec(watcher);
      } catch (MojoExecutionException | IOException | ExecException e) {
        log.error("%s: Error when copying files to container %s: %s",
             imageConfig.getDescription(), watcher.getContainerId(), e.getMessage());
      }
    }
  }
};

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

protected void processLine(String line) {
  log.verbose(line);
}

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

log.info("%s: Loaded tarball in %s", buildConfig.getDockerArchive(), EnvUtil.formatDurationTill(time));
  return;
log.info("%s: Created %s in %s", imageConfig.getDescription(), dockerArchive.getName(), EnvUtil.formatDurationTill(time));
        .buildArgs(mergedBuildMap);
String newImageId = doBuildImage(imageName, dockerArchive, opts);
log.info("%s: Built image %s", imageConfig.getDescription(), newImageId);
    log.info("%s: Removed old image %s", imageConfig.getDescription(), oldImageId);
  } catch (DockerAccessException exp) {
    if (cleanupMode == CleanupMode.TRY_TO_REMOVE) {
      log.warn("%s: %s (old image)%s", imageConfig.getDescription(), exp.getMessage(),
          (exp.getCause() != null ? " [" + exp.getCause().getMessage() + "]" : ""));
    } else {

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

@Override
public void process(JsonObject json) throws DockerAccessException {
  if (json.has("error")) {
    String msg = json.get("error").getAsString();
    String detailMsg = "";
    if (json.has("errorDetail")) {
      JsonObject details = json.getAsJsonObject("errorDetail");
      detailMsg = details.get("message").getAsString();
    }
    throw new DockerAccessException("%s %s", json.get("error"),
        (msg.equals(detailMsg) || "".equals(detailMsg) ? "" : "(" + detailMsg + ")"));
  } else if (json.has("stream")) {
    String message = json.get("stream").getAsString();
    log.verbose("%s", message.trim());
  } else if (json.has("status")) {
    String status = json.get("status").getAsString().trim();
    String id = json.has("id") ? json.get("id").getAsString() : null;
    if (status.matches("^.*(Download|Pulling).*")) {
      log.info("  %s%s",id != null ? id + " " : "",status);
    }
  }
}

相关文章