Search in sources :

Example 1 with NamedLoggerConfig

use of alma.acs.tmcdb.NamedLoggerConfig in project ACS by ACS-Community.

the class HibernateWDALImpl method persistLoggingConfig.

private LoggingConfig persistLoggingConfig(Session session, DAOOperations dao, boolean required) throws CDBFieldDoesNotExistEx, WrongCDBDataTypeEx {
    LoggingConfig loggingConfig = new LoggingConfig();
    if (required) {
        // TODO can be optimized
        loggingConfig.setMinLogLevelDefault((byte) dao.get_long("LoggingConfig/minLogLevel"));
        loggingConfig.setMinLogLevelLocalDefault((byte) dao.get_long("LoggingConfig/minLogLevelLocal"));
        loggingConfig.setCentralizedLogger(dao.get_string("LoggingConfig/centralizedLogger"));
        loggingConfig.setDispatchPacketSize((byte) dao.get_long("LoggingConfig/dispatchPacketSize"));
        loggingConfig.setImmediateDispatchLevel((byte) dao.get_long("LoggingConfig/immediateDispatchLevel"));
        loggingConfig.setFlushPeriodSeconds((byte) dao.get_long("LoggingConfig/flushPeriodSeconds"));
        loggingConfig.setMaxLogQueueSize(dao.get_long("LoggingConfig/maxLogQueueSize"));
        loggingConfig.setMaxLogsPerSecond(dao.get_long("LoggingConfig/maxLogsPerSecond"));
    } else {
        // TODO can be optimized
        loggingConfig.setMinLogLevelDefault((byte) readLong(dao, "LoggingConfig/minLogLevel", 2));
        loggingConfig.setMinLogLevelLocalDefault((byte) readLong(dao, "LoggingConfig/minLogLevelLocal", 2));
        loggingConfig.setCentralizedLogger(readString(dao, "LoggingConfig/centralizedLogger", "Log"));
        loggingConfig.setDispatchPacketSize((byte) readLong(dao, "LoggingConfig/dispatchPacketSize", 10));
        loggingConfig.setImmediateDispatchLevel((byte) readLong(dao, "LoggingConfig/immediateDispatchLevel", 10));
        loggingConfig.setFlushPeriodSeconds((byte) readLong(dao, "LoggingConfig/flushPeriodSeconds", 10));
        loggingConfig.setMaxLogQueueSize(readLong(dao, "LoggingConfig/maxLogQueueSize", 1000));
        loggingConfig.setMaxLogsPerSecond(readLong(dao, "LoggingConfig/maxLogsPerSecond", -1));
    }
    session.persist(loggingConfig);
    final String[] LC_ATTRIBUTES = { "minLogLevel", "minLogLevelLocal", "centralizedLogger", "dispatchPacketSize", "immediateDispatchLevel", "flushPeriodSeconds", "maxLogQueueSize", "maxLogsPerSecond" };
    String[] children;
    if (required)
        children = dao.get_string_seq("LoggingConfig/");
    else
        children = readStringSeq(dao, "LoggingConfig/", new String[0]);
    for (String childName : children) {
        boolean attribute = false;
        for (int i = 0; i < LC_ATTRIBUTES.length; i++) if (childName.equals(LC_ATTRIBUTES[i])) {
            attribute = true;
            break;
        }
        if (!attribute) {
            NamedLoggerConfig namedLoggerConfig = new NamedLoggerConfig();
            namedLoggerConfig.setLoggingConfig(loggingConfig);
            namedLoggerConfig.setName(dao.get_string("LoggingConfig/" + childName + "/Name"));
            namedLoggerConfig.setMinLogLevel((byte) dao.get_long("LoggingConfig/" + childName + "/minLogLevel"));
            namedLoggerConfig.setMinLogLevelLocal((byte) dao.get_long("LoggingConfig/" + childName + "/minLogLevelLocal"));
            session.persist(namedLoggerConfig);
        }
    }
    return loggingConfig;
}
Also used : NamedLoggerConfig(alma.acs.tmcdb.NamedLoggerConfig) LoggingConfig(alma.acs.tmcdb.LoggingConfig)

Aggregations

LoggingConfig (alma.acs.tmcdb.LoggingConfig)1 NamedLoggerConfig (alma.acs.tmcdb.NamedLoggerConfig)1