Search in sources :

Example 6 with LogLevels

use of alma.Logging.LoggingConfigurablePackage.LogLevels in project ACS by ACS-Community.

the class AcsAlarmSystem method get_logLevels.

/**
	 * Gets log levels for a particular named logger. If the returned field
	 * LogLevels.useDefault is true, then the logger uses the default levels,
	 * see get_default_logLevels(); otherwise the returned local and remote
	 * levels apply.
	 * <p>
	 * For possible convenience, the default levels are returned in addition to 
	 * setting {@link LogLevels#useDefault} to <code>true</code>.
	 */
public LogLevels get_logLevels(String logger_name) throws LoggerDoesNotExistEx {
    UnnamedLogger xsdLevels = logConfig.getNamedLoggerConfig(logger_name);
    boolean useDefault = !logConfig.hasCustomConfig(logger_name);
    LogLevels ret = AcsLogLevelDefinition.createIdlLogLevelsFromXsd(useDefault, xsdLevels);
    return ret;
}
Also used : UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) LogLevels(alma.Logging.LoggingConfigurablePackage.LogLevels)

Example 7 with LogLevels

use of alma.Logging.LoggingConfigurablePackage.LogLevels in project ACS by ACS-Community.

the class AcsContainer method get_default_logLevels.

// ///////////////////////////////////////////////////////////
// LoggingConfigurable interface
// ///////////////////////////////////////////////////////////
/**
	 * Gets the log levels of the default logging configuration. These levels
	 * are used by all loggers that have not been configured individually.
	 */
public LogLevels get_default_logLevels() {
    tryToWaitForContainerStart();
    LogLevels logLevels = new LogLevels();
    logLevels.useDefault = false;
    logLevels.minLogLevel = (short) logConfig.getDefaultMinLogLevel().value;
    logLevels.minLogLevelLocal = (short) logConfig.getDefaultMinLogLevelLocal().value;
    return logLevels;
}
Also used : LogLevels(alma.Logging.LoggingConfigurablePackage.LogLevels)

Example 8 with LogLevels

use of alma.Logging.LoggingConfigurablePackage.LogLevels in project ACS by ACS-Community.

the class LogLevelSelectorPanel method loggersLbl.

/**
	 * Gets the loggers and their levels.
	 * <p>
	 * This method makes remote calls and should not be called in the event thread! 
	 * 
	 * @return
	 * @throws AcsJCORBAProblemEx In case of ORB / network failure or if remote process is unresponsive or unreachable.
	 */
private LogLevelHelper[] loggersLbl() throws AcsJCORBAProblemEx {
    List<LogLevelHelper> ret = new ArrayList<LogLevelHelper>();
    try {
        // get the logger names
        final String[] logNames = logConf.get_logger_names();
        // get the log levels for each logger
        for (String logName : logNames) {
            try {
                LogLevels logLevels = logConf.get_logLevels(logName);
                ret.add(new LogLevelHelper(logName, logLevels));
            } catch (LoggerDoesNotExistEx ex) {
                logger.warning("Failed to retrieve log levels info for logger '" + logName + "'. Will skip this logger.");
            }
        }
        return ret.toArray(new LogLevelHelper[0]);
    } catch (SystemException ex) {
        AcsJCORBAProblemEx ex2 = new AcsJCORBAProblemEx(ex);
        ex2.setInfo("Failed to retrieve logger names or levels.");
        throw ex2;
    }
}
Also used : AcsJCORBAProblemEx(alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx) SystemException(org.omg.CORBA.SystemException) ArrayList(java.util.ArrayList) LoggerDoesNotExistEx(alma.Logging.LoggerDoesNotExistEx) LogLevels(alma.Logging.LoggingConfigurablePackage.LogLevels)

Example 9 with LogLevels

use of alma.Logging.LoggingConfigurablePackage.LogLevels in project ACS by ACS-Community.

the class LogLevelSelectorPanel method applyChanges.

