Search in sources :

Example 1 with ConsoleLogFormatter

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");
}
Also used : Handler(java.util.logging.Handler) OperatorLogger(alma.acs.logging.domainspecific.OperatorLogger) ArrayContextLogger(alma.acs.logging.domainspecific.ArrayContextLogger) AntennaContextLogger(alma.acs.logging.domainspecific.AntennaContextLogger) DeveloperLogger(alma.acs.logging.domainspecific.DeveloperLogger) ScienceLogger(alma.acs.logging.domainspecific.ScienceLogger) TestLogger(alma.acs.testsupport.TestLogger) Logger(java.util.logging.Logger) ConsoleLogFormatter(alma.acs.logging.formatters.ConsoleLogFormatter)

Example 2 with ConsoleLogFormatter

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.");
}
Also used : ConsoleLogFormatter(alma.acs.logging.formatters.ConsoleLogFormatter) Formatter(java.util.logging.Formatter) Handler(java.util.logging.Handler) Logger(java.util.logging.Logger) ConsoleLogFormatter(alma.acs.logging.formatters.ConsoleLogFormatter)

Example 3 with ConsoleLogFormatter

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;
}
Also used : ConsoleLogFormatter(alma.acs.logging.formatters.ConsoleLogFormatter)

Example 4 with ConsoleLogFormatter

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.");
}
Also used : LogRecord(java.util.logging.LogRecord) ConsoleLogFormatter(alma.acs.logging.formatters.ConsoleLogFormatter)

Aggregations

ConsoleLogFormatter (alma.acs.logging.formatters.ConsoleLogFormatter)4 Handler (java.util.logging.Handler)2 Logger (java.util.logging.Logger)2 AntennaContextLogger (alma.acs.logging.domainspecific.AntennaContextLogger)1 ArrayContextLogger (alma.acs.logging.domainspecific.ArrayContextLogger)1 DeveloperLogger (alma.acs.logging.domainspecific.DeveloperLogger)1 OperatorLogger (alma.acs.logging.domainspecific.OperatorLogger)1 ScienceLogger (alma.acs.logging.domainspecific.ScienceLogger)1 TestLogger (alma.acs.testsupport.TestLogger)1 Formatter (java.util.logging.Formatter)1 LogRecord (java.util.logging.LogRecord)1