Search in sources :

Example 1 with RollingIOLog

use of com.serotonin.log.RollingIOLog in project ma-modules-public by infiniteautomation.

the class SerialDataSourceRT method initialize.

@Override
public void initialize() {
    boolean connected = false;
    try {
        if (this.vo.isLogIO()) {
            // PrintWriter log = new PrintWriter(new FileWriter(file, true));
            int fileSize = (int) (vo.getIoLogFileSizeMBytes() * 1000000f);
            int maxFiles = vo.getMaxHistoricalIOLogs();
            ioLog = new RollingIOLog(getIOLogFileName(vo.getId()), Common.getLogsDir(), fileSize, maxFiles);
            ioLog.log("Data source started");
        }
        connected = this.connect();
    } catch (Exception e) {
        LOG.debug("Error while initializing data source", e);
        String msg = e.getMessage();
        if (msg == null) {
            msg = "Unknown";
        }
        raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.serial.connectFailed", msg));
    }
    if (connected) {
        returnToNormal(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis());
    }
    super.initialize();
}
Also used : RollingIOLog(com.serotonin.log.RollingIOLog) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) ShouldNeverHappenException(com.serotonin.ShouldNeverHappenException) SerialPortException(com.infiniteautomation.mango.io.serial.SerialPortException) IOException(java.io.IOException)

Aggregations

SerialPortException (com.infiniteautomation.mango.io.serial.SerialPortException)1 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)1 RollingIOLog (com.serotonin.log.RollingIOLog)1 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)1 IOException (java.io.IOException)1