Examples of TopicalLogger


Examples of org.objectweb.util.monolog.api.TopicalLogger

  public void testProgConfig() throws Exception {
    String className = System.getProperty(Monolog.MONOLOG_CLASS_NAME, Monolog.JDK_WRAPPER_CLASS_NAME);
    Monolog.monologFactory = Monolog.getDefaultMonologFactory();
    MonologFactory mf = Monolog.instanciateMonologFactory(className);
    TopicalLogger l = (TopicalLogger) mf.getLogger(
      "org.objectweb.util.monolog.TestHandlerLevel.testA");
    l.setIntLevel(BasicLevel.DEBUG);
    l.setAdditivity(false);

    Handler h1 = mf.createHandler("h1", "console");
    h1.setAttribute(Handler.OUTPUT_ATTRIBUTE, "System.out");
    h1.setAttribute(Handler.LEVEL_ATTRIBUTE, "WARN");
    h1.setAttribute(Handler.PATTERN_ATTRIBUTE, "first handler: %m");
    h1.setAttribute("activation",mf);
    l.addHandler(h1);

    Handler h2 = mf.createHandler("h2", "console");
    h2.setAttribute(Handler.OUTPUT_ATTRIBUTE, "System.out");
    h2.setAttribute(Handler.PATTERN_ATTRIBUTE, "second handler: %m");
    h2.setAttribute("activation",mf);
    l.addHandler(h2);
    l = (TopicalLogger) mf.getLogger(
      "org.objectweb.util.monolog.TestHandlerLevel.testA.l1");
    l.log(BasicLevel.DEBUG, "(" + className + ") this message must be printed only one time");
  }
View Full Code Here

Examples of org.objectweb.util.monolog.api.TopicalLogger

    }
  }

  public void testSimple() {
    quietRootLogger();
    TopicalLogger l = (TopicalLogger)
      lf.getLogger("test.configurability.simple");
    Handler hc =
      hf.createHandler("myhandler_configurability", "file");
    hc.setAttribute(Handler.OUTPUT_ATTRIBUTE, "test.log");
    hc.setAttribute(Handler.PATTERN_ATTRIBUTE, "%m%n");
    hc.setAttribute("activation", lf);
    try {
      l.addHandler(hc);
    }
    catch (Exception e) {
      fail(e.getMessage());
    }
    l.setIntLevel(BasicLevel.DEBUG);
    String str = "configurability mode " + mode + " " + useClassPath;
    l.log(BasicLevel.DEBUG, str);
    String[] found = getLastLines("test.log", 1);
    assertNotNull("TestHelper error", found);
    assertNotNull("TestHelper error", found[0]);
    assertTrue("no log in collocated Handler", found[0].endsWith(str));
  }
View Full Code Here

Examples of org.objectweb.util.monolog.api.TopicalLogger

  // ------ TEST METHODS ------ //
  //----------------------------//

  public void testA() {
    quietRootLogger();
    TopicalLogger l1 = (TopicalLogger) lf.getLogger("test.additivity");
    TopicalLogger l2 = (TopicalLogger) lf.getLogger("test.additivity.foo");
    Handler hc1 = hf.createHandler("myhandler", "file");
    hc1.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME + '1');
    hc1.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    hc1.setAttribute("activation", lf);
    Handler hc2 = hf.createHandler("myhandler2", "file");
    hc2.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME + '2');
    hc2.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    hc2.setAttribute("activation", lf);
    try {
      l1.addHandler(hc1);
      l2.addHandler(hc2);
    }
    catch (Exception e) {
      fail(e.getMessage());
    }
    l2.setAdditivity(false);
    l2.setIntLevel(BasicLevel.DEBUG);
    l2.log(BasicLevel.DEBUG, "simple additivity");
    // The log message must be found in the file 2
    String[] found2 = getLastLines(LOG_FILE_NAME + '2', 1);
    assertNotNull("TestHelper error", found2);
    assertNotNull("TestHelper error", found2[0]);
    assertTrue("A.1",
      found2[0].endsWith("simple additivity"));

    // The log message must NOT be found in the file 1
    String[] found1 = getLastLines(LOG_FILE_NAME + '1', 1);
    if (found1 !=null && found1.length>0 && found1[0] !=null
      && found1[0].endsWith("simple additivity")) {
      fail("A.2");
    }

    l2 = (TopicalLogger) lf.getLogger("test.additivity.foo.bar");
    l2.log(BasicLevel.DEBUG, "simple additivity2");
    // The log message must be found in the file 2
    found2 = getLastLines(LOG_FILE_NAME + '2', 1);
    assertNotNull("TestHelper error", found2);
    assertNotNull("TestHelper error", found2[0]);
    assertTrue("A.3",
View Full Code Here

Examples of org.objectweb.util.monolog.api.TopicalLogger

      fail("A.4");
    }
  }
  public void testB() {
    quietRootLogger();
    TopicalLogger l1 = (TopicalLogger) lf.getLogger("test.additivity");
    TopicalLogger l2 = (TopicalLogger) lf.getLogger("test.additivity.foo");
    Handler hc1 =
      hf.createHandler("myhandler", "file");
    hc1.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME + '1');
    hc1.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    hc1.setAttribute("activation", lf);
    Handler hc2 = hf.createHandler("myhandler2", "file");
    hc2.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME + '2');
    hc2.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    hc2.setAttribute("activation", lf);
    try {
      l1.addHandler(hc1);
      l2.addHandler(hc2);
    }
    catch (Exception e) {
      fail(e.getMessage());
    }
    l2.setAdditivity(false);
    l2.log(BasicLevel.DEBUG, "simple additivity B");
    // The log message must be found in the file 2
    String[] found2 = getLastLines(LOG_FILE_NAME + '2', 1);
    assertNotNull("TestHelper error", found2);
    assertNotNull("TestHelper error", found2[0]);
    assertTrue("B.1",
      found2[0].endsWith("simple additivity B"));

    // The log message must NOT be found in the file 1
    String[] found1 = getLastLines(LOG_FILE_NAME + '1', 1);
    if (found1 !=null && found1.length>0 && found1[0] !=null
      && found1[0].endsWith("simple additivity B")) {
      fail("B.2");
    }

    l2 = (TopicalLogger) lf.getLogger("test.additivity.foo.bar");
    l2.setIntLevel(BasicLevel.DEBUG);
    l2.log(BasicLevel.DEBUG, "simple additivity B 2");
    // The log message must be found in the file 2
    found2 = getLastLines(LOG_FILE_NAME + '2', 1);
    assertNotNull("TestHelper error", found2);
    assertNotNull("TestHelper error", found2[0]);
    assertTrue("B.3",
View Full Code Here

Examples of org.objectweb.util.monolog.api.TopicalLogger

      h.setAttribute("activation", hf);


      //------ Logger ------//

      TopicalLogger l = null;
      //logger.root.level WARN
      // or
      //logger..level WARN
      l = (TopicalLogger) lf.getLogger("");
      l.setIntLevel(BasicLevel.WARN);

      //nothing required
      l = (TopicalLogger) lf.getLogger("org.foo.bar");

      // logger.org.level FATAL
      l = (TopicalLogger) lf.getLogger("org");
      l.setIntLevel(BasicLevel.FATAL);

      // logger.org.foo.bar2.level INFO
      l = (TopicalLogger) lf.getLogger("org.foo.bar2");
      l.setIntLevel(BasicLevel.INFO);

      // logger.org.foo.bar3.topic.0 fr.inria.sardes3
      // logger.org.foo.bar3.topic.1 fr.inrialpes.sardes3
      l = (TopicalLogger) lf.getLogger("org.foo.bar3");
      l.addTopic("fr.inria.sardes3");
      l.addTopic("fr.inrialpes.sardes3");

      // logger.org.foo.bar4.level ERROR
      // logger.org.foo.bar4.topic.0 fr.inria.sardes4
      // logger.org.foo.bar4.topic.1 fr.inrialpes.sardes4
      l = (TopicalLogger) lf.getLogger("org.foo.bar4");
      l.setIntLevel(BasicLevel.ERROR);
      l.addTopic("fr.inria.sardes4");
      l.addTopic("fr.inrialpes.sardes4");

      //logger.org.foo.bar5.handler.0 Handler_file
      l = (TopicalLogger) lf.getLogger("org.foo.bar5");
      l.addHandler( hf.getHandler("Handler_file"));

      //logger.org.foo.bar6.handler.0 Handler_file
      l = (TopicalLogger) lf.getLogger("org.foo.bar6");
      l.addHandler( hf.getHandler("Handler_file"));
      l.addHandler( hf.getHandler("Handler.rolling.file"));
    }
    catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
View Full Code Here

Examples of org.objectweb.util.monolog.api.TopicalLogger

      "2", h.getAttribute(Handler.FILE_NUMBER_ATTRIBUTE));
    assertEquals("handler: test.load.myhandler2: bad max size",
      "20", h.getAttribute(Handler.MAX_SIZE_ATTRIBUTE));

    //------ Logger ------//
    TopicalLogger l = null;
    l = (TopicalLogger) lf.getLogger("test.load.bar");
    assertEquals("logger: test.load.bar: bad level",
      BasicLevel.DEBUG, l.getCurrentIntLevel());

    l = (TopicalLogger) lf.getLogger("test.load.foo");
    assertEquals("logger: test.load.foo: bad level",
      BasicLevel.DEBUG + 1, l.getCurrentIntLevel());

    l = (TopicalLogger) lf.getLogger("test.load.foo3");
    Handler[] hs = l.getHandler();
    assertNotNull("logger: test.load.foo3: handler list is null", hs);
    assertEquals("logger: test.load.foo3: handler list is empty",
      1, hs.length);
    assertEquals("logger: test.load.foo3: bad handler",
      hf.getHandler("myhandler1"), hs[0]);

    l = (TopicalLogger) lf.getLogger("test.load.foo4");
    hs = l.getHandler();
    assertNotNull("logger: test.load.foo4: handler list is null", hs);
    assertEquals("logger: test.load.foo4: handler list is empty",
      2, hs.length);
    assertNotNull("logger: test.load.foo4: handler element 0 is null", hs[0]);
    assertNotNull("logger: test.load.foo4: handler element 1 is null", hs[1]);
    if (!hs[0].equals(hf.getHandler("test.load.myhandler2"))
        && !hs[1].equals(hf.getHandler("test.load.myhandler2"))) {
      fail("logger: test.load.foo4: 'test.load.myhandler2' handler not found");
    }
    if (!hs[0].equals(hf.getHandler("test.load.myhandler3"))
        && !hs[1].equals(hf.getHandler("test.load.myhandler3"))) {
      fail("logger: test.load.foo4: 'test.load.myhandler3' handler not found");
    }

    l = (TopicalLogger) lf.getLogger("test.load.foo2");
    String[] ts = l.getTopic();
    assertNotNull("logger: test.load.foo2: topic list is null", ts);
    assertEquals("logger: test.load.foo2: bad topic list size",
      3, ts.length);
    assertNotNull("logger: test.load.foo2: topic element 0 is null", ts[0]);
    assertNotNull("logger: test.load.foo2: topic element 1 is null", ts[1]);
View Full Code Here

Examples of org.objectweb.util.monolog.api.TopicalLogger

            throws RemoteException {
        Handler h = mf.getHandler(handlername);
        if (h == null) {
            throw new RemoteException("No handler '" + handlername + "' found.");
        }
        TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
        try {
            l.addHandler(h);
        } catch (Exception e) {
            throw new RemoteException(e.getMessage());
        }
    }
View Full Code Here

Examples of org.objectweb.util.monolog.api.TopicalLogger

            throws RemoteException {
        Handler h = mf.getHandler(handlerName);
        if (h == null) {
            return;
        }
        TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
        try {
            l.removeHandler(h);
        } catch (Exception e) {
            throw new RemoteException(e.getMessage());
        }
    }
View Full Code Here

Examples of org.objectweb.util.monolog.api.TopicalLogger

            throw new RemoteException(e.getMessage());
        }
    }

    public void removeAllHandlersFromLogger(String loggerName) throws RemoteException {
        TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
        try {
            l.removeAllHandlers();
        } catch (Exception e) {
            throw new RemoteException(e.getMessage());
        }
    }
View Full Code Here

Examples of org.objectweb.util.monolog.api.TopicalLogger

            throw new RemoteException(e.getMessage());
        }
    }

    public void setAdditivity(boolean a, String loggerName) throws RemoteException {
        TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
        l.setAdditivity(a);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.