use of alma.acs.logging.AcsLoggingHandler in project ACS by ACS-Community.
the class TestLogLevelsCompImpl method getLevels.
/////////////////////////////////////////////////////////////
// Implementation of TestLogLevelsCompOperations
/////////////////////////////////////////////////////////////
public int[] getLevels() throws CouldntPerformActionEx {
//m_logger.info("getLevels called...");
/*
* alma.maci.loggingconfig.LoggingConfig got generated from LoggingConfig.xsd and
* it contains the "default values" (also called "hardcoded").
*/
levels = new int[5];
LoggingConfig logConfig = new LoggingConfig();
int hcMinLogLevel = Integer.parseInt(logConfig.getMinLogLevel().toString());
int hcMinLogLevelLocal = Integer.parseInt(logConfig.getMinLogLevelLocal().toString());
AcsLogLevel acsLevel = AcsLogLevel.getNativeLevel(m_logger.getLevel());
int acsCoreLevel = acsLevel.getAcsLevel().value;
// get separately the stdout and remote levels
Handler[] handlers = m_logger.getHandlers();
if (handlers.length != 2) {
AcsJCouldntPerformActionEx ex = new AcsJCouldntPerformActionEx();
ex.setProperty(PROP_ASSERTION_MESSAGE, "Found " + handlers.length + " log handlers where 2 were expected.");
throw ex.toCouldntPerformActionEx();
//m_logger.info("Found " + handlers.length + " log handlers where 2 were expected.");
}
AcsLogLevel levelStdout = null;
AcsLogLevel levelRemote = null;
for (Handler logHandler : handlers) {
if (logHandler instanceof StdOutConsoleHandler) {
levelStdout = AcsLogLevel.getNativeLevel(logHandler.getLevel());
} else if (logHandler instanceof AcsLoggingHandler) {
levelRemote = AcsLogLevel.getNativeLevel(logHandler.getLevel());
} else {
AcsJCouldntPerformActionEx ex = new AcsJCouldntPerformActionEx();
ex.setProperty(PROP_ASSERTION_MESSAGE, "Handler " + logHandler + " is neither StdOutConsoleHandler nor AcsLoggingHandler");
throw ex.toCouldntPerformActionEx();
}
}
levels[0] = hcMinLogLevel;
levels[1] = hcMinLogLevelLocal;
levels[2] = acsCoreLevel;
if (// should never be the case, but anyway ...
levelRemote == null)
levels[3] = -1;
else
levels[3] = levelRemote.getAcsLevel().value;
if (// should never be the case, but anyway ...
levelStdout == null)
levels[4] = -1;
else
levels[4] = levelStdout.getAcsLevel().value;
return levels;
}
Aggregations