@Override public String toString() { OpType type = getType(); String res = getResource(); UsecTimestamp sTime = getStartTime(); UsecTimestamp eTime = getEndTime(); StringBuilder str = new StringBuilder(); str.append(getClass().getSimpleName()).append("{").append("Name:").append(getName()).append(",").append("Type:") .append(type == null ? "null" : type.toString()).append(",").append("Correlator:") .append(getCorrelator()).append(",").append("Location:").append(getLocation()).append(",") .append("Resource:").append(res == null ? "null" : res).append(",").append("User:").append(getUser()) .append(",").append("SnapCount=").append(getSnapshotCount()).append(",").append("PropCount=") .append(getPropertyCount()).append(",").append("CompCode:").append(getCompCode()).append(",") .append("ReasonCode:").append(getReasonCode()).append(",").append("PID:").append(getPID()).append(",") .append("TID:").append(getTID()).append(",").append("ElapsedUsec:").append(getElapsedTimeUsec()) .append(",").append("WaitUsec:").append(getWaitTimeUsec()).append(",").append("WallUsec:") .append(getWallTimeUsec()).append(",").append("StartTime:[").append(sTime.toString()).append("],") .append("EndTime:[").append(eTime.toString()).append("],").append("Exception:") .append(getExceptionString()).append("}"); return str.toString(); }
msg.append("snap-count: '").append(event.getOperation().getSnapshotCount()).append("'"); if (event.getOperation().getResource() != null) { msg.append(separator); msg.append("resource: '").append(event.getOperation().getResource()).append("'");
Utils.quote(escaped, jsonString).append(ATTR_JSON); if (!Utils.isEmpty(event.getOperation().getResource())) { String escaped = StringEscapeUtils.escapeJson(event.getOperation().getResource()); // escape double quote
/** * Extract syslog name/value pairs if available in within the message * * @param event * syslog event message * @param tevent * tracking event * @return map of parsed out event attributes (name=value pairs) */ protected Map<String, Object> extractVariables(SyslogServerEventIF event, TrackingEvent tevent) { Map<String, Object> attr = parseVariables(event.getMessage()); if (attr != null && attr.size() > 0) { extractSpecialKeys(attr, tevent); PropertySnapshot snap = new PropertySnapshot(SNAPSHOT_CAT_SYSLOG_VARS, tevent.getOperation().getResource(), tevent.getSeverity()); snap.addAll(attr); tevent.getOperation().addSnapshot(snap); } return attr; }
@Override public void event(Object arg0, SyslogServerIF config, SocketAddress arg2, SyslogServerEventIF event) { Date date = (event.getDate() == null ? new Date() : event.getDate()); String facility = getFacilityString(event.getFacility()); OpLevel level = getOpLevel(event.getLevel()); TrackingEvent tevent = logger.newEvent(facility, event.getMessage()); tevent.getOperation().setSeverity(level); tevent.getOperation().addProperty(new Property("facility", facility)); tevent.getOperation().addProperty(new Property("hostname", event.getHost())); tevent.getOperation().addProperty(new Property("level", event.getLevel(), ValueTypes.VALUE_TYPE_ID)); if (arg2 instanceof InetSocketAddress) { InetSocketAddress from = (InetSocketAddress) arg2; tevent.getOperation().addProperty(new Property("hostaddr", from.getAddress().getHostAddress())); tevent.setLocation(from.getAddress().getHostAddress()); } else { tevent.setLocation(event.getHost()); } tevent.setCharset(config.getConfig().getCharSet()); if (event instanceof StructuredSyslogServerEvent) { processRFC5424(facility, (StructuredSyslogServerEvent) event, tevent); } else { processRFC3164(facility, event, tevent); } // extract name=value pairs if available extractVariables(event, tevent); String locationKey = tevent.getLocation() + "/" + tevent.getOperation().getResource(); tevent.stop(date.getTime() * 1000, getUsecSinceLastEvent(locationKey)); logger.tnt(tevent); }