Search in sources :

Example 1 with WebsocketApiController

use of io.openems.impl.controller.api.websocket.WebsocketApiController in project openems by OpenEMS.

the class WebsocketLogAppender method append.

@Override
protected void append(ILoggingEvent event) {
    long timestamp = event.getTimeStamp();
    String level = event.getLevel().toString();
    String source = event.getLoggerName();
    String message = event.getFormattedMessage();
    ThingRepository thingRepository = ThingRepository.getInstance();
    for (Scheduler scheduler : thingRepository.getSchedulers()) {
        for (Controller controller : scheduler.getControllers()) {
            if (controller instanceof WebsocketApiController) {
                WebsocketApiController websocketApiController = (WebsocketApiController) controller;
                websocketApiController.sendLog(timestamp, level, source, message);
            }
        }
    }
    // send to fenecon persistence
    ThingRepository.getInstance().getPersistences().forEach((persistence) -> {
        if (persistence instanceof FeneconPersistence) {
            FeneconPersistence p = (FeneconPersistence) persistence;
            p.sendLog(timestamp, level, source, message);
        }
    });
}
Also used : ThingRepository(io.openems.core.ThingRepository) WebsocketApiController(io.openems.impl.controller.api.websocket.WebsocketApiController) FeneconPersistence(io.openems.impl.persistence.fenecon.FeneconPersistence) Scheduler(io.openems.api.scheduler.Scheduler) Controller(io.openems.api.controller.Controller) WebsocketApiController(io.openems.impl.controller.api.websocket.WebsocketApiController)

Aggregations

Controller (io.openems.api.controller.Controller)1 Scheduler (io.openems.api.scheduler.Scheduler)1 ThingRepository (io.openems.core.ThingRepository)1 WebsocketApiController (io.openems.impl.controller.api.websocket.WebsocketApiController)1 FeneconPersistence (io.openems.impl.persistence.fenecon.FeneconPersistence)1