/**
	 * Apply the changes to the log levels, if any.
	 * <p>
	 * TODO: This method makes remote calls and should not be called in the event thread.
	 *       However this would require more refactoring, because it currently also accesses swing components.
	 * 
	 * @throws AcsJCORBAProblemEx In case of ORB / network failure or if remote process is unresponsive or unreachable.
	 */
private void applyChanges() {
    try {
        for (LogLevelHelper logLvl : model.getLevels()) {
            if (logLvl.modified()) {
                // see reset of modification flag in the changesApplied call below
                System.out.println("Applying new log levels to " + logLvl.getName() + ": <" + logLvl.isUsingDefault() + ", " + logLvl.getGlobalLevel() + ", " + logLvl.getLocalLevel() + ">");
                logConf.set_logLevels(logLvl.getName(), logLvl.getLogLevels());
            }
        }
        int localIndex = allLocalCB.getSelectedIndex();
        LogTypeHelper local = LogTypeHelper.values()[localIndex];
        final int localAcs = local.getAcsCoreLevel().value;
        int globalIndex = allGlobalCB.getSelectedIndex();
        LogTypeHelper global = LogTypeHelper.values()[globalIndex];
        final int globalAcs = global.getAcsCoreLevel().value;
        boolean useDefault = logConf.get_default_logLevels().useDefault;
        LogLevels toset = new LogLevels(useDefault, (short) globalAcs, (short) localAcs);
        logConf.set_default_logLevels(toset);
        model.changesApplied();
        updateMinLevels();
        applyBtn.setEnabled(false);
    } catch (SystemException ex) {
        //			AcsJCORBAProblemEx ex2 = new AcsJCORBAProblemEx(ex);
        String msg = "Failed to set log levels for '" + getName() + "' because of Corba errors. Giving up, also for other loggers of the same process.";
        logger.log(Level.WARNING, msg, ex);
        JOptionPane.showMessageDialog(null, msg + " \nCheck the logs for details.", "Error", JOptionPane.ERROR_MESSAGE);
    } catch (Exception ex) {
        //			AcsJUnexpectedExceptionEx ex2 = new AcsJUnexpectedExceptionEx(ex);
        String msg = "Failed to set log levels for '" + getName() + "'. Giving up, also for other loggers of the same process.";
        logger.log(Level.WARNING, msg, ex);
        JOptionPane.showMessageDialog(null, msg + " \nCheck the logs for details.", "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : SystemException(org.omg.CORBA.SystemException) LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper) SystemException(org.omg.CORBA.SystemException) LogLvlSelNotSupportedException(alma.acs.gui.loglevel.LogLvlSelNotSupportedException) LogLevels(alma.Logging.LoggingConfigurablePackage.LogLevels)

Example 10 with LogLevels

use of alma.Logging.LoggingConfigurablePackage.LogLevels in project ACS by ACS-Community.

the class AcsAlarmSystem method get_default_logLevels.

/**
	 * Gets the log levels of the default logging configuration. These levels
	 * are used by all loggers that have not been configured individually.
	 */
public LogLevels get_default_logLevels() {
    LogLevels logLevels = new LogLevels();
    logLevels.useDefault = false;
    logLevels.minLogLevel = (short) logConfig.getDefaultMinLogLevel().value;
    logLevels.minLogLevelLocal = (short) logConfig.getDefaultMinLogLevelLocal().value;
    return logLevels;
}
Also used : LogLevels(alma.Logging.LoggingConfigurablePackage.LogLevels)

Aggregations

LogLevels (alma.Logging.LoggingConfigurablePackage.LogLevels)15 UnnamedLogger (alma.maci.loggingconfig.UnnamedLogger)6 SystemException (org.omg.CORBA.SystemException)3 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)2 LogConfig (alma.acs.logging.config.LogConfig)2 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)2 AcsJIllegalArgumentEx (alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx)1 LoggerDoesNotExistEx (alma.Logging.LoggerDoesNotExistEx)1 LogLvlSelNotSupportedException (alma.acs.gui.loglevel.LogLvlSelNotSupportedException)1 LockableUnnamedLogger (alma.acs.logging.config.LogConfig.LockableUnnamedLogger)1 ArrayList (java.util.ArrayList)1