@Override public String format(Object obj, Object... args) { if (obj instanceof TrackingActivity) { return format((TrackingActivity) obj); } else if (obj instanceof TrackingEvent) { return format((TrackingEvent) obj); } else if (obj instanceof Snapshot) { return format((Snapshot) obj); } else if (obj instanceof Property) { return format((Property) obj); } else { StringBuilder jsonString = new StringBuilder(1024); jsonString.append(START_JSON); jsonString.append(JSON_TIME_USEC_LABEL).append(ATTR_SEP).append(Useconds.CURRENT.get()).append(ATTR_JSON); String msgText = StringEscapeUtils.escapeJson(Utils.format(Utils.toString(obj), args)); // escape double // quote chars jsonString.append(JSON_MSG_TEXT_LABEL).append(ATTR_SEP); Utils.quote(msgText, jsonString); jsonString.append(END_JSON); return jsonString.toString(); } }
String itemJSON; if (item instanceof TrackingEvent) { itemJSON = format((TrackingEvent) item); } else if (item instanceof TrackingActivity) { itemJSON = format((TrackingActivity) item); } else if (item instanceof Snapshot) { itemJSON = format((Snapshot) item); } else if (item instanceof Property) { itemJSON = format((Property) item); } else {
@Override public String format(Snapshot snapshot) { if (level == 9) { return super.format(snapshot);
@Override public String format(TrackingActivity activity) { if (level == 9) { return super.format(activity);
@Override public String format(Property prop) { if (level == 9) { return super.format(prop); } if (prop == null || prop.isTransient()) { return EMPTY_STR; } Object value = prop.getValue(); if (isSpecialSuppress(value)) { return EMPTY_STR; } StringBuilder jsonString = new StringBuilder(256); jsonString.append(Utils.quote(StringEscapeUtils.escapeJson(getKeyStr(prop.getKey())))).append(ATTR_SEP); if (isNoNeedToQuote(value)) { jsonString.append(propValueToString(value)); } else { Utils.quote(StringEscapeUtils.escapeJson(propValueToString(value)), jsonString); } return jsonString.toString(); }
@Override public String format(TrackingEvent event) { if (level == 9) { return super.format(event);