Search in sources :

Example 1 with DefaultTetradLoggerConfig

use of edu.cmu.tetrad.util.DefaultTetradLoggerConfig in project tetrad by cmu-phil.

the class TetradApplicationConfig method configureLogger.

/**
 * Configures the logger that the given element represents and returns its
 * id.
 */
private static TetradLoggerConfig configureLogger(Element logger) {
    Elements elements = logger.getChildElements();
    List<TetradLoggerConfig.Event> events = new LinkedList<>();
    List<String> defaultLog = new LinkedList<>();
    for (int i = 0; i < elements.size(); i++) {
        Element event = elements.get(i);
        String eventId = event.getAttributeValue("id");
        String description = event.getAttributeValue("description");
        String defaultOption = event.getAttributeValue("default");
        if (defaultOption != null && defaultOption.equals("on")) {
            defaultLog.add(eventId);
        }
        events.add(new DefaultTetradLoggerConfig.DefaultEvent(eventId, description));
    }
    TetradLoggerConfig config = new DefaultTetradLoggerConfig(events);
    // set any defaults
    for (String event : defaultLog) {
        config.setEventActive(event, true);
    }
    return config;
}
Also used : DefaultTetradLoggerConfig(edu.cmu.tetrad.util.DefaultTetradLoggerConfig) TetradLoggerConfig(edu.cmu.tetrad.util.TetradLoggerConfig) Element(nu.xom.Element) Elements(nu.xom.Elements) DefaultTetradLoggerConfig(edu.cmu.tetrad.util.DefaultTetradLoggerConfig)

Aggregations

DefaultTetradLoggerConfig (edu.cmu.tetrad.util.DefaultTetradLoggerConfig)1 TetradLoggerConfig (edu.cmu.tetrad.util.TetradLoggerConfig)1 Element (nu.xom.Element)1 Elements (nu.xom.Elements)1