Package org.wso2.carbon.logging.service.data

Examples of org.wso2.carbon.logging.service.data.LogMessage


      throws LogViewerException {
    List<LogMessage> resultList = new ArrayList<LogMessage>();
    LogMessage[] allLogs = getHeadLogs(logIndex,
        getTenantLogMessages(logFile, maxLines, start - 1, end, tenantId, serviceName));
    for (int i = 0; i < allLogs.length; i++) {
      LogMessage tempLog = allLogs[i];
      if (type.equals(tempLog.getType().trim())) {
        resultList.add(tempLog);
      }
    }
    if (resultList.size() > 0) {
      return resultList.toArray(new LogMessage[resultList.size()]);
View Full Code Here


      throws LogViewerException {
    List<LogMessage> resultList = new ArrayList<LogMessage>();
    LogMessage[] allLogs = getHeadLogs(logIndex,
        getTenantLogMessages(logFile, maxLines, start - 1, end, tenantId, serviceName));
    for (int i = 0; i < allLogs.length; i++) {
      LogMessage tempLog = allLogs[i];
      String message = tempLog.getLogMessage();
      if (message != null && message.toLowerCase().indexOf(keyword.toLowerCase()) > -1) {
        resultList.add(tempLog);
      }
    }
    if (resultList.size() > 0) {
View Full Code Here

    }
    return line.replace(tenantPattern.trim(), "");
  }

  private LogMessage getLogMessageForType(String log) {
    LogMessage logMessage = null;
    if (isTraceHeader(log)) {
      logMessage = new LogMessage(log, LoggingConstants.RegexPatterns.LOG_TRACE);
    } else if (isDebugHeader(log)) {
      logMessage = new LogMessage(log, LoggingConstants.RegexPatterns.LOG_DEBUG);
    } else if (isInfoHeader(log)) {
      logMessage = new LogMessage(log, LoggingConstants.RegexPatterns.LOG_INFO);
    } else if (isWarnHeader(log)) {
      logMessage = new LogMessage(log, LoggingConstants.RegexPatterns.LOG_WARN);
    } else if (isErrorHeader(log)) {
      logMessage = new LogMessage(log, LoggingConstants.RegexPatterns.LOG_ERROR);
    } else if (isFatalHeader(log)) {
      logMessage = new LogMessage(log, LoggingConstants.RegexPatterns.LOG_FATAL);
    }
    return logMessage;
  }
View Full Code Here

          // it waits for valid log header,
          // and add the multiple log lines to the specific log header
          // (since we are reading from bottom up
          // those multiple lines belongs to the next valid log
          // header.
          LogMessage logMessage = null;
          if (isErrorHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            // when there are log messages with multiple lines one
            // after the other
            // next line is also considered as a error line
            errorLine = line;
          } else if (isFatalHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            errorLine = line;
          } else if (isTraceHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            errorLine = line;
          } else if (isInfoHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            errorLine = line;
          } else if (isWarnHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            errorLine = line;
          } else if (isDebugHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            errorLine = line;
          } else if (!isLogHeader(line)) {
            // if a log line has no valid log header that log line
            // is considered as a error line.
            errorLine = errorLine + line + LoggingConstants.RegexPatterns.NEW_LINE;
          } else if (isLogHeader(line)) {
            if (!errorLine.equals("")) {
              errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
              logMessage = getLogMessageForType(errorLine);
              if (logMessage != null) {
                logsList.add(logMessage);
              }
              errorLine = "";
            }
            logMessage = getLogMessageForType(line);
            if (logMessage != null) {
              logsList.add(logMessage);
            }
          } else {
            log.warn("The log message  " + line + " is ignored.");
          }
        }
        index++;
      }
      if (!errorLine.equals("")) {
        LogMessage logMessage = getLogMessageForType(errorLine);
        if (logMessage != null) {
          logsList.add(logMessage);
        } else {
          log.warn("The log message " + errorLine + " is ignored.");
        }
View Full Code Here

        if (appender instanceof MemoryAppender) {
            MemoryAppender memoryAppender = (MemoryAppender) appender;
            if ((memoryAppender.getCircularQueue() != null)) {
                definedamount = memoryAppender.getBufferSize();
            } else {
                return new LogMessage[]{new LogMessage("--- No log entries found. " +
                        "You may try increasing the log level ---", "")};
            }

            Object[] objects;
            if (definedamount < 1) {
                objects = memoryAppender.getCircularQueue().getObjects(DEFAULT_NO_OF_LOGS);
            } else {
                objects = memoryAppender.getCircularQueue().getObjects(definedamount);
            }
            if ((memoryAppender.getCircularQueue().getObjects(definedamount) == null) ||
                    (memoryAppender.getCircularQueue().getObjects(definedamount).length == 0)) {
                return new LogMessage[]{new LogMessage("--- No log entries found. " +
                        "You may try increasing the log level ---", "")};
            }
            LogMessage[] logMessages = new LogMessage[objects.length];

            Layout layout = memoryAppender.getLayout();

            for (int i = 0; i < objects.length; i++) {
                LoggingEvent logEvt = (LoggingEvent) objects[i];
                if (logEvt != null) {
                    Level level = logEvt.getLevel();
                    logMessages[i] = new LogMessage(layout.format(logEvt), level.toString());
                }
            }
            return logMessages;
        } else {
            return new LogMessage[]{new LogMessage("The log must be configured to use the org.wso2.carbon." +
                    "logging.appenders.MemoryAppender to view entries on the admin console", "")};
        }
    }
