Package org.objectweb.util.monolog.api

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


        }
  }


    public void addTopicToLogger(String topic, String loggerName) {
        TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
        try {
            l.addTopic(topic);
        } catch (Exception e) {
            return;
        }
    }
View Full Code Here


            return;
        }
    }

    public void removeTopicFromLogger(String topic, String loggerName) {
        TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
        try {
            l.removeTopic(topic);
        } catch (Exception e) {
            return;
        }
    }
View Full Code Here

        if (temp == null || !temp.equalsIgnoreCase(LOGGER_FIELD)) {
            throw new Exception(
                    "This key is not a Logger property:" + key);
        }

        TopicalLogger logger = null;
        temp = DottedStringTools.getEnd(key);
        String last = DottedStringTools.getLast(temp);
        if (last.equalsIgnoreCase(LEVEL_FIELD)) {
            // Assigns the level of the logger
            logger = (TopicalLogger)
                    mf.getLogger(DottedStringTools.getBegin(temp));
            String levelName = prop.getProperty(key).trim();
            Level l = mf.getLevel(levelName);
            if (l == null) {
                l = parseLevelProp(prop, LEVEL_FIELD + DOT + levelName, mf);
            }
            if (debug) {
                debug("set level to " + l.getName() + " to the logger " + logger.getName());
            }
            logger.setLevel(l);
        } else if (ADDITIVITY_FIELD.equalsIgnoreCase(last)
                || USE_PARENT_FIELD.equalsIgnoreCase(last)) {
            logger = (TopicalLogger)
                    mf.getLogger(DottedStringTools.getBegin(temp));
            boolean a = Boolean.getBoolean(prop.getProperty(key).trim());
            if (debug) {
                debug("set additivity to " + a + " to the logger " + logger.getName());
            }
            logger.setAdditivity(a);
        } else if (CLEAN_HANDLERS_FIELD.equalsIgnoreCase(last)) {
            //Already managed iin the read method
        } else if (HANDLER_FIELD.equalsIgnoreCase(last)) {
            String value = prop.getProperty(key).trim();
            StringTokenizer st = new StringTokenizer(value, ", ;:", false);
            logger = (TopicalLogger)
          mf.getLogger(DottedStringTools.getBegin(temp));
            cleanOldHandler(logger);
            while(st.hasMoreTokens()) {
                String hn = st.nextToken();
                Handler h = mf.getHandler(hn);
                if (h == null) {
                    h = parseHandlerProp(prop, HANDLER_FIELD + DOT + value
                            + DOT + HANDLER_TYPE_ATTRIBUTE, mf);
                }
                if (debug) {
                    debug("add handler " + h.getName() + " to the logger " + logger.getName());
                }
                logger.addHandler(h);
            }
        } else if (TOPIC_FIELD.equalsIgnoreCase(last)) {
            logger = (TopicalLogger)
              mf.getLogger(DottedStringTools.getBegin(temp));
            String value = prop.getProperty(key).trim();
            StringTokenizer st = new StringTokenizer(value, ", ;:", false);
            cleanOldHandler(logger);
            while(st.hasMoreTokens()) {
                String topic = st.nextToken();
                if (debug) {
                    debug("add topic " + topic + " to the logger " + logger.getName());
                }
                logger.addTopic(topic);
            }
        } else { //old declaration
            temp = DottedStringTools.getBegin(temp); // remove the number
            last = DottedStringTools.getLast(temp); // attribute name
            temp = DottedStringTools.getBegin(temp); // logger name
            logger = (TopicalLogger) mf.getLogger(temp);
            if (last.equalsIgnoreCase(HANDLER_FIELD)) {
                // Assign an handler to a logger
                String value = prop.getProperty(key).trim();
                Handler h = mf.getHandler(value);
                if (h == null) {
                    h = parseHandlerProp(prop, HANDLER_FIELD + DOT + value
                            + DOT + HANDLER_TYPE_ATTRIBUTE, mf);
                }
                cleanOldHandler(logger);
                if (debug) {
                    debug("add handler " + h.getName() + " to the logger " + logger.getName());
                }
                logger.addHandler(h);
            } else if (last.equalsIgnoreCase(TOPIC_FIELD)) {
                // Assign a topic to a logger
                String topic = prop.getProperty(key).trim();
                if (debug) {
                    debug("add topic " + topic + " to the logger " + logger.getName());
                }
                logger.addTopic(topic);
            } else {
                throw new Exception(
                        "Unknown definition" + key + " " + prop.getProperty(key));
            }
        }
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]);
      }
    }
    catch (Exception e) {
      fail("error" + e.getMessage());
    }
View Full Code Here

TOP

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

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.