Tabnine Logo
Profiler.addContext
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: SonarSource/sonarqube

private static void addSomeContext(Profiler profiler) {
 profiler.addContext("a_string", "bar");
 profiler.addContext("null_value", null);
 profiler.addContext("an_int", 42);
 profiler.addContext("after_start", true);
}
origin: SonarSource/sonarqube

 @Override
 public ComputationStep.Statistics add(String key, Object value) {
  requireNonNull(key, "Statistic has null key");
  requireNonNull(value, () -> format("Statistic with key [%s] has null value", key));
  checkArgument(!key.equalsIgnoreCase("time"), "Statistic with key [time] is not accepted");
  checkArgument(!profiler.hasContext(key), "Statistic with key [%s] is already present", key);
  profiler.addContext(key, value);
  return this;
 }
}
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

private static void stopLogProfiler(Profiler profiler, CeActivityDto.Status status) {
 profiler.addContext("status", status.name());
 profiler.stopInfo("Executed task");
}
origin: SonarSource/sonarqube

@Test
public void start_writes_no_log_even_if_there_is_context() {
 underTest.addContext("a_string", "bar");
 underTest.addContext("null_value", null);
 underTest.addContext("an_int", 42);
 underTest.start();
 // do not write context as there's no message
 assertThat(tester.logs()).isEmpty();
}
origin: SonarSource/sonarqube

private void executeStep(Profiler stepProfiler, ComputationStep.Context context, ComputationStep step) {
 String status = "FAILED";
 stepProfiler.start();
 try {
  taskInterrupter.check(Thread.currentThread());
  step.execute(context);
  status = "SUCCESS";
 } finally {
  stepProfiler.addContext("status", status);
  stepProfiler.stopInfo(step.getDescription());
 }
}
origin: SonarSource/sonarqube

 @Test
 public void hasContext() {
  assertThat(underTest.hasContext("foo")).isFalse();

  underTest.addContext("foo", "bar");
  assertThat(underTest.hasContext("foo")).isTrue();

  underTest.addContext("foo", null);
  assertThat(underTest.hasContext("foo")).isFalse();
 }
}
origin: SonarSource/sonarqube

@Test
public void empty_message() {
 underTest.addContext("foo", "bar");
 underTest.startInfo("");
 assertThat(tester.logs()).containsOnly("foo=bar");
 underTest.addContext("after_start", true);
 underTest.stopInfo("");
 assertThat(tester.logs()).hasSize(2);
 assertThat(tester.logs().get(1))
  .startsWith("time=")
  .endsWith("ms | foo=bar | after_start=true");
}
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.logsProfileraddContext

Javadoc

Context information is removed if value is null.

Popular methods of Profiler

  • create
  • stopInfo
  • startInfo
  • stopError
  • createIfTrace
  • logTimeLast
    Defines whether time is added to stop messages before or after context (if any). flag is false by d
  • start
  • startTrace
  • stopTrace
  • hasContext
  • stopDebug
  • createIfDebug
  • stopDebug,
  • createIfDebug,
  • isDebugEnabled,
  • isTraceEnabled,
  • startDebug

Popular in Java

  • Creating JSON documents from java classes using gson
  • onRequestPermissionsResult (Fragment)
  • compareTo (BigDecimal)
  • getContentResolver (Context)
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • JFileChooser (javax.swing)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now