Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-5700

New logging API to remove coupling on SLF4J

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.1
    • Component/s: Plugin API
    • Labels:
      None

      Description

      SQ should provide its own API to log messages. Any coupling with external libs like SLF4J or Logback must be removed. It will allow batch, in future versions, do directly use the underlying logging facility, for example Maven log.

      API:

      import org.sonar.api.utils.log.*;
      public class MyClass {
        private final Logger logger = Loggers.get(getClass());
        
        void doSomething() {
          logger.info("foo");
        }
      }
      

      Unit test:

      import org.sonar.api.utils.log.*;
      public class MyClassTest {
       
        @Rule
        public LogTester logTester = new LogTester();
       
        @Test
        public void test() {
          new MyClass().foo();
          
          // verify logs
          assertThat(logTester.logs()).contains("foo");
        }
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              simon.brandhof Simon Brandhof (Inactive)
              Reporter:
              simon.brandhof Simon Brandhof (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: