Search in sources :

Example 16 with AcsLogger

use of alma.acs.logging.AcsLogger in project ACS by ACS-Community.

the class AcsContainer method set_statistics_logger_configuration_byname.

/**
     * Sets logger statistics configuration for a particular named logger.
     * Throws LoggerDoesNotExistEx if a the logger is not found 
     */
public void set_statistics_logger_configuration_byname(String logger_name, LogStatsInformation statsInformation) throws alma.Logging.LoggerDoesNotExistEx {
    // Retrieve logger by logger name
    AcsLogger retrievedLogger = ClientLogManager.getAcsLogManager().getLoggerByName(logger_name);
    // Verification if logger does exist (!= null)
    if (retrievedLogger == null) {
        LoggerDoesNotExistEx inexistantLoggerEx = new LoggerDoesNotExistEx(logger_name);
        throw inexistantLoggerEx;
    }
    // Configure logger
    retrievedLogger.stats.configureStatistics(statsInformation.statsId, statsInformation.statsStatus, statsInformation.statsPeriodConfiguration, statsInformation.statsGranularityConfiguration);
    return;
}
Also used : LoggerDoesNotExistEx(alma.Logging.LoggerDoesNotExistEx) AcsLogger(alma.acs.logging.AcsLogger)

Example 17 with AcsLogger

use of alma.acs.logging.AcsLogger in project ACS by ACS-Community.

the class CorbaNullFinderTest method testJacorbNullBehavior.

/**
	 * Tests jacorb's reaction to null data inside structs.
	 * If this test fails after a jacorb update, the logic of the Null Finder must be revisited.
	 */
public void testJacorbNullBehavior() throws Exception {
    // Below we'll need an ORB... 
    AcsLogger logger = ClientLogManager.getAcsLogManager().getLoggerForApplication("testOrbLogger", false);
    AcsCorba acsCorba = new AcsCorba(logger);
    acsCorba.initCorbaForClient(false);
    // Jacorb uses ReplyOutputStream, but its base class ServiceContextTransportingOutputStream is easier to construct
    // and should be similar enough for this test.
    OutputStream out = new ServiceContextTransportingOutputStream(acsCorba.getORB());
    Struct2 myStruct2 = ComponentWithBadNullsImpl.createGoodStruct2();
    // the good data should marshal without exception
    Struct2Helper.write(out, myStruct2);
    // null string
    try {
        myStruct2.mystruct1.mystring = null;
        Struct2Helper.write(out, myStruct2);
        fail("null strings in structs should marshal with exception.");
    } catch (MARSHAL ex) {
        // expected
        assertEquals("org.omg.CORBA.MARSHAL: Cannot marshall null string.", ex.toString());
    }
    // null enum
    myStruct2 = ComponentWithBadNullsImpl.createGoodStruct2();
    try {
        myStruct2.mystruct1.myenum1 = null;
        Struct2Helper.write(out, myStruct2);
        fail("null strings in structs should marshal with NPE.");
    } catch (NullPointerException ex) {
    // expected... this is a really mean case, because we get NPE instead of MARSHAL. Maybe a jacorb bug?
    }
    // null struct
    myStruct2 = ComponentWithBadNullsImpl.createGoodStruct2();
    try {
        myStruct2.mystruct1 = null;
        Struct2Helper.write(out, myStruct2);
        fail("null structs inside structs should marshal with NPE.");
    } catch (NullPointerException ex) {
    // expected... this is a really mean case, because we get NPE instead of MARSHAL. Maybe a jacorb bug?
    }
    // top-level struct itself is null
    try {
        Struct2Helper.write(out, null);
        fail("top-level null structs should marshal with NPE.");
    } catch (NullPointerException ex) {
    // expected... 
    }
    // null sequence of structs
    myStruct2 = ComponentWithBadNullsImpl.createGoodStruct2();
    try {
        myStruct2.seqOfStruct1 = null;
        Struct2Helper.write(out, myStruct2);
        fail("null sequence of structs inside structs should marshal with NPE.");
    } catch (NullPointerException ex) {
    // expected... this is a really mean case, because we get NPE instead of MARSHAL. Maybe a jacorb bug?
    }
    // sequence with null struct
    myStruct2 = ComponentWithBadNullsImpl.createGoodStruct2();
    try {
        // with null inside
        myStruct2.seqOfStruct1 = new Struct1[1];
        Struct2Helper.write(out, myStruct2);
        fail("sequence of structs with nulls should marshal with NPE.");
    } catch (NullPointerException ex) {
    // expected... this is a really mean case, because we get NPE instead of MARSHAL. Maybe a jacorb bug?
    }
}
Also used : ServiceContextTransportingOutputStream(org.jacorb.orb.giop.ServiceContextTransportingOutputStream) ServiceContextTransportingOutputStream(org.jacorb.orb.giop.ServiceContextTransportingOutputStream) OutputStream(org.omg.CORBA.portable.OutputStream) Struct2(alma.jconttest.ComponentWithBadNullsPackage.Struct2) MARSHAL(org.omg.CORBA.MARSHAL) AcsLogger(alma.acs.logging.AcsLogger)

Example 18 with AcsLogger

use of alma.acs.logging.AcsLogger in project ACS by ACS-Community.

the class Log4jFactory method makeNewLoggerInstance.

@Override
public synchronized Logger makeNewLoggerInstance(String name) {
    //		System.out.println("*** makeNewLoggerInstance called, name=" + name + " ***");
    // Check which framework is requesting the log4j logger
    String loggerNameBase = "unknown";
    StackTraceElement[] stackTrace = (new Exception()).getStackTrace();
    for (StackTraceElement stackTraceElement : stackTrace) {
        if (stackTraceElement.getClassName().contains("cern.laser.")) {
            loggerNameBase = LASER_LOGGER_NAME_PREFIX;
            break;
        }
    // TODO: add check for other frameworks that use log4j, once we have those
    }
    // Check if we already have a logger for the client framework, and create it if needed.
    Logger myLogger = loggerMap.get(loggerNameBase);
    if (myLogger == null) {
        AcsLogger delegate = ClientLogManager.getAcsLogManager().getLoggerForCorba(loggerNameBase, true);
        myLogger = new Log4jLogger(loggerNameBase, delegate);
        loggerMap.put(loggerNameBase, myLogger);
    }
    return myLogger;
}
Also used : RootLogger(org.apache.log4j.spi.RootLogger) Logger(org.apache.log4j.Logger) AcsLogger(alma.acs.logging.AcsLogger) AcsLogger(alma.acs.logging.AcsLogger)

Example 19 with AcsLogger

use of alma.acs.logging.AcsLogger in project ACS by ACS-Community.

the class FrameworkLoggerTest method testDummyFrameworkLogger.

/**
	 * Other framework loggers did not have the same problem
	 * as the jacorb logger. Thus this test always passed.
	 */
@Test
public void testDummyFrameworkLogger() throws Exception {
    LogConfig logConfig = clientLogManager.getLogConfig();
    final String expectedFrameworkLoggerName = "myFW@" + FrameworkLoggerTest.class.getSimpleName();
    assertThat("Dummy framework logger should NOT be known beforehand.", logConfig.isKnownLogger(expectedFrameworkLoggerName), is(false));
    assertThat("Framework logger configuration should be DEBUG, as controlled by ACS_LOG_STDOUT.", AcsLogLevelDefinition.fromXsdLogLevel(logConfig.getNamedLoggerConfig(expectedFrameworkLoggerName).getMinLogLevelLocal()), equalTo(AcsLogLevelDefinition.DEBUG));
    // Check if the framework logger is configured in line with the above logConfig results
    AcsLogger myFWLogger = ClientLogManager.getAcsLogManager().getLoggerForCorba("myFW", true);
    myFWLogger.finer("A framework test log, should be shown.");
    assertThat(myFWLogger.isLoggable(AcsLogLevel.TRACE), is(false));
    assertThat(myFWLogger.isLoggable(AcsLogLevel.DELOUSE), is(true));
}
Also used : LogConfig(alma.acs.logging.config.LogConfig) AcsLogger(alma.acs.logging.AcsLogger) Test(org.junit.Test)

Example 20 with AcsLogger

use of alma.acs.logging.AcsLogger in project ACS by ACS-Community.

the class FrameworkLoggerTest method testJacorbLogger.

@Test
public void testJacorbLogger() throws Exception {
    LogConfig logConfig = clientLogManager.getLogConfig();
    final String expectedJacorbLoggerName = "jacorb@" + FrameworkLoggerTest.class.getSimpleName();
    assertThat("jacorb logger should be known already from base class corba calls.", logConfig.isKnownLogger(expectedJacorbLoggerName), is(true));
    // JacORB config file "orb.properties" currently contains "jacorb.log.default.verbosity=2" (mapped to INFO), 
    // but it is not visible as a system property and thus cannot be verified here.
    // This test must be started with "-Djacorb.log.default.verbosity=3" (DEBUG) so that we can assert
    // the right jacorb log level.
    assertThat("Expected system property jacorb.log.default.verbosity=3 set. Check the test start script!", System.getProperty("jacorb.log.default.verbosity"), equalTo("3"));
    assertThat("Stdout log level must be DEBUG or lower, to not override the jacorb log level.", logConfig.getDefaultMinLogLevelLocal(), lessThanOrEqualTo(AcsLogLevelDefinition.DEBUG));
    assertThat("jacorb logger configuration should be DEBUG for local logging.", AcsLogLevelDefinition.fromXsdLogLevel(logConfig.getNamedLoggerConfig(expectedJacorbLoggerName).getMinLogLevelLocal()), equalTo(AcsLogLevelDefinition.DEBUG));
    // Check if the jacorb logger itself is configured according to the above logConfig results
    AcsLogger jacorbLogger = ClientLogManager.getAcsLogManager().getLoggerForCorba("jacorb", true);
    jacorbLogger.fine("A jacorb test log, should be shown.");
    assertThat(jacorbLogger.isLoggable(AcsLogLevel.TRACE), is(false));
    assertThat(jacorbLogger.isLoggable(AcsLogLevel.DELOUSE), is(false));
    assertThat(jacorbLogger.isLoggable(AcsLogLevel.DEBUG), is(true));
    // This setMinLogLevelLocal effects a call to LogConfig#notifySubscribers(), 
    // which in the past brought out the jacorb logs even when the above "A jacorb test log, should be shown." 
    // was not logged due a bug.
    logConfig.setMinLogLevelLocal(AcsLogLevelDefinition.DELOUSE, "SomeOtherFramework");
    jacorbLogger.finer("jacorb test log #2, shown.");
}
Also used : LogConfig(alma.acs.logging.config.LogConfig) AcsLogger(alma.acs.logging.AcsLogger) Test(org.junit.Test)

Aggregations

AcsLogger (alma.acs.logging.AcsLogger)20 LogConfig (alma.acs.logging.config.LogConfig)3 LogStatsInformation (alma.Logging.ACSLogStatisticsPackage.LogStatsInformation)2 LoggerDoesNotExistEx (alma.Logging.LoggerDoesNotExistEx)2 CleaningDaemonThreadFactory (alma.acs.container.CleaningDaemonThreadFactory)2 ContainerServicesImpl (alma.acs.container.ContainerServicesImpl)2 DAL (com.cosylab.CDB.DAL)2 ThreadFactory (java.util.concurrent.ThreadFactory)2 Test (org.junit.Test)2 POA (org.omg.PortableServer.POA)2 AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)1 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)1 AcsManagerProxy (alma.acs.container.AcsManagerProxy)1 AcsCorba (alma.acs.container.corba.AcsCorba)1 AcsJException (alma.acs.exceptions.AcsJException)1 ClientLogManager (alma.acs.logging.ClientLogManager)1 StdOutConsoleHandler (alma.acs.logging.StdOutConsoleHandler)1 JacORBFilter (alma.acs.logging.adapters.JacORBFilter)1 LogConfigException (alma.acs.logging.config.LogConfigException)1 AcsORBProfilerImplBase (alma.acs.profiling.orb.AcsORBProfilerImplBase)1