use of org.sonar.api.utils.log.LoggerLevel in project sonarqube by SonarSource.
the class ServerLogging method changeLevel.
public void changeLevel(ServerProcessLogging serverProcessLogging, LoggerLevel level) {
Level logbackLevel = Level.toLevel(level.name());
helper.changeRoot(serverProcessLogging.getLogLevelConfig(), logbackLevel);
LoggerFactory.getLogger(ServerLogging.class).info("Level of logs changed to {}", level);
}
use of org.sonar.api.utils.log.LoggerLevel in project sonarqube by SonarSource.
the class ChangeLogLevelAction method handle.
@Override
public void handle(Request wsRequest, Response wsResponse) throws InterruptedException {
userSession.checkIsSystemAdministrator();
LoggerLevel level = LoggerLevel.valueOf(wsRequest.mandatoryParam(PARAM_LEVEL));
service.changeLogLevel(level);
wsResponse.noContent();
}
use of org.sonar.api.utils.log.LoggerLevel in project sonarqube by SonarSource.
the class ChangeLogLevelHttpAction method serve.
@Override
public NanoHTTPD.Response serve(NanoHTTPD.IHTTPSession session) {
if (session.getMethod() != NanoHTTPD.Method.POST) {
return newFixedLengthResponse(METHOD_NOT_ALLOWED, MIME_PLAINTEXT, null);
}
String levelStr = session.getParms().get(PARAM_LEVEL);
if (levelStr == null || levelStr.isEmpty()) {
return newFixedLengthResponse(BAD_REQUEST, MIME_PLAINTEXT, format("Parameter '%s' is missing", PARAM_LEVEL));
}
try {
LoggerLevel level = LoggerLevel.valueOf(levelStr);
logging.changeLevel(level);
return newFixedLengthResponse(OK, MIME_PLAINTEXT, null);
} catch (IllegalArgumentException e) {
Loggers.get(ChangeLogLevelHttpAction.class).debug("Value '{}' for parameter '" + PARAM_LEVEL + "' is invalid: {}", levelStr, e);
return newFixedLengthResponse(BAD_REQUEST, MIME_PLAINTEXT, format("Value '%s' for parameter '%s' is invalid", levelStr, PARAM_LEVEL));
}
}
use of org.sonar.api.utils.log.LoggerLevel in project sonarqube by SonarSource.
the class ServerLogging method changeLevel.
public void changeLevel(LoggerLevel level) {
Level logbackLevel = Level.toLevel(level.name());
database.enableSqlLogging(level == TRACE);
helper.changeRoot(serverProcessLogging.getLogLevelConfig(), logbackLevel);
LoggerFactory.getLogger(ServerLogging.class).info("Level of logs changed to {}", level);
}
Aggregations