Merge "Omaha #2975 fix mkdirs() bug" into omaha_14.4.1
Former-commit-id:cddda47923
[formerly c643d7c706ef39d1c17926b2a99bcfa2e52c3193] Former-commit-id:aa43004f85
This commit is contained in:
commit
2bca618f67
1 changed files with 33 additions and 25 deletions
|
@ -23,30 +23,31 @@ import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
|
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
|
import com.raytheon.uf.viz.core.VizApp;
|
||||||
|
import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for logging cave performance metrics
|
* Abstract class for logging cave performance metrics
|
||||||
*
|
*
|
||||||
* Modified to add the log() method so as to make sure timestamp, host, and user name will be logged.
|
|
||||||
* - By Wufeng Zhou 07/26/2010
|
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jul 3, 2010 mschenke Initial creation
|
* Jul 03, 2010 mschenke Initial creation
|
||||||
|
* Jul 26, 2010 wzhou Added log methods
|
||||||
|
* Oct 01, 2014 2975 njensen Cleaned up
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -54,8 +55,14 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AbstractCavePerformanceMonitor {
|
public abstract class AbstractCavePerformanceMonitor {
|
||||||
private final SimpleDateFormat TIMESTAMP_FORMAT = new SimpleDateFormat("yyyyMMdd HH:mm:ss.SSS");
|
|
||||||
|
private final SimpleDateFormat TIMESTAMP_FORMAT = new SimpleDateFormat(
|
||||||
|
"yyyyMMdd HH:mm:ss.SSS");
|
||||||
|
|
||||||
|
private final String hostname;
|
||||||
|
|
||||||
|
private final String username;
|
||||||
|
|
||||||
private PrintStream out;
|
private PrintStream out;
|
||||||
|
|
||||||
|
@ -71,6 +78,8 @@ public class AbstractCavePerformanceMonitor {
|
||||||
runTotalTimeMap = new HashMap<String, Long>();
|
runTotalTimeMap = new HashMap<String, Long>();
|
||||||
|
|
||||||
out = getPrintStream(fileName);
|
out = getPrintStream(fileName);
|
||||||
|
hostname = VizApp.getHostName();
|
||||||
|
username = LocalizationManager.getInstance().getCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,12 +95,14 @@ public class AbstractCavePerformanceMonitor {
|
||||||
.getContext(LocalizationType.CAVE_STATIC,
|
.getContext(LocalizationType.CAVE_STATIC,
|
||||||
LocalizationLevel.USER);
|
LocalizationLevel.USER);
|
||||||
|
|
||||||
File logFile = PathManagerFactory.getPathManager().getLocalizationFile(
|
File logFile = PathManagerFactory
|
||||||
ctx,
|
.getPathManager()
|
||||||
"logs" + File.separator + fileName + "-"
|
.getLocalizationFile(
|
||||||
+ sdf.format(new Date()) + ".log").getFile();
|
ctx,
|
||||||
|
"logs" + IPathManager.SEPARATOR + fileName + "-"
|
||||||
|
+ sdf.format(new Date()) + ".log").getFile();
|
||||||
if (logFile.getParentFile().exists() == false) {
|
if (logFile.getParentFile().exists() == false) {
|
||||||
logFile.mkdirs();
|
logFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -105,26 +116,23 @@ public class AbstractCavePerformanceMonitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* logg message along with timestamp, host, and user name information.
|
* log message along with timestamp, host, and user name information. -added
|
||||||
* -added by Wufeng Zhou 07/26/2010
|
* by Wufeng Zhou 07/26/2010
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
protected void log(String message) {
|
protected void log(String message) {
|
||||||
String hostname = null;
|
String timestamp = TIMESTAMP_FORMAT.format(new Date());
|
||||||
try {
|
out.println(timestamp + " Host=" + hostname + ", User=" + username
|
||||||
hostname = InetAddress.getLocalHost().getHostName();
|
+ ", " + message);
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
hostname = "unknown";
|
|
||||||
}
|
|
||||||
String timestamp = TIMESTAMP_FORMAT.format(new Date());
|
|
||||||
out.println(timestamp + " Host=" + hostname + ", User=" + System.getProperty("user.name") + ", " + message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* printout exception stacktrace
|
* printout exception stacktrace
|
||||||
|
*
|
||||||
* @param e
|
* @param e
|
||||||
*/
|
*/
|
||||||
protected void log(Exception e) {
|
protected void log(Exception e) {
|
||||||
e.printStackTrace(out);
|
e.printStackTrace(out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue