Package org.objectweb.util.monolog.api

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


  // IMPLEMENTATION OF THE HandlerFactory INTERFACE //
  //------------------------------------------------//

  public Handler createHandler(String hn, String handlertype) {
    Handler res = (Handler) handlers.get(hn);
    if (res != null) {
      return null;
    }
    res = new BasicHandler(hn, handlertype);
    handlers.put(hn, res);
View Full Code Here


  }
  // IMPLEMENTATION OF THE HandlerFactory INTERFACE //
  //------------------------------------------------//

  public Handler createHandler(String hn, String handlertype) {
    Handler res = (Handler) handlers.get(hn);
    if (res != null) {
      return null;
    }
    res = new FileHandler(handlertype, hn);
    handlers.put(hn, res);
View Full Code Here

  // IMPLEMENTATION OF THE HandlerFactory INTERFACE //
  //------------------------------------------------//

  public Handler createHandler(String hn, String handlertype) {
    Handler res = (Handler) handlers.get(hn);
    if (res != null) {
      return res;
    }
    if (handlertype == null) {
      return null;
    }
    int i =0;
    for(;i<handlerType2className.length
        && !handlerType2className[i][0].equalsIgnoreCase(handlertype); i++);
    String handlerClassName;
    if (i<handlerType2className.length) {
      handlerClassName = handlerType2className[i][1];
    } else {
      handlerClassName = handlertype;
    }
    debug("Instanciating the handler '" + hn + "', class name=" + handlerClassName);
    try {
      res = (Handler) Class.forName(handlerClassName).newInstance();
    } catch (Throwable e) {
      warn("Impossible to instanciate the handler: name=" + hn
        + ", class name=" + handlerClassName +": " + e.getMessage());
            e.printStackTrace(System.err);
      return null;
    }
    res.setAttribute("handlertype", handlertype);
    res.setName(hn);
    handlers.put(hn, res);
    //Calling the listeners
    Iterator iterator = monologFactoryListeners.iterator ();
    while (iterator.hasNext ()) {
       MonologFactoryListener mfl = ((MonologFactoryListener)iterator.next ());
View Full Code Here

  public Handler getHandler(String hn) {
    return (Handler) handlers.get(hn);
  }

  public Handler removeHandler(String hn) {
     Handler res = (Handler) handlers.remove(hn);
    if (res != null) {
      //Calling the listeners
      Iterator iterator = monologFactoryListeners.iterator ();
      while (iterator.hasNext ()) {
         MonologFactoryListener mfl = ((MonologFactoryListener)iterator.next ());
View Full Code Here

  }

  public void testLogInCollocatedHandler() {
    quietRootLogger();
    l = (TopicalLogger) lf.getLogger("test.simple.log");
    Handler hc =
      hf.createHandler("myhandler", "file");
    hc.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME);
    hc.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    hc.setAttribute("activation", lf);
    try {
      l.addHandler(hc);
    }
    catch (Exception e) {
      fail(e.getMessage());
View Full Code Here

  }

  public void testLogInSeveralCollocatedHandler() {
    quietRootLogger();
    l = (TopicalLogger) lf.getLogger("test.simple.log");
    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", hf);

    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", hf);

    try {
      l.addHandler(hc1);
      l.addHandler(hc2);
    }
View Full Code Here

  }

  public void testLogInInheritedHandler() {
    quietRootLogger();
    l = (TopicalLogger) lf.getLogger("test.simple.log");
    Handler hc = hf.createHandler("myhandler", "file");
    hc.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME);
    hc.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    hc.setAttribute("activation", hf);
    try {
      l.addHandler(hc);
    }
    catch (Exception e) {
      fail(e.getMessage());
View Full Code Here

  }

  public void testLogInSeveralInheritedHandler() {
    quietRootLogger();
    l = (TopicalLogger) lf.getLogger("test.simple.log");
    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", hf);

    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", hf);

    try {
      l.addHandler(hc1);
      l = (TopicalLogger) lf.getLogger("test.simple.log.foo");
      l.addHandler(hc2);
View Full Code Here

    quietRootLogger();
    l = (TopicalLogger)
      lf.getLogger("test.intermediate_level.foo");

    Handler hc = hf.createHandler(
      "intermediate_level_handler", "file");
    hc.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME);
    hc.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    hc.setAttribute("activation", hf);
    try {
      l.addHandler(hc);
    }
    catch (Exception e) {
      fail(e.getMessage());
View Full Code Here

   * It removes all handlers of the root logger.
   */
  public void quietRootLogger() {
    TopicalLogger l = (TopicalLogger) lf.getLogger("root");
    Handler[] hcs = l.getHandler();
    Handler hc = hf.createHandler("handlerOfroot", "file");
    hc.setAttribute(Handler.OUTPUT_ATTRIBUTE, "rootLogger.log");
    hc.setAttribute(Handler.PATTERN_ATTRIBUTE, "%m%n");
    hc.setAttribute("activation", lf);
    try {
      l.addHandler(hc);
      for (int i = 0; i < hcs.length; i++) {
        l.removeHandler(hcs[i]);
      }
View Full Code Here

TOP

Related Classes of org.objectweb.util.monolog.api.Handler

Copyright © 2018 www.massapicom. 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.