Codota Logo
StreamTaskListener.getLogger
Code IndexAdd Codota to your IDE (free)

How to use
getLogger
method
in
hudson.util.StreamTaskListener

Best Java code snippets using hudson.util.StreamTaskListener.getLogger (Showing top 20 results out of 315)

  • Common ways to obtain StreamTaskListener
private void myMethod () {
StreamTaskListener s =
  • Codota IconStreamTaskListener.fromStdout()
  • Codota IconOutputStream out;new StreamTaskListener(out)
  • Codota IconOutputStream out;new StreamTaskListener(out, Charset.defaultCharset())
  • Smart code suggestions by Codota
}
origin: jenkinsci/jenkins

  public void run() {
    logger.log(getNormalLoggingLevel(), "Started {0}", name);
    long startTime = System.currentTimeMillis();
    long stopTime;
    StreamTaskListener l = createListener();
    try {
      l.getLogger().printf("Started at %tc%n", new Date(startTime));
      ACL.impersonate(ACL.SYSTEM);
      execute(l);
    } catch (IOException e) {
      Functions.printStackTrace(e, l.fatalError(e.getMessage()));
    } catch (InterruptedException e) {
      Functions.printStackTrace(e, l.fatalError("aborted"));
    } finally {
      stopTime = System.currentTimeMillis();
      try {
        l.getLogger().printf("Finished at %tc. %dms%n", new Date(stopTime), stopTime - startTime);
      } finally {
        l.closeQuietly();
      }
    }
    logger.log(getNormalLoggingLevel(), "Finished {0}. {1,number} ms",
        new Object[]{name, stopTime - startTime});
  }
},name+" thread");
origin: jenkinsci/jenkins

private boolean runPolling() {
  try {
    // to make sure that the log file contains up-to-date text,
    // don't do buffering.
    StreamTaskListener listener = new StreamTaskListener(getLogFile());
    try {
      PrintStream logger = listener.getLogger();
      long start = System.currentTimeMillis();
      logger.println("Started on "+ DateFormat.getDateTimeInstance().format(new Date()));
      boolean result = job().poll(listener).hasChanges();
      logger.println("Done. Took "+ Util.getTimeSpanString(System.currentTimeMillis()-start));
      if(result)
        logger.println("Changes found");
      else
        logger.println("No changes");
      return result;
    } catch (Error | RuntimeException e) {
      Functions.printStackTrace(e, listener.error("Failed to record SCM polling for " + job));
      LOGGER.log(Level.SEVERE,"Failed to record SCM polling for "+job,e);
      throw e;
    } finally {
      listener.close();
    }
  } catch (IOException e) {
    LOGGER.log(Level.SEVERE,"Failed to record SCM polling for "+job,e);
    return false;
  }
}
origin: jenkinsci/jenkins

  public void run() {
    logger.log(getNormalLoggingLevel(), "Started {0}", name);
    long startTime = System.currentTimeMillis();
    long stopTime;
    StreamTaskListener l = createListener();
    try {
      l.getLogger().printf("Started at %tc%n", new Date(startTime));
      ACL.impersonate(ACL.SYSTEM);
      execute(l);
    } catch (IOException e) {
      Functions.printStackTrace(e, l.fatalError(e.getMessage()));
    } catch (InterruptedException e) {
      Functions.printStackTrace(e, l.fatalError("aborted"));
    } finally {
      stopTime = System.currentTimeMillis();
      try {
        l.getLogger().printf("Finished at %tc. %dms%n", new Date(stopTime), stopTime - startTime);
      } finally {
        l.closeQuietly();
      }
    }
    logger.log(getNormalLoggingLevel(), "Finished {0}. {1,number} ms",
        new Object[]{name, stopTime - startTime});
  }
},name+" thread");
origin: jenkinsci/jenkins

