/**
 * Licensed to Inspektr under one or more contributor license
 * agreements. See the NOTICE file distributed with this work
 * for additional information regarding copyright ownership.
 * Inspektr licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a
 * copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package com.github.inspektr.audit.support;

import com.github.inspektr.audit.AuditActionContext;
import com.github.inspektr.audit.AuditTrailManager;

/**
 * Abstract AuditTrailManager that turns the AuditActionContext into a printable String.
 *
 * @author Scott Battaglia
 * @version $Revision$ $Date$
 * @since 1.0.1
 */
public abstract class AbstractStringAuditTrailManager implements AuditTrailManager {

    protected String toString(final AuditActionContext auditActionContext) {
        final StringBuilder builder = new StringBuilder();
        builder.append("Audit trail record BEGIN\n");
        builder.append("=============================================================\n");
        builder.append("WHO: ");
        builder.append(auditActionContext.getPrincipal());
        builder.append("\n");
        builder.append("WHAT: ");
        builder.append(auditActionContext.getResourceOperatedUpon());
        builder.append("\n");
        builder.append("ACTION: ");
        builder.append(auditActionContext.getActionPerformed());
        builder.append("\n");
        builder.append("APPLICATION: ");
        builder.append(auditActionContext.getApplicationCode());
        builder.append("\n");
        builder.append("WHEN: ");
        builder.append(auditActionContext.getWhenActionWasPerformed());
        builder.append("\n");
        builder.append("CLIENT IP ADDRESS: ");
        builder.append(auditActionContext.getClientIpAddress());
        builder.append("\n");
        builder.append("SERVER IP ADDRESS: ");
        builder.append(auditActionContext.getServerIpAddress());
        builder.append("\n");
        builder.append("=============================================================");
        builder.append("\n\n");

        return builder.toString();
    }
}

@@ -1188,27 +1188,828 @@
     
-protected String to
+/** Use multi-line output by default **/%0A    private Boolean useSingleLine = new Boolean(%22False%22);%0A%0A    /** Separator for single line log entries */%0A    private String entrySeparator = %22,%22;%0A%0A    public String getEntrySeparator() %7B%0A            return this.entrySeparator;%0A    %7D%0A%0A    public void setEntrySeparator(final String separator) %7B%0A        this.entrySeparator = separator;%0A    %7D%0A%0A    public void setUseSingleLine(final Boolean useSingleLine) %7B%0A        this.useSingleLine = useSingleLine;%0A    %7D%0A%0A    protected String toString(final AuditActionContext auditActionContext) %7B%0A        if(this.useSingleLine) %7B%0A            return getSingleLineAuditString(auditActionContext);%0A        %7D else %7B%0A            return getMultiLineAuditString(auditActionContext);%0A        %7D%0A    %7D%0A        %0A    protected String getMultiLineAudit
 Stri
@@ -3368,10 +3368,936 @@
 ;%0A    %7D%0A
-%7D
 %0A
+    protected String getSingleLineAuditString(final AuditActionContext auditActionContext) %7B%0A        final StringBuilder builder = new StringBuilder();%0A        builder.append(auditActionContext.getWhenActionWasPerformed());%0A        builder.append(getEntrySeparator());%0A        builder.append(auditActionContext.getApplicationCode());%0A        builder.append(getEntrySeparator());%0A        builder.append(auditActionContext.getResourceOperatedUpon());%0A        builder.append(getEntrySeparator());%0A        builder.append(auditActionContext.getActionPerformed());%0A        builder.append(getEntrySeparator());%0A        builder.append(auditActionContext.getPrincipal());%0A        builder.append(getEntrySeparator());%0A        builder.append(auditActionContext.getClientIpAddress());%0A        builder.append(getEntrySeparator());%0A        builder.append(auditActionContext.getServerIpAddress());%0A%0A        return builder.toString();%0A    %7D%0A%0A%7D

Add support for single-line audit messages