Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * SonarQube Scanner
  3. * Copyright (C) 2011-2016 SonarSource SA
  4. * mailto:contact AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonarsource.scanner.cli;
  21. import java.util.Properties;
  22. import org.sonar.runner.api.EmbeddedRunner;
  23. import org.sonar.runner.api.LogOutput;
  24. class RunnerFactory {
  25. private final Logs logger;
  26. public RunnerFactory(Logs logger) {
  27. this.logger = logger;
  28. }
  29. EmbeddedRunner create(Properties props) {
  30. return EmbeddedRunner.create(new DefaultLogOutput()).addGlobalProperties(props);
  31. }
  32. class DefaultLogOutput implements LogOutput {
  33. @Override
  34. public void log(String formattedMessage, Level level) {
  35. switch (level) {
  36. case TRACE:
  37. case DEBUG:
  38. logger.debug(formattedMessage);
  39. break;
  40. case ERROR:
  41. logger.error(formattedMessage);
  42. break;
  43. case INFO:
  44. case WARN:
  45. default:
  46. logger.info(formattedMessage);
  47. }
  48. }
  49. }
  50. }