@Override
public void restart() throws IOException, InterruptedException {
  Jenkins jenkins = Jenkins.getInstanceOrNull();
  try {
    if (jenkins != null) {
      jenkins.cleanUp();
    }
  } catch (Exception e) {
    LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
  }
  File me = getHudsonWar();
  File home = me.getParentFile();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  StreamTaskListener task = new StreamTaskListener(baos);
  task.getLogger().println("Restarting a service");
  String exe = System.getenv("WINSW_EXECUTABLE");
  File executable;
  if (exe!=null)   executable = new File(exe);
  else            executable = new File(home, "hudson.exe");
  if (!executable.exists())   executable = new File(home, "jenkins.exe");
  // use restart! to run hudson/jenkins.exe restart in a separate process, so it doesn't kill itself
  int r = new LocalLauncher(task).launch().cmds(executable, "restart!")
      .stdout(task).pwd(home).join();
  if(r!=0)
    throw new IOException(baos.toString());
}

origin: jenkinsci/jenkins

task.getLogger().println("Installing a service");
int r = runElevated(new File(dir, "jenkins.exe"), "install", task, dir);
if(r!=0) {
origin: jenkinsci/jenkins

if (veto != null) {
  try (StreamTaskListener listener = new StreamTaskListener(getLogFile())) {
    listener.getLogger().println(
        "Skipping polling on " + DateFormat.getDateTimeInstance().format(new Date())
            + " due to veto from " + veto);
origin: org.jenkins-ci.lib/xtrigger-lib

public void info(String message) {
  if (listener != null) {
    listener.getLogger().println(message);
  }
}
origin: org.jenkins-ci.lib/xtrigger-lib

public void error(String message) {
  if (listener != null) {
    listener.getLogger().println("[ERROR] - " + message);
  }
}
origin: org.eclipse.hudson/hudson-core

  public void run() {
    try {
      StreamTaskListener task = StreamTaskListener.fromStdout();
      int r = runElevated(slaveExe, "start", task, dir, nativeUtils);
      task.getLogger().println(r == 0 ? "Successfully started" : "start service failed. Exit code=" + r);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
});
origin: org.eclipse.hudson.main/hudson-core

  public void run() {
    try {
      StreamTaskListener task = StreamTaskListener.fromStdout();
      int r = runElevated(slaveExe,"start",task,dir);
      task.getLogger().println(r==0?"Successfully started":"start service failed. Exit code="+r);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
});
origin: org.jvnet.hudson.main/hudson-core

  public void run() {
    try {
      StreamTaskListener task = StreamTaskListener.fromStdout();
      int r = runElevated(slaveExe,"start",task,dir);
      task.getLogger().println(r==0?"Successfully started":"start service failed. Exit code="+r);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
});
origin: hudson/hudson-2.x

  public void run() {
    try {
      StreamTaskListener task = StreamTaskListener.fromStdout();
      int r = runElevated(slaveExe,"start",task,dir);
      task.getLogger().println(r==0?"Successfully started":"start service failed. Exit code="+r);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
});
origin: org.jenkins-ci.modules/windows-slave-installer

  @Override
  public void run() {
    try {
      StreamTaskListener task = StreamTaskListener.fromStdout();
      int r = runElevated(agentExe, "start", task, rootDir);
      task.getLogger().println(r == 0 ? "Successfully started" : "Start service failed. Exit code=" + r);
    } catch (IOException | InterruptedException ex) {
      // Level is severe, because the process won't be recovered in the service mode
      LOGGER.log(Level.SEVERE, "Failed to start the service with id=" + serviceId, ex);
    }
  }
}
origin: org.jenkins-ci.plugins.workflow/workflow-cps-global-lib

@Override public FormValidation validateVersion(String name, String version) {
  StringWriter w = new StringWriter();
  try {
    StreamTaskListener listener = new StreamTaskListener(w);
    SCMRevision revision = scm.fetch(version, listener);
    if (revision != null) {
      // TODO validate repository structure using SCMFileSystem when implemented (JENKINS-33273)
      return FormValidation.ok("Currently maps to revision: " + revision);
    } else {
      listener.getLogger().flush();
      return FormValidation.warning("Revision seems invalid:\n" + w);
    }
  } catch (Exception x) {
    return FormValidation.warning(x, "Cannot validate default version.");
  }
}
origin: org.jvnet.hudson.main/hudson-core

@Override
public void restart() throws IOException, InterruptedException {
  File me = getHudsonWar();
  File home = me.getParentFile();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  StreamTaskListener task = new StreamTaskListener(baos);
  task.getLogger().println("Restarting a service");
  int r = new LocalLauncher(task).launch().cmds(new File(home, "hudson.exe"), "restart")
      .stdout(task).pwd(home).join();
  if(r!=0)
    throw new IOException(baos.toString());
}
origin: org.eclipse.hudson.main/hudson-core

@Override
public void restart() throws IOException, InterruptedException {
  File me = getHudsonWar();
  File home = me.getParentFile();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  StreamTaskListener task = new StreamTaskListener(baos);
  task.getLogger().println("Restarting a service");
  int r = new LocalLauncher(task).launch().cmds(new File(home, "hudson.exe"), "restart")
      .stdout(task).pwd(home).join();
  if(r!=0)
    throw new IOException(baos.toString());
}
origin: hudson/hudson-2.x

@Override
public void restart() throws IOException, InterruptedException {
  File me = getHudsonWar();
  File home = me.getParentFile();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  StreamTaskListener task = new StreamTaskListener(baos);
  task.getLogger().println("Restarting a service");
  int r = new LocalLauncher(task).launch().cmds(new File(home, "hudson.exe"), "restart")
      .stdout(task).pwd(home).join();
  if(r!=0)
    throw new IOException(baos.toString());
}
origin: org.eclipse.hudson/hudson-core

@Override
public void restart() throws IOException, InterruptedException {
  File me = getHudsonWar();
  File home = me.getParentFile();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  StreamTaskListener task = new StreamTaskListener(baos);
  task.getLogger().println("Restarting a service");
  int r = new LocalLauncher(task).launch().cmds(new File(home, "hudson.exe"), "restart")
      .stdout(task).pwd(home).join();
  if (r != 0) {
    throw new IOException(baos.toString());
  }
}
private static final Logger LOGGER = Logger.getLogger(WindowsServiceLifecycle.class.getName());
origin: org.jvnet.hudson.plugins/perforce

private String getEffectiveClientName(AbstractBuild build) {
  Node buildNode = build.getBuiltOn();
  FilePath workspace = build.getWorkspace();
  String p4Client = this.p4Client;
  try {
    p4Client = getEffectiveClientName(build.getProject(), buildNode, workspace);
  } catch (Exception e){
    new StreamTaskListener(System.out).getLogger().println(
        "Could not get effective client name: " + e.getMessage());
  } finally {
    p4Client = substituteParameters(p4Client, build);
    return p4Client;
  }
}
origin: jenkinsci/cloudbees-folder-plugin

public void add(String kid) throws IOException, InterruptedException {
  try (StreamTaskListener listener = getComputation().createEventsListener();
      ChildObserver<FreeStyleProject> observer = openEventsChildObserver()) {
    FreeStyleProject p = observer.shouldUpdate(kid);
    try {
      if (p == null) {
        if (observer.mayCreate(kid)) {
          listener.getLogger().println("adding " + kid);
          kids.add(kid);
          p = new FreeStyleProject(this, kid);
          observer.created(p);
        }
      }
    } finally {
      observer.completed(kid);
    }
  }
}
hudson.utilStreamTaskListenergetLogger

Popular methods of StreamTaskListener

  • <init>
  • fromStdout
  • closeQuietly
    Closes this listener and swallows any exceptions, if raised.
  • error
  • close
  • fatalError
  • _error
  • annotate
  • fromStderr
  • asPath

Popular in Java

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (Timer)
  • putExtra (Intent)
  • notifyDataSetChanged (ArrayAdapter)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • PriorityQueue (java.util)
    An unbounded priority Queue based on a priority heap. The elements of the priority queue are ordered
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now