Search in sources :

Example 1 with SyslogConfig

use of org.openremote.model.syslog.SyslogConfig in project openremote by openremote.

the class SyslogService method init.

@Override
public void init(Container container) throws Exception {
    executorService = container.getService(ManagerExecutorService.class);
    if (container.hasService(ClientEventService.class) && container.hasService(PersistenceService.class)) {
        LOG.info("Syslog service enabled");
        clientEventService = container.getService(ClientEventService.class);
        persistenceService = container.getService(PersistenceService.class);
    } else {
        LOG.info("Syslog service disabled, missing required services");
    }
    if (clientEventService != null) {
        clientEventService.addSubscriptionAuthorizer((auth, subscription) -> {
            // Only superuser can get logging events
            return subscription.isEventType(SyslogEvent.class) && auth.isSuperUser();
        });
    }
    if (container.hasService(WebService.class)) {
        container.getService(WebService.class).getApiSingletons().add(new SyslogResourceImpl(this));
    }
    // Default config: Store all INFO messages for five days
    config = new SyslogConfig(SyslogLevel.INFO, SyslogCategory.values(), 60 * 24 * 5);
}
Also used : PersistenceService(org.openremote.container.persistence.PersistenceService) SyslogEvent(org.openremote.model.syslog.SyslogEvent) ManagerExecutorService(org.openremote.manager.concurrent.ManagerExecutorService) ClientEventService(org.openremote.manager.event.ClientEventService) SyslogConfig(org.openremote.model.syslog.SyslogConfig)

Aggregations

PersistenceService (org.openremote.container.persistence.PersistenceService)1 ManagerExecutorService (org.openremote.manager.concurrent.ManagerExecutorService)1 ClientEventService (org.openremote.manager.event.ClientEventService)1 SyslogConfig (org.openremote.model.syslog.SyslogConfig)1 SyslogEvent (org.openremote.model.syslog.SyslogEvent)1