use of alma.acs.logging.formatters.ConsoleLogFormatter in project ACS by ACS-Community.
the class AcsLoggerTest method testWrapJdkLogger.
public void testWrapJdkLogger() {
assertSame("Expected reuse of AcsLogger", acsLogger, AcsLogger.fromJdkLogger(acsLogger, null));
Logger jdkLogger = TestLogger.getLogger("myJdkLogger");
Handler[] handlers = jdkLogger.getHandlers();
assertEquals(1, handlers.length);
// to get an ISO timestamp on stdout, for TAT/sed filtering.
handlers[0].setFormatter(new ConsoleLogFormatter());
AcsLogger wrapper = AcsLogger.fromJdkLogger(jdkLogger, null);
assertEquals("myJdkLoggerwrapper", wrapper.getName());
wrapper.info("A message logged by the AcsLogger that wraps the jdkLogger");
}
use of alma.acs.logging.formatters.ConsoleLogFormatter in project ACS by ACS-Community.
the class ClientLogManagerTest method testLoggerStructure.
public void testLoggerStructure() {
Logger containerLogger = clientLogManager.getLoggerForContainer("test");
assertNotNull(containerLogger);
Logger acsRemoteLogger = containerLogger.getParent();
assertNotNull(acsRemoteLogger);
assertFalse(acsRemoteLogger.getUseParentHandlers());
Logger rootLogger = acsRemoteLogger.getParent();
assertNotNull(rootLogger);
assertNull(rootLogger.getParent());
Handler[] handlers = containerLogger.getHandlers();
assertTrue(handlers.length == 2);
StdOutConsoleHandler localHandler = null;
AcsLoggingHandler remoteHandler = null;
for (Handler handler : handlers) {
if (handler instanceof StdOutConsoleHandler) {
localHandler = (StdOutConsoleHandler) handler;
} else if (handler instanceof AcsLoggingHandler) {
remoteHandler = (AcsLoggingHandler) handler;
} else {
fail("Unexpected handler type " + handler.getClass().getName() + " encountered.");
}
}
assertNotNull(localHandler);
assertNotNull(remoteHandler);
Formatter localFormatter = localHandler.getFormatter();
assertTrue("localFormatter should not be of type " + localFormatter.getClass().getName(), localFormatter instanceof ConsoleLogFormatter);
Handler[] parentHandlers = acsRemoteLogger.getHandlers();
assertTrue(parentHandlers.length == 0);
assertEquals(AcsLogLevel.DELOUSE, remoteHandler.getLevel());
containerLogger.info("I'm a good pedigree logger.");
}
use of alma.acs.logging.formatters.ConsoleLogFormatter in project ACS by ACS-Community.
the class ClientLogManager method createStdOutConsoleHandlerWithFormatter.
/**
* Factory method broken out to allow tests to easily use an instrumented variant.
*/
protected StdOutConsoleHandler createStdOutConsoleHandlerWithFormatter(LogConfig logConfig, String loggerName, LogThrottle throttle) {
// subscribes to sharedLogConfig
StdOutConsoleHandler localHandler = new StdOutConsoleHandler(logConfig, loggerName, throttle);
localHandler.setFormatter(new ConsoleLogFormatter());
return localHandler;
}
use of alma.acs.logging.formatters.ConsoleLogFormatter in project ACS by ACS-Community.
the class Manager method initialize.
/**
* Initialize.
*/
protected void initialize() {
getManagerEngine().initialize();
initializeGUI();
LogRecord record = new LogRecord(Level.INFO, "AcsManagerStatusMessage_ManagerStarted Manager Application initialized.");
record.setLoggerName(getManagerEngine().getLogger().getName());
String formattedString = new ConsoleLogFormatter().format(record);
System.out.println(formattedString);
//getManagerEngine().getLogger().log(Level.OFF, "AcsManagerStatusMessage_ManagerStarted Manager Application initialized.");
}
Aggregations