ELFFormatter.java revision 8af80418ba1ec431c8027fa9668e5678658d3611
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ELFFormatter.java,v 1.10 2009/10/20 20:47:04 bigfatrat Exp $
*
*/
/*
* Portions Copyrighted [2011] [ForgeRock AS]
*/
/**
* This Formatter is the custom defined Formatter for DSAME which formats the
* logRecord according to ELF. For details of ELF specification pls refer
* www.w3.org/TR/WD-logfile.html. This Formatter will put the version number and
* Fields as the first 2 lines and the data corresponding to each field follows.
* If a field is not selected a "-" is put.
*/
public class ELFFormatter extends Formatter {
// private IGenerator fieldGenerator = new MACGenerator();
/**
* returns a ELF Formatter
*/
public ELFFormatter() {
try {
} catch (ClassNotFoundException cnfe) {
"not found", cnfe);
} catch (InstantiationException ie) {
"not be Instantiated", ie);
} catch (IllegalAccessException iae) {
"not be Instantiated", iae);
}
}
/**
* Format the given record as per ELF and return a formatted string. <p>
* For ELF Specifications refer <LI> www.w3.org/TR/WD-logfile.html</LI>
*
* @param logRecord the log record to be formatted.
* @return formatted string.
*/
if ((LogManagerUtil.isAMLoggingMode()) &&
.getLogInfoMap();
}
try {
if(secureTimestampGenerator != null) {
} else {
strTime ="";
}
boolean escapeDone = false;
escapeDone = true;
break;
}
}
if (!escapeDone) {
}
if (logInfoTable != null) {
(selectedFields != null) &&
escapeDone = false;
j++) {
escapeDone = true;
break;
}
}
if (!escapeDone) {
}
} else {
"\"\t");
}
} else {
}
}
}
} else {
}
}
}
} catch (Exception e) {
}
}
/**
* According to ELF, the log file should start with a #Version which
* specifies the ELF version used followed by a #Fields line which specifies
* all the fields that are being logged.
* <p>
* <tt> ELFFormatter </tt> uses this method to return back the header
* containing these two lines. <tt> FileHandler </TT> checks if the header
* is already written, if not uses this method to get the header and puts it
* at the beginning of the file.
* @param handler The target handler (can be null)
* @return the set of all fields converted into a # prefixed string.
*/
// to be done: append correct Fields after gettting from logmanager.
}
/**
* Returns an empty string.
* @param handler The target handler (can be null)
* @return a empty string.
*/
return "";
}
private String constructHeader() {
}
}
/**
* This method is used to process each field to see if it has a quote,
* if it does then append another quote. If any field has a \r or \n
* replace them by \\r and \\n. This is essentially to take care of
* multiline strings(Strings which have \r\n in them)
*/
}
boolean hasUniqueChar = false;
for (int i = 0; i < len; i ++) {
if (currentCharacter == '"') {
hasUniqueChar = true;
}
if (currentCharacter == '\r') {
hasUniqueChar = true;
}
if (currentCharacter == '\n') {
hasUniqueChar = true;
}
if (!hasUniqueChar) {
}
hasUniqueChar = false;
}
return sbuffer;
}
}