DebugFileImpl.java revision 10165d7e4cd84a62ad539bbc21526ff549137fc1
/**
* 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: DebugImpl.java,v 1.4 2009/03/07 08:01:53 veiming Exp $
*
*/
/**
* Portions Copyrighted 2014-2015 ForgeRock AS.
*/
/**
* Manage a log file :
* - compute its complete name
* - create log directory
* - manage the log rotation
*/
public class DebugFileImpl implements DebugFile {
private final TimeService clock;
private long fileCreationTime = 0;
private long nextRotation = 0;
private final SimpleDateFormat suffixDateFormat;
private final DebugConfiguration configuration;
/**
* Constructor
*
* @param configuration debug configuration
* @param debugName log file name
*/
}
/**
* Constructor
*
* @param configuration debug configuration
* @param debugName log file name
* @param clock Clock used to generate date
*/
this.configuration = configuration;
//initialize SimpleDateFormat
try {
} catch (IllegalArgumentException iae) {
// cannot debug as we are debug
String message = "An error occurred with the date format suffix : '" + configuration.getDebugSuffix() +
}
}
this.suffixDateFormat = tmpSuffixDateFormat;
}
if (debugWriter == null) {
initialize();
} else if (needsRotate()) {
rotate();
}
stackStream.flush();
}
// printing is the printer can be consider here as a reading access to it
try {
} finally {
}
}
/**
* Close the log file
*/
private void close() {
this.debugWriter.flush();
this.debugWriter.close();
this.debugWriter = null;
}
/**
* Compute the final log file name (prefix and suffix)
*
* @param fileName the log file name base
* @return the complete log file name
*/
//Set prefix
}
//Set name
//Set suffix
synchronized (suffixDateFormat) {
}
}
return newFileName.toString();
}
/**
* Initialize a new log file
*
* @throws IOException
*/
private synchronized void initialize() throws IOException {
if (this.debugWriter == null) {
// remember when we rotated last
// Is rounded to the lower minute
//Create the log directory
boolean directoryAvailable = false;
directoryAvailable = true;
}
}
if (!directoryAvailable) {
throw new IOException(bundle.getString("com.iplanet.services.debug.nodir") + " Current Debug File : "
+ this);
}
//Create the log file
try {
} catch (IOException ioex) {
if (this.debugWriter != null) {
close();
}
throw new IOException(bundle.getString("com.iplanet.services.debug.nofile") + " Current Debug File : " +
this, ioex);
}
}
}
/**
* Check if a log rotation is needed
*
* @return true if the log file need to be rotate
*/
private boolean needsRotate() {
}
return false;
}
/**
* Rotate log file
*
* @throws IOException
*/
private synchronized void rotate() throws IOException {
if (needsRotate()) {
try {
if (this.debugWriter != null) {
close();
}
initialize();
} finally {
}
}
}
return "DebugFileImpl{" +
'}';
}
}