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