StdDebugFile.java revision 9c613e28bb91f464d2e937b21b8174b23499038a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the Common Development and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Distribution License (the License). You may not use this file except in compliance with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specific language governing permission and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Software, include this CDDL Header Notice in each file and include
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Header, with the fields enclosed by brackets [] replaced by your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: "Portions copyright [year] [name of copyright owner]".
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2014-2015 ForgeRock AS.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteimport com.sun.identity.shared.debug.DebugConstants;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteimport com.sun.identity.shared.debug.file.DebugFile;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakkiimport com.sun.identity.shared.debug.impl.DebugImpl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Debug file dedicated to std out
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte private static final StdDebugFile INSTANCE = new StdDebugFile();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte private PrintWriter stdoutWriter = new PrintWriter(System.out, true);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get std out debug file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return std debug file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte public void writeIt(String prefix, String msg, Throwable th) throws IOException {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte StringWriter stBuf = new StringWriter(DebugConstants.MAX_BUFFER_SIZE_EXCEPTION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PrintWriter stackStream = new PrintWriter(stBuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Printing error directly into the stdout. A log header will be generated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param debugName debug name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param message the error message
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ex the exception (can be null)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte public static void printError(String debugName, String message, Throwable ex) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss:SSS a zzz");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte String prefix = debugName + ":" + dateFormat.format(new Date()) + ": " + Thread.currentThread().toString() +