/** * Generate the log header * * @param context the current Context - safe to pass in <code>null</code> * @param action string describing the action * @param extrainfo string with extra information, like parameters * @return the filled out log header */ public static String getHeader(Context context, String action, String extrainfo) { String email = "anonymous"; String contextExtraInfo; if (context != null) { EPerson e = context.getCurrentUser(); if (e != null) { email = e.getEmail(); } contextExtraInfo = context.getExtraLogInfo(); } else { contextExtraInfo = "no_context"; } StringBuilder result = new StringBuilder(); // Escape everthing but the extra context info because for some crazy reason two fields // are generated inside this entry one for the session id, and another for the ip // address. Everything else should be escaped. result.append(escapeLogField(email)).append(":").append(contextExtraInfo).append(":") .append(escapeLogField(action)).append(":").append(escapeLogField(extrainfo)); return result.toString(); }