Search in sources :

Example 6 with UnnamedLogger

use of alma.maci.loggingconfig.UnnamedLogger in project ACS by ACS-Community.

the class LogConfigTest method testDynamicChanges.

/**
	 * Tests runtime changes as they could happen via the {@linkplain LoggingConfigurable} API. 
	 */
public void testDynamicChanges() throws Exception {
    logger.info("============ Running testDynamicChanges ============");
    // the default log levels from schema defaults and optional env var setting
    AcsLogLevelDefinition defaultMinLogLevel = logConfig.getDefaultMinLogLevel();
    AcsLogLevelDefinition defaultMinLogLevelLocal = logConfig.getDefaultMinLogLevelLocal();
    // change the default log levels
    AcsLogLevelDefinition newDefaultLevel = defaultMinLogLevel.getNextHigherLevel();
    assertNotNull(newDefaultLevel);
    logConfig.setDefaultMinLogLevel(newDefaultLevel);
    assertSame(newDefaultLevel, logConfig.getDefaultMinLogLevel());
    assertSame(defaultMinLogLevelLocal, logConfig.getDefaultMinLogLevelLocal());
    newDefaultLevel = newDefaultLevel.getNextHigherLevel();
    assertNotNull(newDefaultLevel);
    logConfig.setDefaultMinLogLevel(newDefaultLevel);
    logConfig.setDefaultMinLogLevelLocal(newDefaultLevel);
    assertSame(newDefaultLevel, logConfig.getDefaultMinLogLevel());
    assertSame(newDefaultLevel, logConfig.getDefaultMinLogLevelLocal());
    // restore initial values
    logConfig.setDefaultMinLogLevel(defaultMinLogLevel);
    logConfig.setDefaultMinLogLevelLocal(defaultMinLogLevelLocal);
    // named logger levels 
    String knownLoggerName = "knownLogger";
    // now the logger is known, even though it has default values 
    UnnamedLogger knownLoggerConfig = logConfig.getNamedLoggerConfig(knownLoggerName);
    assertEquals(defaultMinLogLevel, AcsLogLevelDefinition.fromXsdLogLevel(knownLoggerConfig.getMinLogLevel()));
    assertEquals(defaultMinLogLevelLocal, AcsLogLevelDefinition.fromXsdLogLevel(knownLoggerConfig.getMinLogLevelLocal()));
    Set<String> loggerNames = logConfig.getLoggerNames();
    assertEquals(1, loggerNames.size());
    assertTrue(loggerNames.contains(knownLoggerName));
    String unknownLoggerName = "unknownLogger";
    // first encounter with this logger when setting its levels
    logConfig.setMinLogLevel(AcsLogLevelDefinition.DEBUG, unknownLoggerName);
    loggerNames = logConfig.getLoggerNames();
    assertEquals(2, loggerNames.size());
    assertTrue(loggerNames.contains(knownLoggerName));
    assertTrue(loggerNames.contains(unknownLoggerName));
    // make sure that returned objects are not "live" for the logConfig data
    knownLoggerConfig = logConfig.getNamedLoggerConfig(knownLoggerName);
    UnnamedLogger knownLoggerConfig2 = logConfig.getNamedLoggerConfig(knownLoggerName);
    assertNotSame(knownLoggerConfig, knownLoggerConfig2);
    newDefaultLevel = newDefaultLevel.getNextHigherLevel();
    assertNotNull(newDefaultLevel);
    knownLoggerConfig.setMinLogLevel(newDefaultLevel.toXsdLevel());
    assertSame(defaultMinLogLevel, logConfig.getDefaultMinLogLevel());
    newDefaultLevel = newDefaultLevel.getNextHigherLevel();
    assertNotNull(newDefaultLevel);
    logConfig.setDefaultMinLogLevel(newDefaultLevel);
    assertEquals(defaultMinLogLevel, AcsLogLevelDefinition.fromXsdLogLevel(knownLoggerConfig2.getMinLogLevel()));
}
Also used : UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) AcsLogLevelDefinition(alma.acs.logging.level.AcsLogLevelDefinition)

Example 7 with UnnamedLogger

use of alma.maci.loggingconfig.UnnamedLogger in project ACS by ACS-Community.

the class AcsAlarmSystem method set_logLevels.

/**
	 * Sets log levels for a particular named logger. If levels.useDefault is
	 * true, then the logger will be reset to using default levels; otherwise it
	 * will use the supplied local and remote levels.
	 */
public void set_logLevels(String logger_name, LogLevels levels) throws LoggerDoesNotExistEx, IllegalLogLevelsEx {
    if (levels.useDefault) {
        logConfig.clearNamedLoggerConfig(logger_name);
    } else {
        try {
            UnnamedLogger config = AcsLogLevelDefinition.createXsdLogLevelsFromIdl(levels);
            logConfig.setNamedLoggerConfig(logger_name, config);
        } catch (AcsJIllegalArgumentEx ex) {
            //throw ex.toIllegalArgumentEx();
            IllegalLogLevelsEx ille = new IllegalLogLevelsEx(ex.getErrorDesc());
            throw ille;
        }
    }
}
Also used : IllegalLogLevelsEx(alma.Logging.IllegalLogLevelsEx) UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) AcsJIllegalArgumentEx(alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx)

Example 8 with UnnamedLogger

use of alma.maci.loggingconfig.UnnamedLogger 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 9 with UnnamedLogger

use of alma.maci.loggingconfig.UnnamedLogger in project ACS by ACS-Community.

the class AcsContainer method set_logLevels.

/**
	 * Sets log levels for a particular named logger. If levels.useDefault is
	 * true, then the logger will be reset to using default levels; otherwise it
	 * will use the supplied local and remote levels.
	 */
public void set_logLevels(String logger_name, LogLevels levels) throws LoggerDoesNotExistEx, IllegalLogLevelsEx {
    tryToWaitForContainerStart();
    if (levels.useDefault) {
        logConfig.clearNamedLoggerConfig(logger_name);
    } else {
        try {
            UnnamedLogger config = AcsLogLevelDefinition.createXsdLogLevelsFromIdl(levels);
            logConfig.setNamedLoggerConfig(logger_name, config);
        } catch (AcsJIllegalArgumentEx ex) {
            //throw ex.toIllegalArgumentEx();
            IllegalLogLevelsEx ille = new IllegalLogLevelsEx(ex.getErrorDesc());
            throw ille;
        }
    }
}
Also used : IllegalLogLevelsEx(alma.Logging.IllegalLogLevelsEx) UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) LockableUnnamedLogger(alma.acs.logging.config.LogConfig.LockableUnnamedLogger) AcsJIllegalArgumentEx(alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx)

Example 10 with UnnamedLogger

use of alma.maci.loggingconfig.UnnamedLogger in project ACS by ACS-Community.

the class LaserComponent 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)

Aggregations

UnnamedLogger (alma.maci.loggingconfig.UnnamedLogger)19 AcsJIllegalArgumentEx (alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx)6 IllegalLogLevelsEx (alma.Logging.IllegalLogLevelsEx)6 LogLevels (alma.Logging.LoggingConfigurablePackage.LogLevels)6 LoggingConfig (alma.maci.loggingconfig.LoggingConfig)4 AcsLogLevelDefinition (alma.acs.logging.level.AcsLogLevelDefinition)3 LogConfig (alma.acs.logging.config.LogConfig)2 LockableUnnamedLogger (alma.acs.logging.config.LogConfig.LockableUnnamedLogger)2 StringReader (java.io.StringReader)2 CastorException (org.exolab.castor.core.exceptions.CastorException)2 JacORBFilter (alma.acs.logging.adapters.JacORBFilter)1 ReaderExtractor (alma.acs.util.ReaderExtractor)1 CDBRecordDoesNotExistEx (alma.cdbErrType.CDBRecordDoesNotExistEx)1 CDBXMLErrorEx (alma.cdbErrType.CDBXMLErrorEx)1 NamedLogger (alma.maci.loggingconfig.NamedLogger)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Filter (java.util.logging.Filter)1