View Full Code Here

        }

        public void run() {
            try {
                MessageContext msgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
                Event<MessageContext> event = new Event(msgCtx);
                subscriptions = subscriptionManager.getMatchingSubscriptions(event);
            } catch (EventException e) {
                handleException("Matching subscriptions fetching error", e);
            }
View Full Code Here

     * @throws EventException event
     */
    private void processGetStatusRequest(MessageContext mc,
                                         ResponseMessageBuilder messageBuilder)
            throws AxisFault, EventException {
        Subscription subscription =
                SubscriptionMessageBuilder.createGetStatusMessage(mc);
        if (log.isDebugEnabled()) {
            log.debug("GetStatus request recived for SynapseSubscription ID : " +
                    subscription.getId());
        }
        subscription = subscriptionManager.getSubscription(subscription.getId());
        if (subscription != null) {
            if (log.isDebugEnabled()) {
                log.debug("Sending GetStatus responce for SynapseSubscription ID : " +
                        subscription.getId());
            }
            //send the responce
            SOAPEnvelope soapEnvelope = messageBuilder.genGetStatusResponse(subscription);
            dispatchResponse(soapEnvelope, EventingConstants.WSE_GET_STATUS_RESPONSE,
                    mc, false);
View Full Code Here

            // Adding static subscriptions
            List<Subscription> staticSubscriptionList =
                    eventSource.getSubscriptionManager().getStaticSubscriptions();
            for (Iterator<Subscription> iterator = staticSubscriptionList.iterator();
                 iterator.hasNext();) {
                Subscription staticSubscription = iterator.next();
                OMElement staticSubElem =
                        fac.createOMElement("subscription", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                staticSubElem.addAttribute(
                        fac.createOMAttribute("id", nullNS, staticSubscription.getId()));
                OMElement filterElem =
                        fac.createOMElement("filter", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                filterElem.addAttribute(fac.createOMAttribute("source", nullNS,
                        (String) staticSubscription.getFilterValue()));
                filterElem.addAttribute(fac.createOMAttribute("dialect", nullNS,
                        (String) staticSubscription.getFilterDialect()));
                staticSubElem.addChild(filterElem);
                OMElement endpointElem =
                        fac.createOMElement("endpoint", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                OMElement addressElem =
                        fac.createOMElement("address", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                addressElem.addAttribute(
                        fac.createOMAttribute("uri", nullNS, staticSubscription.getEndpointUrl()));
                endpointElem.addChild(addressElem);
                staticSubElem.addChild(endpointElem);
                if (staticSubscription.getExpires() != null) {
                    OMElement expiresElem =
                            fac.createOMElement("expires", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                    fac.createOMText(expiresElem,
                            ConverterUtil.convertToString(staticSubscription.getExpires()));
                    staticSubElem.addChild(expiresElem);
                }
                evenSourceElem.addChild(staticSubElem);
            }
View Full Code Here


    public SynapseSubscription() {
        this.setId(UIDGenerator.generateURNString());
        this.setDeliveryMode(EventingConstants.WSE_DEFAULT_DELIVERY_MODE);
        SubscriptionData subscriptionData = new SubscriptionData();
        subscriptionData.setProperty(SynapseEventingConstants.STATIC_ENTRY, "false");
        this.setSubscriptionData(subscriptionData);
    }
View Full Code Here

                    .getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "class"));
            if (clazz != null) {
                String className = clazz.getAttributeValue();
                try {
                    Class subscriptionManagerClass = Class.forName(className);
                    SubscriptionManager manager =
                            (SubscriptionManager) subscriptionManagerClass.newInstance();
                    Iterator itr = subscriptionManagerElem.getChildrenWithName(PROPERTIES_QNAME);
                    while (itr.hasNext()) {
                        OMElement propElem = (OMElement) itr.next();
                        String propName =
                                propElem.getAttribute(new QName("name")).getAttributeValue();
                        String propValue =
                                propElem.getAttribute(new QName("value")).getAttributeValue();
                        if (propName != null && !"".equals(propName.trim()) &&
                                propValue != null && !"".equals(propValue.trim())) {

                            propName = propName.trim();
                            propValue = propValue.trim();

                            PasswordManager passwordManager =
                                    PasswordManager.getInstance();
                            String key = eventSource.getName() + "." + propName;

                            if (passwordManager.isInitialized()
                                    && passwordManager.isTokenProtected(key)) {
                                eventSource.putConfigurationProperty(propName, propValue);
                                propValue = passwordManager.resolve(propValue);
                            }

                            manager.addProperty(propName, propValue);
                        }
                    }
                    eventSource.setSubscriptionManager(manager);
                    eventSource.getSubscriptionManager()
                            .init(); // Initialise before doing further processing, required for static subscriptions
View Full Code Here

TOP

Related Classes of org.wso2.carbon.logging.service.data.LogMessage

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.