diff options
author | hche10x <hche10x@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-01-31 08:20:54 +0000 |
---|---|---|
committer | hche10x <hche10x@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-01-31 08:20:54 +0000 |
commit | 9e011eacdbc44b753abac2cb77998f84412a7d10 (patch) | |
tree | 0c83e804e13700f1a3043012bd3cdcee3a8225cb /Tools | |
parent | a8b194b97cd4d0cd46ce9880293c4500bd841fc1 (diff) | |
download | edk2-9e011eacdbc44b753abac2cb77998f84412a7d10.zip edk2-9e011eacdbc44b753abac2cb77998f84412a7d10.tar.gz edk2-9e011eacdbc44b753abac2cb77998f84412a7d10.tar.bz2 |
1. Fix EDKT508: FW should't build Log.log file in current directory
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2341 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java | 36 | ||||
-rw-r--r-- | Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Log.java | 152 | ||||
-rwxr-xr-x | Tools/bin/FrameworkWizard | 2 | ||||
-rw-r--r-- | Tools/bin/FrameworkWizard.bat | 2 | ||||
-rwxr-xr-x | Tools/bin/fw | 2 | ||||
-rw-r--r-- | Tools/bin/fw.bat | 2 |
6 files changed, 131 insertions, 65 deletions
diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java index c3452d7..69d4742 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java @@ -324,12 +324,22 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe @return FrameworkWizardUI The instance of this class
**/
- public static FrameworkWizardUI getInstance() {
+ public static FrameworkWizardUI getInstance(String[] args) {
if (fwui == null) {
- fwui = new FrameworkWizardUI();
+ fwui = new FrameworkWizardUI(args);
}
return fwui;
}
+
+ /**
+ If the class hasn't an instnace, new one.
+
+ @return FrameworkWizardUI The instance of this class
+
+ **/
+ public static FrameworkWizardUI getInstance() {
+ return fwui;
+ }
/**
This method initializes jMenuBar
@@ -1794,8 +1804,11 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe * Main class, start the GUI
*
*/
- public static void main(String[] args) {
- FrameworkWizardUI module = FrameworkWizardUI.getInstance();
+ public static void main(String[] args) {
+ //
+ // Start Main UI
+ //
+ FrameworkWizardUI module = FrameworkWizardUI.getInstance(args);
module.setVisible(true);
}
@@ -1803,9 +1816,9 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe This is the default constructor
**/
- public FrameworkWizardUI() {
+ public FrameworkWizardUI(String[] args) {
super();
- init();
+ init(args);
}
/**
@@ -1813,7 +1826,7 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe **/
- private void init() {
+ private void init(String[] args) {
//
// Set current workspace and check
// Check if exists WORKSPACE
@@ -1826,6 +1839,15 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe //
SplashScreen ss = new SplashScreen();
ss.setVisible(true);
+
+ //
+ // Go through args to check if enable log
+ //
+ for (int index = 0; index < args.length; index++) {
+ if (args[index].equals("--log") || args[index].equals("-l")) {
+ Log.setSaveLog(true);
+ }
+ }
//
// Init Global Data
diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Log.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Log.java index cab1909..49a7a36 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Log.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Log.java @@ -23,12 +23,18 @@ import java.io.IOException; import javax.swing.JOptionPane;
import org.tianocore.frameworkwizard.FrameworkWizardUI;
+import org.tianocore.frameworkwizard.workspace.Workspace;
/**
The class is used to provides static interfaces to save log and error information
**/
public class Log {
+ //
+ //Log file directory path
+ //
+ private static String strLogDir = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + "Tools"
+ + DataType.FILE_SEPARATOR + "Logs";
//
//Log file
@@ -48,17 +54,22 @@ public class Log { //
//Log file name
//
- static String strLogFileName = "Log.log";
+ private static String strLogFileName = strLogDir + DataType.FILE_SEPARATOR + "frameworkwizard.log";
//
//Wrn file name
//
- static String strWrnFileName = "Wrn.log";
+ private static String strWrnFileName = strLogDir + DataType.FILE_SEPARATOR + "frameworkwizard.wrn";
//
//Err file name
//
- static String strErrFileName = "Err.log";
+ private static String strErrFileName = strLogDir + DataType.FILE_SEPARATOR + "frameworkwizard.err";
+
+ //
+ //Flag for create log or not
+ //
+ private static boolean isSaveLog = false;
/**
Main class, used for test
@@ -88,7 +99,7 @@ public class Log { public static void log(String strItem, String strLog) {
try {
writeToLogFile(strItem + ":" + strLog);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -102,7 +113,7 @@ public class Log { public static void log(String strLog) {
try {
writeToLogFile(strLog);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -118,7 +129,7 @@ public class Log { try {
writeToWrnFile("Warning when " + strItem + "::" + strWrn);
showWrnMessage(strWrn);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -133,7 +144,7 @@ public class Log { try {
writeToWrnFile("Warning::" + strWrn);
showWrnMessage("Warning::" + strWrn);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -148,7 +159,7 @@ public class Log { public static void err(String strItem, String strErr) {
try {
writeToErrFile("Error when " + strItem + "::" + strErr);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -162,7 +173,7 @@ public class Log { public static void err(String strErr) {
try {
writeToErrFile("Error::" + strErr);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -176,8 +187,8 @@ public class Log { **/
private static void showWrnMessage(String strErr) {
String strReturn = Tools.wrapStringByWord(strErr);
- JOptionPane
- .showConfirmDialog(FrameworkWizardUI.getInstance(), strReturn, "Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showConfirmDialog(FrameworkWizardUI.getInstance(), strReturn, "Warning",
+ JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
}
/**
@@ -187,21 +198,25 @@ public class Log { @throws IOException
**/
- private static void writeToLogFile(String strLog) throws IOException {
- try {
- if (fleLogFile == null) {
- fleLogFile = new File(strLogFileName);
- fleLogFile.createNewFile();
+ private static void writeToLogFile(String strLog) throws Exception {
+ if (isSaveLog) {
+ try {
+ createLogDir();
+ if (fleLogFile == null) {
+ fleLogFile = new File(strLogFileName);
+ fleLogFile.delete();
+ fleLogFile.createNewFile();
+ }
+ FileOutputStream fos = new FileOutputStream(fleLogFile, true);
+ fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
+ fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
+ fos.flush();
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
}
- FileOutputStream fos = new FileOutputStream(fleLogFile, true);
- fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
- fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
- fos.flush();
- fos.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
}
}
@@ -209,24 +224,28 @@ public class Log { Open wrn file and write wrn information
@param strLog The log information
- @throws IOException
+ * @throws Exception
**/
- private static void writeToWrnFile(String strLog) throws IOException {
- try {
- if (fleWrnFile == null) {
- fleWrnFile = new File(strWrnFileName);
- fleWrnFile.createNewFile();
+ private static void writeToWrnFile(String strLog) throws Exception {
+ if (isSaveLog) {
+ try {
+ createLogDir();
+ if (fleWrnFile == null) {
+ fleWrnFile = new File(strWrnFileName);
+ fleWrnFile.delete();
+ fleWrnFile.createNewFile();
+ }
+ FileOutputStream fos = new FileOutputStream(fleWrnFile, true);
+ fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
+ fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
+ fos.flush();
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
}
- FileOutputStream fos = new FileOutputStream(fleWrnFile, true);
- fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
- fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
- fos.flush();
- fos.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
}
}
@@ -237,21 +256,46 @@ public class Log { @throws IOException
**/
- private static void writeToErrFile(String strLog) throws IOException {
- try {
- if (fleErrFile == null) {
- fleErrFile = new File(strErrFileName);
- fleErrFile.createNewFile();
+ private static void writeToErrFile(String strLog) throws Exception {
+ if (isSaveLog) {
+ try {
+ createLogDir();
+ if (fleErrFile == null) {
+ fleErrFile = new File(strErrFileName);
+ fleErrFile.delete();
+ fleErrFile.createNewFile();
+ }
+ FileOutputStream fos = new FileOutputStream(fleErrFile, true);
+ fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
+ fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
+ fos.flush();
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
}
- FileOutputStream fos = new FileOutputStream(fleErrFile, true);
- fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
- fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
- fos.flush();
- fos.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
}
}
+
+ /**
+ Check if directory for Logs exists or not
+ Create the directory if it doesn't exist
+ * @throws Exception
+
+ **/
+ private static void createLogDir() throws Exception {
+ File f = new File(strLogDir);
+ if (!f.exists()) {
+ FileOperation.newFolder(strLogDir);
+ }
+ }
+
+ public static boolean isSaveLog() {
+ return isSaveLog;
+ }
+
+ public static void setSaveLog(boolean isSaveLog) {
+ Log.isSaveLog = isSaveLog;
+ }
}
diff --git a/Tools/bin/FrameworkWizard b/Tools/bin/FrameworkWizard index 1473909..efc650d 100755 --- a/Tools/bin/FrameworkWizard +++ b/Tools/bin/FrameworkWizard @@ -10,4 +10,4 @@ # # Run Framework Wizard -java -Xmx256m -cp "$CLASSPATH:$WORKSPACE/Tools/bin/FrameworkWizard.jar" org.tianocore.frameworkwizard.FrameworkWizardUI +java -Xmx256m -cp "$CLASSPATH:$WORKSPACE/Tools/bin/FrameworkWizard.jar" org.tianocore.frameworkwizard.FrameworkWizardUI $1 diff --git a/Tools/bin/FrameworkWizard.bat b/Tools/bin/FrameworkWizard.bat index 41ac5dc..056a331 100644 --- a/Tools/bin/FrameworkWizard.bat +++ b/Tools/bin/FrameworkWizard.bat @@ -29,7 +29,7 @@ if not exist %WORKSPACE%\Tools\bin\FrameworkWizard.jar ( )
@REM Run Framework Wizard
-call "java" -Xmx256m org.tianocore.frameworkwizard.FrameworkWizardUI
+call "java" -Xmx256m org.tianocore.frameworkwizard.FrameworkWizardUI %%1
goto end
diff --git a/Tools/bin/fw b/Tools/bin/fw index 0f8c80f..505fe7b 100755 --- a/Tools/bin/fw +++ b/Tools/bin/fw @@ -10,4 +10,4 @@ # # Run Framework Wizard -java -cp "$CLASSPATH:$WORKSPACE/Tools/bin/FrameworkWizard.jar" org.tianocore.frameworkwizard.FrameworkWizardUI +java -cp "$CLASSPATH:$WORKSPACE/Tools/bin/FrameworkWizard.jar" org.tianocore.frameworkwizard.FrameworkWizardUI $1 diff --git a/Tools/bin/fw.bat b/Tools/bin/fw.bat index 41ac5dc..056a331 100644 --- a/Tools/bin/fw.bat +++ b/Tools/bin/fw.bat @@ -29,7 +29,7 @@ if not exist %WORKSPACE%\Tools\bin\FrameworkWizard.jar ( )
@REM Run Framework Wizard
-call "java" -Xmx256m org.tianocore.frameworkwizard.FrameworkWizardUI
+call "java" -Xmx256m org.tianocore.frameworkwizard.FrameworkWizardUI %%1
goto end
|