org.apache.tools.ant.Project.log()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(108)

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

Project.log介绍

[英]Write a message to the log with the default log level of MSG_INFO .
[中]使用默认日志级别MSG_INFO将消息写入日志。

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * Logs a message through the project object if one has been provided.
 *
 * @param message The message to log.
 *                Should not be <code>null</code>.
 *
 * @param priority The logging priority of the message.
 */
protected void log(String message, int priority) {
  if (project != null) {
    project.log(message, priority);
  }
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Write a message to the log with the default log level
 * of MSG_INFO .
 * @param message The text to log. Should not be <code>null</code>.
 */
public void log(final String message) {
  log(message, MSG_INFO);
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Write a project level message to the log with the given log level.
 * @param message The text to log. Should not be <code>null</code>.
 * @param msgLevel The log priority level to use.
 */
public void log(final String message, final int msgLevel) {
  log(message, null, msgLevel);
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Write a target level message to the log with the given log level.
 * @param target The target to use in the log.
 *               Must not be <code>null</code>.
 * @param message The text to log. Should not be <code>null</code>.
 * @param msgLevel The log priority level to use.
 */
public void log(final Target target, final String message, final int msgLevel) {
  log(target, message, null, msgLevel);
}

代码示例来源:origin: org.apache.ant/ant

private static void log(final Project project, final String message, final int level) {
  if (project == null) {
    System.out.println(message);
  } else {
    project.log(message, level);
  }
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Add a reference to the project.
 *
 * @param referenceName The name of the reference. Must not be <code>null</code>.
 * @param value The value of the reference.
 */
public void addReference(final String referenceName, final Object value) {
  final Object old = ((AntRefTable) references).getReal(referenceName);
  if (old == value) {
    // no warning, this is not changing anything
    return;
  }
  if (old != null && !(old instanceof UnknownElement)) {
    log("Overriding previous definition of reference to " + referenceName,
      MSG_VERBOSE);
  }
  log("Adding reference: " + referenceName, MSG_DEBUG);
  references.put(referenceName, value);
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Logs a message through the project object if one has been provided.
 *
 * @param message The message to log.
 *                Should not be <code>null</code>.
 *
 * @param priority The logging priority of the message.
 */
protected void log(final String message, final int priority) {
  if (project != null) {
    project.log(message, priority);
  } else if (priority < Project.MSG_INFO) {
    System.err.println(message);
  }
}

代码示例来源:origin: pmd/pmd

@Override
public void startFileAnalysis(DataSource dataSource) {
  project.log("Processing file " + dataSource.getNiceFileName(false, inputPaths),
      Project.MSG_VERBOSE);
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Utility method that will throw a {@link BuildException}
 * if {@link #failOnError} is true else it just displays
 * a warning.
 */
private void missingExtension() {
  final String message = "Unable to resolve extension to a file";
  if (failOnError) {
    throw new BuildException(message);
  }
  getProject().log(message, Project.MSG_ERR);
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Add a target to the project, or replaces one with the same
 * name.
 *
 * @param targetName The name to use for the target.
 *                   Must not be <code>null</code>.
 * @param target The target to be added or replaced in the project.
 *               Must not be <code>null</code>.
 */
public void addOrReplaceTarget(final String targetName, final Target target) {
  final String msg = " +Target: " + targetName;
  log(msg, MSG_DEBUG);
  target.setProject(this);
  targets.put(targetName, target);
}

代码示例来源:origin: org.apache.ant/ant

private void applyReflectionHackForExtensionMethods() {
  // Jigsaw doesn't allow reflection to work, so we can stop trying
  if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
    try { // #51668, #52382
      final Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing");
      _isNotSecureProcessing.setAccessible(true);
      _isNotSecureProcessing.set(tfactory, Boolean.TRUE);
    } catch (final Exception x) {
      if (project != null) {
        project.log(x.toString(), Project.MSG_DEBUG);
      }
    }
  }
}

代码示例来源:origin: pmd/pmd

private void setupClassLoader() {
  try {
    if (auxClasspath != null) {
      project.log("Using auxclasspath: " + auxClasspath, Project.MSG_VERBOSE);
      configuration.prependClasspath(auxClasspath.toString());
    }
  } catch (IOException ioe) {
    throw new BuildException(ioe.getMessage(), ioe);
  }
}

代码示例来源:origin: pmd/pmd

private void logRulesUsed(RuleSets rules) {
    project.log("Using these rulesets: " + configuration.getRuleSets(), Project.MSG_VERBOSE);

    RuleSet[] ruleSets = rules.getAllRuleSets();
    for (RuleSet ruleSet : ruleSets) {
      for (Rule rule : ruleSet.getRules()) {
        project.log("Using rule " + rule.getName(), Project.MSG_VERBOSE);
      }
    }
  }
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Prints the description of a project (if there is one) to
 * <code>System.out</code>.
 *
 * @param project The project to display a description of.
 *                Must not be <code>null</code>.
 */
private static void printDescription(final Project project) {
  if (project.getDescription() != null) {
   project.log(project.getDescription());
  }
}

代码示例来源:origin: org.apache.ant/ant

private static OutputStream getOutputStream(final Resource resource, final boolean append, final Project project)
    throws IOException {
  if (append) {
    final Appendable a = resource.as(Appendable.class);
    if (a != null) {
      return a.getAppendOutputStream();
    }
    String msg = "Appendable OutputStream not available for non-appendable resource "
      + resource + "; using plain OutputStream";
    if (project != null) {
      project.log(msg, Project.MSG_VERBOSE);
    } else {
      System.out.println(msg);
    }
  }
  return resource.getOutputStream();
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Demultiplex output so that each task receives the appropriate
 * messages. If the current thread is not currently executing a task,
 * the message is logged directly.
 *
 * @param output Message to handle. Should not be <code>null</code>.
 * @param isWarning Whether the text represents an warning (<code>true</code>)
 *        or information (<code>false</code>).
 */
public void demuxOutput(final String output, final boolean isWarning) {
  final Task task = getThreadTask(Thread.currentThread());
  if (task == null) {
    log(output, isWarning ? MSG_WARN : MSG_INFO);
  } else if (isWarning) {
    task.handleErrorOutput(output);
  } else {
    task.handleOutput(output);
  }
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Logs a message with the given priority. This delegates
 * the actual logging to the project.
 *
 * @param msg The message to be logged. Should not be <code>null</code>.
 * @param msgLevel The message priority at which this message is to
 *                 be logged.
 */
public void log(String msg, int msgLevel) {
  if (getProject() == null) {
    super.log(msg, msgLevel);
  } else {
    getProject().log(this, msg, msgLevel);
  }
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Logs a message with the given priority. This delegates
 * the actual logging to the project.
 *
 * @param msg The message to be logged. Should not be <code>null</code>.
 * @param t The exception to be logged. May be <code>null</code>.
 * @param msgLevel The message priority at which this message is to
 *                 be logged.
 * @since 1.7
 */
public void log(String msg, Throwable t, int msgLevel) {
  if (getProject() == null) {
    super.log(msg, msgLevel);
  } else {
    getProject().log(this, msg, t, msgLevel);
  }
}

代码示例来源:origin: pmd/pmd

private ResourceLoader setupResourceLoader() {
  if (classpath == null) {
    classpath = new Path(project);
  }
  /*
   * 'basedir' is added to the path to make sure that relative paths such
   * as "<ruleset>resources/custom_ruleset.xml</ruleset>" still work when
   * ant is invoked from a different directory using "-f"
   */
  classpath.add(new Path(null, project.getBaseDir().toString()));
  project.log("Using the AntClassLoader: " + classpath, Project.MSG_VERBOSE);
  // must be true, otherwise you'll get ClassCastExceptions as classes
  // are loaded twice
  // and exist in multiple class loaders
  final boolean parentFirst = true;
  return new ResourceLoader(new AntClassLoader(Thread.currentThread().getContextClassLoader(),
      project, classpath, parentFirst));
}

代码示例来源:origin: org.apache.ant/ant

/**
 * @since Ant 1.10.3
 */
@Override
protected boolean areIiopAndIdlSupported() {
  boolean supported = !JavaEnvUtils.isAtLeastJavaVersion("11");
  if (!supported && getRmic().getExecutable() != null) {
    getRmic().getProject()
      .log("Allowing -iiop and -idl for forked rmic even though this version of Java doesn't support it.",
         Project.MSG_INFO);
    return true;
  }
  return supported;
}

相关文章