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

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

本文整理了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

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

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

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

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

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

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

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

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

  1. @Override
  2. protected void processLine(String line) {
  3. if (log.isDebugEnabled()) {
  4. log.verbose("%s", line);
  5. }
  6. if (line.startsWith(prefix)) {
  7. setEnvironmentVariable(line.substring(prefix.length()));
  8. }
  9. }

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

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

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

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

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

  1. public void wait(ImageConfiguration imageConfig, Properties projectProperties, String containerId) throws IOException {
  2. List<WaitChecker> checkers = prepareWaitCheckers(imageConfig, projectProperties, containerId);
  3. int timeout = getTimeOut(imageConfig);
  4. if (checkers.isEmpty()) {
  5. if (timeout > 0) {
  6. log.info("%s: Pausing for %d ms", imageConfig.getDescription(), timeout);
  7. WaitUtil.sleep(timeout);
  8. }
  9. return;
  10. }
  11. String logLine = extractCheckerLog(checkers);
  12. ContainerRunningPrecondition precondition = new ContainerRunningPrecondition(dockerAccess, containerId);
  13. try {
  14. long waited = WaitUtil.wait(precondition, timeout, checkers);
  15. log.info("%s: Waited %s %d ms", imageConfig.getDescription(), logLine, waited);
  16. } catch (WaitTimeoutException exp) {
  17. String desc = String.format("%s: Timeout after %d ms while waiting %s",
  18. imageConfig.getDescription(), exp.getWaited(),
  19. logLine);
  20. log.error(desc);
  21. throw new IOException(desc);
  22. } catch (PreconditionFailedException exp) {
  23. String desc = String.format("%s: Container stopped with exit code %d unexpectedly after %d ms while waiting %s",
  24. imageConfig.getDescription(), precondition.getExitCode(), exp.getWaited(),
  25. logLine);
  26. log.error(desc);
  27. throw new IOException(desc);
  28. }
  29. }

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

  1. @Override
  2. public boolean check() {
  3. try {
  4. final ContainerDetails container = docker.getContainer(containerId);
  5. if (container == null) {
  6. log.debug("HealthWaitChecker: Container %s not found");
  7. return false;
  8. }
  9. if (container.getHealthcheck() == null) {
  10. throw new IllegalArgumentException("Can not wait for healthstate of " + imageConfigDesc +". No HEALTHCHECK configured.");
  11. }
  12. if (first) {
  13. log.info("%s: Waiting to become healthy", imageConfigDesc);
  14. log.debug("HealthWaitChecker: Waiting for healthcheck: '%s'", container.getHealthcheck());
  15. first = false;
  16. } else if (log.isDebugEnabled()) {
  17. log.debug("HealthWaitChecker: Waiting on healthcheck '%s'", container.getHealthcheck());
  18. }
  19. return container.isHealthy();
  20. } catch(DockerAccessException e) {
  21. log.warn("Error while checking health: %s", e.getMessage());
  22. return false;
  23. }
  24. }

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

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

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

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

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

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

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

  1. @Override
  2. public void open() {
  3. logger.debug("Open LogWaitChecker callback");
  4. }
  5. }

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

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

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

  1. @Override
  2. public TarArchiver customize(TarArchiver archiver) throws IOException {
  3. log.warn("/--------------------- SECURITY WARNING ---------------------\\");
  4. log.warn("|You are building a Docker image with normalized permissions.|");
  5. log.warn("|All files and directories added to build context will have |");
  6. log.warn("|'-rwxr-xr-x' permissions. It is recommended to double check |");
  7. log.warn("|and reset permissions for sensitive files and directories. |");
  8. log.warn("\\------------------------------------------------------------/");
  9. log.debug("Changing permissions of '%s' from %o to %o.", name, mode, newMode);

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

  1. } catch (IOException | ExecException exp) {
  2. logException(exp);
  3. throw new MojoExecutionException(log.errorMessage(exp.getMessage()), exp);
  4. } catch (MojoExecutionException exp) {
  5. logException(exp);

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

  1. @Override
  2. public void run() {
  3. List<AssemblyFiles.Entry> entries = files.getUpdatedEntriesAndRefresh();
  4. if (entries != null && entries.size() > 0) {
  5. try {
  6. log.info("%s: Assembly changed. Copying changed files to container ...", imageConfig.getDescription());
  7. File changedFilesArchive = archiveService.createChangedFilesArchive(entries, files.getAssemblyDirectory(),
  8. imageConfig.getName(), mojoParameters);
  9. dockerAccess.copyArchive(watcher.getContainerId(), changedFilesArchive, containerBaseDir);
  10. callPostExec(watcher);
  11. } catch (MojoExecutionException | IOException | ExecException e) {
  12. log.error("%s: Error when copying files to container %s: %s",
  13. imageConfig.getDescription(), watcher.getContainerId(), e.getMessage());
  14. }
  15. }
  16. }
  17. };

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

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

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

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

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

  1. @Override
  2. public void process(JsonObject json) throws DockerAccessException {
  3. if (json.has("error")) {
  4. String msg = json.get("error").getAsString();
  5. String detailMsg = "";
  6. if (json.has("errorDetail")) {
  7. JsonObject details = json.getAsJsonObject("errorDetail");
  8. detailMsg = details.get("message").getAsString();
  9. }
  10. throw new DockerAccessException("%s %s", json.get("error"),
  11. (msg.equals(detailMsg) || "".equals(detailMsg) ? "" : "(" + detailMsg + ")"));
  12. } else if (json.has("stream")) {
  13. String message = json.get("stream").getAsString();
  14. log.verbose("%s", message.trim());
  15. } else if (json.has("status")) {
  16. String status = json.get("status").getAsString().trim();
  17. String id = json.has("id") ? json.get("id").getAsString() : null;
  18. if (status.matches("^.*(Download|Pulling).*")) {
  19. log.info(" %s%s",id != null ? id + " " : "",status);
  20. }
  21. }
  22. }

相关文章