Search in sources :

Example 1 with SingleSubsystemSummary

use of org.graylog2.rest.models.system.loggers.responses.SingleSubsystemSummary in project graylog2-server by Graylog2.

the class LoggersResource method subsystems.

@GET
@Timed
@Path("/subsystems")
@ApiOperation(value = "List all logger subsystems and their current levels")
@Produces(MediaType.APPLICATION_JSON)
public SubsystemSummary subsystems() {
    final Map<String, SingleSubsystemSummary> subsystems = Maps.newHashMap();
    for (Map.Entry<String, Subsystem> subsystem : SUBSYSTEMS.entrySet()) {
        if (!isPermitted(RestPermissions.LOGGERS_READSUBSYSTEM, subsystem.getKey())) {
            continue;
        }
        try {
            final String category = subsystem.getValue().getCategory();
            final Level level = getLoggerLevel(category);
            subsystems.put(subsystem.getKey(), SingleSubsystemSummary.create(subsystem.getValue().getTitle(), subsystem.getValue().getCategory(), subsystem.getValue().getDescription(), level.toString().toLowerCase(Locale.ENGLISH), level.intLevel()));
        } catch (Exception e) {
            LOG.error("Error while listing logger subsystem.", e);
        }
    }
    return SubsystemSummary.create(subsystems);
}
Also used : SingleSubsystemSummary(org.graylog2.rest.models.system.loggers.responses.SingleSubsystemSummary) Level(org.apache.logging.log4j.Level) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) NotFoundException(javax.ws.rs.NotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Map (java.util.Map)1 GET (javax.ws.rs.GET)1 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)1 NotFoundException (javax.ws.rs.NotFoundException)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Level (org.apache.logging.log4j.Level)1 SingleSubsystemSummary (org.graylog2.rest.models.system.loggers.responses.SingleSubsystemSummary)1