Codota Logo
Profiler.logTimeLast
Code IndexAdd Codota to your IDE (free)

How to use
logTimeLast
method
in
org.sonar.core.util.logs.Profiler

Best Java code snippets using org.sonar.core.util.logs.Profiler.logTimeLast (Showing top 12 results out of 315)

  • Common ways to obtain Profiler
private void myMethod () {
Profiler p =
  • Codota IconLogger logger;Profiler.create(logger)
  • Codota IconLogger logger;Profiler.createIfTrace(logger)
  • Smart code suggestions by Codota
}
origin: SonarSource/sonarqube

public void execute() {
 Profiler stepProfiler = Profiler.create(LOGGER).logTimeLast(true);
 boolean allStepsExecuted = false;
 try {
  executeSteps(stepProfiler);
  allStepsExecuted = true;
 } finally {
  if (listener != null) {
   executeListener(allStepsExecuted);
  }
 }
}
origin: SonarSource/sonarqube

private static Profiler startLogProfiler(CeTask task) {
 Profiler profiler = Profiler.create(LOG)
  .logTimeLast(true)
  .addContext("project", task.getMainComponent().flatMap(CeTask.Component::getKey).orElse(null))
  .addContext("type", task.getType());
 for (Map.Entry<String, String> characteristic : task.getCharacteristics().entrySet()) {
  profiler.addContext(characteristic.getKey(), characteristic.getValue());
 }
 return profiler
  .addContext("id", task.getUuid())
  .addContext("submitter", submitterOf(task))
  .startInfo("Execute task");
}
origin: SonarSource/sonarqube

@Test
public void stopInfo_adds_context_before_time_if_logTimeLast_is_true() {
 addSomeContext(underTest);
 underTest.logTimeLast(true);
 underTest.start().stopInfo("Rules registered");
 assertThat(tester.logs()).hasSize(1);
 assertThat(tester.logs(LoggerLevel.INFO).get(0))
  .startsWith("Rules registered | a_string=bar | an_int=42 | after_start=true | time=")
  .endsWith("ms");
}
origin: SonarSource/sonarqube

@Test
public void stopTrace_adds_context_before_time_if_logTimeLast_is_true() {
 tester.setLevel(LoggerLevel.TRACE);
 addSomeContext(underTest);
 underTest.logTimeLast(true);
 underTest.start().stopTrace("Rules registered");
 assertThat(tester.logs()).hasSize(1);
 assertThat(tester.logs(LoggerLevel.TRACE).get(0))
  .startsWith("Rules registered | a_string=bar | an_int=42 | after_start=true | time=")
  .endsWith("ms");
}
origin: SonarSource/sonarqube

@Test
public void stopError_adds_context_before_time_if_logTimeLast_is_true() {
 addSomeContext(underTest);
 underTest.logTimeLast(true);
 underTest.start().stopError("Rules registered");
 assertThat(tester.logs()).hasSize(1);
 assertThat(tester.logs(LoggerLevel.ERROR).get(0))
  .startsWith("Rules registered | a_string=bar | an_int=42 | after_start=true | time=")
  .endsWith("ms");
}
origin: SonarSource/sonarqube

@Test
public void stopInfo_clears_context() {
 addSomeContext(underTest);
 underTest.logTimeLast(true);
 underTest.start().stopInfo("Foo");
 underTest.start().stopInfo("Bar");
 assertThat(tester.logs()).hasSize(2);
 List<String> logs = tester.logs(LoggerLevel.INFO);
 assertThat(logs.get(0))
   .startsWith("Foo | a_string=bar | an_int=42 | after_start=true | time=")
   .endsWith("ms");
 assertThat(logs.get(1))
   .startsWith("Bar | time=")
   .endsWith("ms");
}
origin: SonarSource/sonarqube

@Test
@UseDataProvider("logTimeLastValues")
public void different_start_and_stop_messages(boolean logTimeLast) {
 underTest.logTimeLast(logTimeLast);
 tester.setLevel(LoggerLevel.TRACE);
 // start TRACE and stop DEBUG
 underTest.startTrace("Register rules");
 underTest.stopDebug("Rules registered");
 assertThat(tester.logs()).hasSize(2);
 assertThat(tester.logs().get(0)).contains("Register rules");
 assertThat(tester.logs().get(1)).startsWith("Rules registered | time=");
 tester.clear();
 // start DEBUG and stop INFO
 underTest.startDebug("Register rules {}", 10);
 underTest.stopInfo("Rules registered");
 assertThat(tester.logs()).hasSize(2);
 assertThat(tester.logs().get(0)).contains("Register rules 10");
 assertThat(tester.logs().get(1)).startsWith("Rules registered | time=");
 tester.clear();
 // start INFO and stop TRACE
 underTest.startInfo("Register rules");
 underTest.stopTrace("Rules registered");
 assertThat(tester.logs()).hasSize(2);
 assertThat(tester.logs().get(0)).contains("Register rules");
 assertThat(tester.logs().get(1)).startsWith("Rules registered | time=");
}
origin: SonarSource/sonarqube

@Test
public void stopDebug_clears_context() {
 tester.setLevel(LoggerLevel.DEBUG);
 addSomeContext(underTest);
 underTest.logTimeLast(true);
 underTest.start().stopDebug("Foo");
 underTest.start().stopDebug("Bar");
 assertThat(tester.logs()).hasSize(2);
 List<String> logs = tester.logs(LoggerLevel.DEBUG);
 assertThat(logs.get(0))
   .startsWith("Foo | a_string=bar | an_int=42 | after_start=true | time=")
   .endsWith("ms");
 assertThat(logs.get(1))
   .startsWith("Bar | time=")
   .endsWith("ms");
}
origin: SonarSource/sonarqube

@Test
public void stopTrace_clears_context() {
 tester.setLevel(LoggerLevel.TRACE);
 addSomeContext(underTest);
 underTest.logTimeLast(true);
 underTest.start().stopTrace("Foo");
 underTest.start().stopTrace("Bar");
 assertThat(tester.logs()).hasSize(2);
 List<String> logs = tester.logs(LoggerLevel.TRACE);
 assertThat(logs.get(0))
   .startsWith("Foo | a_string=bar | an_int=42 | after_start=true | time=")
   .endsWith("ms");
 assertThat(logs.get(1))
   .startsWith("Bar | time=")
   .endsWith("ms");
}
origin: SonarSource/sonarqube

@Test
@UseDataProvider("logTimeLastValues")
public void log_on_at_stop(boolean logTimeLast) {
 underTest.logTimeLast(logTimeLast);
 tester.setLevel(LoggerLevel.TRACE);
 // trace
 underTest.start();
 underTest.stopTrace("Rules registered");
 assertThat(tester.logs()).hasSize(1);
 assertThat(tester.logs().get(0)).startsWith("Rules registered | time=");
 tester.clear();
 // debug
 underTest.start();
 underTest.stopDebug("Rules registered {} on {}", 6, 10);
 assertThat(tester.logs()).hasSize(1);
 assertThat(tester.logs().get(0)).startsWith("Rules registered 6 on 10 | time=");
 tester.clear();
 // info
 underTest.start();
 underTest.stopInfo("Rules registered");
 assertThat(tester.logs()).hasSize(1);
 assertThat(tester.logs().get(0)).startsWith("Rules registered | time=");
}
origin: SonarSource/sonarqube

@Test
@UseDataProvider("logTimeLastValues")
public void stop_reuses_start_message(boolean logTimeLast) throws InterruptedException {
 underTest.logTimeLast(logTimeLast);
 tester.setLevel(LoggerLevel.TRACE);
origin: org.sonarsource.sonarqube/sonar-ce

 private static void addContext(Profiler profiler, CeTask task) {
  profiler
   .logTimeLast(true)
   .addContext("project", task.getComponentKey())
   .addContext("type", task.getType())
   .addContext("id", task.getUuid());
  String submitterLogin = task.getSubmitterLogin();
  if (submitterLogin != null) {
   profiler.addContext("submitter", submitterLogin);
  }
 }
}
org.sonar.core.util.logsProfilerlogTimeLast

Javadoc

Defines whether time is added to stop messages before or after context (if any).

flag is false by default.

Popular methods of Profiler

  • create
  • stopInfo
  • startInfo
  • stopError
  • addContext
    Context information is removed if value is null.
  • createIfTrace
  • start
  • startTrace
  • stopTrace
  • hasContext
  • stopDebug
  • createIfDebug
  • stopDebug,
  • createIfDebug,
  • isDebugEnabled,
  • isTraceEnabled,
  • startDebug

Popular in Java

  • Parsing JSON documents to java classes using gson
  • putExtra (Intent)
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • StringTokenizer (java.util)
    The string tokenizer class allows an application to break a string into tokens. The tokenization met
  • JList (javax.swing)
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