summaryrefslogtreecommitdiff
path: root/Tools/Java/Source/Common
diff options
context:
space:
mode:
authorlhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524>2006-10-05 23:12:07 +0000
committerlhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524>2006-10-05 23:12:07 +0000
commitfeccee87a78e68d575dbdf44b34ca0cb5a21ea8d (patch)
treec70bdaea30cf92a8555e1013fc15565138203134 /Tools/Java/Source/Common
parent214b0d1914b48d651b25e58f321ddb77a46903b8 (diff)
downloadedk2-platforms-feccee87a78e68d575dbdf44b34ca0cb5a21ea8d.tar.xz
Restructuring for better separation of Tool packages.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1674 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Java/Source/Common')
-rw-r--r--Tools/Java/Source/Common/Common.msa42
-rw-r--r--Tools/Java/Source/Common/build.xml46
-rw-r--r--Tools/Java/Source/Common/org/tianocore/common/cache/FileTimeStamp.java83
-rw-r--r--Tools/Java/Source/Common/org/tianocore/common/definitions/EdkDefinitions.java111
-rw-r--r--Tools/Java/Source/Common/org/tianocore/common/definitions/ToolDefinitions.java103
-rw-r--r--Tools/Java/Source/Common/org/tianocore/common/exception/EdkException.java49
-rw-r--r--Tools/Java/Source/Common/org/tianocore/common/logger/DefaultLogger.java44
-rw-r--r--Tools/Java/Source/Common/org/tianocore/common/logger/EdkLog.java112
-rw-r--r--Tools/Java/Source/Common/org/tianocore/common/logger/LogMethod.java27
9 files changed, 617 insertions, 0 deletions
diff --git a/Tools/Java/Source/Common/Common.msa b/Tools/Java/Source/Common/Common.msa
new file mode 100644
index 0000000000..fa7f93a5cf
--- /dev/null
+++ b/Tools/Java/Source/Common/Common.msa
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" >
+ <MsaHeader>
+ <ModuleName>Common Java Classes</ModuleName>
+ <ModuleType>TOOL</ModuleType>
+ <GuidValue>9D0ACB3E-4CE1-4228-98FF-85E64B0A4EC8</GuidValue>
+ <Version>2.0</Version>
+ <Abstract>This is the EFI/Tiano Tool Resources Module</Abstract>
+ <Description>
+ This Module provides the EFI/Tiano Tools that are used to create EFI/Tiano
+ Modules and Platform Binary Files (PBF)
+ These tools require compilation only once if the Developer Workstation and
+ the Developer's choice of HOST tool chain are stable. If the developer
+ updates either the OS or the HOST tool chain, these tools should be rebuilt.
+ </Description>
+ <Copyright>Copyright 2005-2006, Intel Corporation</Copyright>
+ <License>
+All rights reserved.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the
+BSD License which accompanies this distribution. The full text of the
+license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>NULL</OutputFileBasename>
+ </ModuleDefinitions>
+ <SourceFiles>
+ <Filename>build.xml</Filename>
+ <Filename>org/tianocore/exception/EdkException.java</Filename>
+ <Filename>org/tianocore/logger/DefaultLogger.java</Filename>
+ <Filename>org/tianocore/logger/EdkLog.java</Filename>
+ <Filename>org/tianocore/logger/LogMethod.java</Filename>
+ </SourceFiles>
+</ModuleSurfaceArea>
diff --git a/Tools/Java/Source/Common/build.xml b/Tools/Java/Source/Common/build.xml
new file mode 100644
index 0000000000..4fd7285f01
--- /dev/null
+++ b/Tools/Java/Source/Common/build.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<!--
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+-->
+<project name="Common" default="Common_Jar" basedir=".">
+
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE" value="${env.WORKSPACE}"/>
+ <property name="buildDir" value="build"/>
+ <property name="installLocation" value="${WORKSPACE}/Tools/Jars"/>
+ <target name="Common_Jar" depends="install"/>
+ <target name="source">
+ <mkdir dir="${buildDir}"/>
+ <javac srcdir="." destdir="${buildDir}">
+ <compilerarg value="-Xlint"/>
+ </javac>
+ </target>
+ <target name="clean">
+ <delete dir="${buildDir}"/>
+ </target>
+ <target name="cleanall">
+ <delete dir="${buildDir}"/>
+ <delete file="${installLocation}/Common.jar"/>
+ <if>
+ <available file="${installLocation}/Common.jar"/>
+ <then>
+ <echo message="You must manually remove the file: ${installLocation}/Common.jar"/>
+ <echo message="Java has already loaded the file, and cannot remove it within ANT!"/>
+ </then>
+ </if>
+ </target>
+ <target name="install" depends="source">
+ <jar destfile="${installLocation}/Common.jar"
+ basedir="${buildDir}"
+ includes="**"
+ />
+ </target>
+</project>
diff --git a/Tools/Java/Source/Common/org/tianocore/common/cache/FileTimeStamp.java b/Tools/Java/Source/Common/org/tianocore/common/cache/FileTimeStamp.java
new file mode 100644
index 0000000000..968d31f15c
--- /dev/null
+++ b/Tools/Java/Source/Common/org/tianocore/common/cache/FileTimeStamp.java
@@ -0,0 +1,83 @@
+/** @file
+This file is to define the FileTimeStamp class for speeding up the dependency check.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.common.cache;
+
+import java.io.File;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.HashMap;
+
+/**
+ FileTimeStamp class is used to cache the time stamp of accessing file, which
+ will speed up the dependency check for build
+ **/
+public class FileTimeStamp {
+ //
+ // cache the modified timestamp of files accessed, to speed up the depencey check
+ //
+ private static Map<String, Long> timeStampCache = new HashMap<String, Long>();
+
+ /**
+ Get the time stamp of given file. It will try the cache first and then
+ get from file system if no time stamp of the file is cached.
+
+ @param file File name
+
+ @return long The time stamp of the file
+ **/
+ synchronized public static long get(String file) {
+ long timeStamp = 0;
+
+ Long value = timeStampCache.get(file);
+ if (value != null) {
+ timeStamp = value.longValue();
+ } else {
+ timeStamp = new File(file).lastModified();
+ timeStampCache.put(file, new Long(timeStamp));
+ }
+
+ return timeStamp;
+ }
+
+ /**
+ Force update the time stamp for the given file
+
+ @param file File name
+ @param timeStamp The time stamp of the file
+ **/
+ synchronized public static void update(String file, long timeStamp) {
+ timeStampCache.put(file, new Long(timeStamp));
+ }
+
+ /**
+ Force update the time stamp for the given file
+
+ @param file File name
+ **/
+ synchronized public static void update(String file) {
+ long timeStamp = new File(file).lastModified();
+ timeStampCache.put(file, new Long(timeStamp));
+ }
+
+ /**
+ Check if the time stamp of given file has been cached for not
+
+ @param file The file name
+
+ @return boolean
+ **/
+ synchronized public static boolean containsKey(String file) {
+ return timeStampCache.containsKey(file);
+ }
+}
diff --git a/Tools/Java/Source/Common/org/tianocore/common/definitions/EdkDefinitions.java b/Tools/Java/Source/Common/org/tianocore/common/definitions/EdkDefinitions.java
new file mode 100644
index 0000000000..e5f510a199
--- /dev/null
+++ b/Tools/Java/Source/Common/org/tianocore/common/definitions/EdkDefinitions.java
@@ -0,0 +1,111 @@
+/** @file
+ EdkDefinitions Class.
+
+ EdkDefinitions class incldes the common EDK definitions which are used
+ by the Tools.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+package org.tianocore.common.definitions;
+
+/**
+ This class includes the common EDK definitions.
+ **/
+public class EdkDefinitions {
+ ///
+ /// MODULE_TYPE definitions
+ ///
+ public final static String MODULE_TYPE_BASE = "BASE";
+ public final static String MODULE_TYPE_SEC = "SEC";
+ public final static String MODULE_TYPE_PEI_CORE = "PEI_CORE";
+ public final static String MODULE_TYPE_PEIM = "PEIM";
+ public final static String MODULE_TYPE_DXE_CORE = "DXE_CORE";
+ public final static String MODULE_TYPE_DXE_DRIVER = "DXE_DRIVER";
+ public final static String MODULE_TYPE_DXE_RUNTIME_DRIVER = "DXE_RUNTIME_DRIVER";
+ public final static String MODULE_TYPE_DXE_SMM_DRIVER = "DXE_SMM_DRIVER";
+ public final static String MODULE_TYPE_DXE_SAL_DRIVER = "DXE_SAL_DRIVER";
+ public final static String MODULE_TYPE_UEFI_DRIVER = "UEFI_DRIVER";
+ public final static String MODULE_TYPE_UEFI_APPLICATION = "UEFI_APPLICATION";
+ public final static String MODULE_TYPE_USER_DEFINED = "USER_DEFINED";
+ public final static String MODULE_TYPE_TOOL = "TOOL";
+
+ ///
+ /// Extension definitions for each of module types
+ ///
+ public final static String ModuleTypeExtensions[][] = {
+ { MODULE_TYPE_BASE, ".FFS" },
+ { MODULE_TYPE_SEC, ".SEC" },
+ { MODULE_TYPE_PEI_CORE, ".PEI" },
+ { MODULE_TYPE_PEIM, ".PEI" },
+ { MODULE_TYPE_DXE_CORE, ".DXE" },
+ { MODULE_TYPE_DXE_DRIVER, ".DXE" },
+ { MODULE_TYPE_DXE_RUNTIME_DRIVER, ".DXE" },
+ { MODULE_TYPE_DXE_SMM_DRIVER, ".DXE" },
+ { MODULE_TYPE_DXE_SAL_DRIVER, ".DXE" },
+ { MODULE_TYPE_UEFI_DRIVER, ".DXE" },
+ { MODULE_TYPE_UEFI_APPLICATION, ".APP" },
+ { MODULE_TYPE_USER_DEFINED, ".FFS" },
+ { MODULE_TYPE_TOOL, ".FFS" }
+ };
+
+ ///
+ /// FFS_TYPE definitions
+ ///
+ public final static int EFI_FV_FILETYPE_ALL = 0x00;
+ public final static int EFI_FV_FILETYPE_RAW = 0x01;
+ public final static int EFI_FV_FILETYPE_FREEFORM = 0x02;
+ public final static int EFI_FV_FILETYPE_SECURITY_CORE = 0x03;
+ public final static int EFI_FV_FILETYPE_PEI_CORE = 0x04;
+ public final static int EFI_FV_FILETYPE_DXE_CORE = 0x05;
+ public final static int EFI_FV_FILETYPE_PEIM = 0x06;
+ public final static int EFI_FV_FILETYPE_DRIVER = 0x07;
+ public final static int EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER = 0x08;
+ public final static int EFI_FV_FILETYPE_APPLICATION = 0x09;
+ public final static int EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE = 0x0B;
+ public final static int EFI_FV_FILETYPE_FFS_PAD = 0xF0;
+
+ ///
+ /// SECTION_TYPE definitions
+ ///
+ public final static String EFI_SECTION_COMPRESSION = "EFI_SECTION_COMPRESSION";
+ public final static String EFI_SECTION_GUID_DEFINED = "EFI_SECTION_GUID_DEFINED";
+ public final static String EFI_SECTION_PE32 = "EFI_SECTION_PE32";
+ public final static String EFI_SECTION_PIC = "EFI_SECTION_PIC";
+ public final static String EFI_SECTION_TE = "EFI_SECTION_TE";
+ public final static String EFI_SECTION_DXE_DEPEX = "EFI_SECTION_DXE_DEPEX";
+ public final static String EFI_SECTION_VERSION = "EFI_SECTION_VERSION";
+ public final static String EFI_SECTION_USER_INTERFACE = "EFI_SECTION_USER_INTERFACE";
+ public final static String EFI_SECTION_COMPATIBILITY16 = "EFI_SECTION_COMPATIBILITY16";
+ public final static String EFI_SECTION_FIRMWARE_VOLUME_IMAGE = "EFI_SECTION_FIRMWARE_VOLUME_IMAGE";
+ public final static String EFI_SECTION_FREEFORM_SUBTYPE_GUID = "EFI_SECTION_FREEFORM_SUBTYPE_GUID";
+ public final static String EFI_SECTION_RAW = "EFI_SECTION_RAW";
+ public final static String EFI_SECTION_PEI_DEPEX = "EFI_SECTION_PEI_DEPEX";
+
+ ///
+ /// Extension definitions for each of section types
+ ///
+ public final static String SectionTypeExtensions[][] = {
+ { EFI_SECTION_COMPRESSION, ".sec" },
+ { EFI_SECTION_GUID_DEFINED, ".sec" },
+ { EFI_SECTION_PE32, ".pe32" },
+ { EFI_SECTION_PIC, ".pic" },
+ { EFI_SECTION_TE, ".tes" },
+ { EFI_SECTION_DXE_DEPEX, ".dpx" },
+ { EFI_SECTION_VERSION, ".ver" },
+ { EFI_SECTION_USER_INTERFACE, ".ui" },
+ { EFI_SECTION_COMPATIBILITY16, ".sec" },
+ { EFI_SECTION_FIRMWARE_VOLUME_IMAGE, ".sec" },
+ { EFI_SECTION_FREEFORM_SUBTYPE_GUID, ".sec" },
+ { EFI_SECTION_RAW, ".sec" },
+ { EFI_SECTION_PEI_DEPEX, ".dpx" }
+ };
+}
diff --git a/Tools/Java/Source/Common/org/tianocore/common/definitions/ToolDefinitions.java b/Tools/Java/Source/Common/org/tianocore/common/definitions/ToolDefinitions.java
new file mode 100644
index 0000000000..5a1986f246
--- /dev/null
+++ b/Tools/Java/Source/Common/org/tianocore/common/definitions/ToolDefinitions.java
@@ -0,0 +1,103 @@
+/** @file
+ ToolDefinitions Class.
+
+ ToolDefinitions class incldes the common Tool definitions.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+package org.tianocore.common.definitions;
+
+import java.io.File;
+
+/**
+ This class includes the common Tool definitions.
+ **/
+public class ToolDefinitions {
+ ///
+ /// Line separator (carriage return-line feed, CRLF)
+ ///
+ public final static String LINE_SEPARATOR = "\r\n";
+
+ ///
+ /// Framework Database (FrameworkDatabase.db) file path
+ ///
+ public final static String FRAMEWORK_DATABASE_FILE_PATH =
+ "Tools" + File.separatorChar + "Conf" + File.separatorChar + "FrameworkDatabase.db";
+
+ ///
+ /// Target (target.txt) file path
+ ///
+ public final static String TARGET_FILE_PATH =
+ "Tools" + File.separatorChar + "Conf" + File.separatorChar + "target.txt";
+
+ ///
+ /// Default Tools Definition (tools_def.txt) file path
+ ///
+ public final static String DEFAULT_TOOLS_DEF_FILE_PATH =
+ "Tools" + File.separatorChar + "Conf" + File.separatorChar + "tools_def.txt";
+
+ ///
+ /// Extension names for SPD, FPD, and MSA
+ ///
+ public final static String SPD_EXTENSION = ".spd";
+ public final static String FPD_EXTENSION = ".fpd";
+ public final static String MSA_EXTENSION = ".msa";
+
+ ///
+ /// Tool Chain Elements in the Tools Definition file
+ ///
+ public final static String TOOLS_DEF_ELEMENT_TARGET = "TARGET";
+ public final static String TOOLS_DEF_ELEMENT_TOOLCHAIN = "TOOLCHAIN";
+ public final static String TOOLS_DEF_ELEMENT_ARCH = "ARCH";
+ public final static String TOOLS_DEF_ELEMENT_TOOLCODE = "TOOLCODE";
+ public final static String TOOLS_DEF_ELEMENT_ATTRIBUTE = "ATTRIBUTE";
+
+ ///
+ /// Index of Tool Chain elements in the Tools Definition file
+ ///
+ public final static int TOOLS_DEF_ELEMENT_INDEX_TARGET = 0;
+ public final static int TOOLS_DEF_ELEMENT_INDEX_TOOLCHAIN = 1;
+ public final static int TOOLS_DEF_ELEMENT_INDEX_ARCH = 2;
+ public final static int TOOLS_DEF_ELEMENT_INDEX_TOOLCODE = 3;
+ public final static int TOOLS_DEF_ELEMENT_INDEX_ATTRIBUTE = 4;
+ public final static int TOOLS_DEF_ELEMENT_INDEX_MAXIMUM = 5;
+
+ ///
+ /// Tool Chain Attributes in the Tools Definition file
+ ///
+ public final static String TOOLS_DEF_ATTRIBUTE_NAME = "NAME";
+ public final static String TOOLS_DEF_ATTRIBUTE_PATH = "PATH";
+ public final static String TOOLS_DEF_ATTRIBUTE_DPATH = "DPATH";
+ public final static String TOOLS_DEF_ATTRIBUTE_SPATH = "SPATH";
+ public final static String TOOLS_DEF_ATTRIBUTE_EXT = "EXT";
+ public final static String TOOLS_DEF_ATTRIBUTE_FAMILY = "FAMILY";
+ public final static String TOOLS_DEF_ATTRIBUTE_FLAGS = "FLAGS";
+
+ ///
+ /// Tool Chain Families in the Tools Definition file
+ ///
+ public final static String TOOLS_DEF_FAMILY_MSFT = "MSFT";
+ public final static String TOOLS_DEF_FAMILY_INTEL = "INTEL";
+ public final static String TOOLS_DEF_FAMILY_GCC = "GCC";
+
+ ///
+ /// Key name in the Target file
+ ///
+ public final static String TARGET_KEY_ACTIVE_PLATFORM = "ACTIVE_PLATFORM";
+ public final static String TARGET_KEY_TARGET = "TARGET";
+ public final static String TARGET_KEY_TOOLCHAIN = "TOOL_CHAIN_TAG";
+ public final static String TARGET_KEY_ARCH = "TARGET_ARCH";
+ public final static String TARGET_KEY_TOOLS_DEF = "TOOL_CHAIN_CONF";
+ public final static String TARGET_KEY_MULTIPLE_THREAD = "MULTIPLE_THREAD";
+ public final static String TARGET_KEY_MAX_CONCURRENT_THREAD_NUMBER
+ = "MAX_CONCURRENT_THREAD_NUMBER";
+}
diff --git a/Tools/Java/Source/Common/org/tianocore/common/exception/EdkException.java b/Tools/Java/Source/Common/org/tianocore/common/exception/EdkException.java
new file mode 100644
index 0000000000..6d4fc52dae
--- /dev/null
+++ b/Tools/Java/Source/Common/org/tianocore/common/exception/EdkException.java
@@ -0,0 +1,49 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ EdkException.java
+
+Abstract:
+
+--*/
+
+package org.tianocore.common.exception;
+
+public class EdkException extends Exception {
+ static final long serialVersionUID = -8494188017252114029L;
+
+ public static boolean isPrintStack = false;
+
+ public EdkException(String message) {
+ super("[EdkException]:" + message);
+ }
+
+ public EdkException(String message, boolean traceStack) {
+ super(message);
+
+ }
+
+ public EdkException(){
+ super();
+ }
+
+ public EdkException(Exception e, String message){
+ super("[EdkException]:" + message);
+ if (isPrintStack){
+ this.setStackTrace(e.getStackTrace());
+ }
+ e.printStackTrace();
+ }
+ public static void setIsprintStack (boolean flag){
+ isPrintStack = flag;
+ }
+}
diff --git a/Tools/Java/Source/Common/org/tianocore/common/logger/DefaultLogger.java b/Tools/Java/Source/Common/org/tianocore/common/logger/DefaultLogger.java
new file mode 100644
index 0000000000..b1d9d6de85
--- /dev/null
+++ b/Tools/Java/Source/Common/org/tianocore/common/logger/DefaultLogger.java
@@ -0,0 +1,44 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ DefaultLogger.java
+
+Abstract:
+
+--*/
+
+package org.tianocore.common.logger;
+
+import java.io.File;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+class DefaultLogger implements LogMethod {
+ private Logger logger = Logger.global;
+ private static Level[] levelMap = {
+ Level.SEVERE, Level.WARNING, Level.INFO, Level.FINE, Level.ALL
+ };
+
+ public DefaultLogger() {
+ }
+
+ public void putMessage(Object msgSource, int msgLevel, String msg) {
+ if (msgLevel < 0 || msgLevel > levelMap.length) {
+ msgLevel = 2;
+ }
+ logger.log(levelMap[msgLevel], msg);
+ }
+
+ public void flushToFile(File file){
+
+ }
+} \ No newline at end of file
diff --git a/Tools/Java/Source/Common/org/tianocore/common/logger/EdkLog.java b/Tools/Java/Source/Common/org/tianocore/common/logger/EdkLog.java
new file mode 100644
index 0000000000..6b3ed95471
--- /dev/null
+++ b/Tools/Java/Source/Common/org/tianocore/common/logger/EdkLog.java
@@ -0,0 +1,112 @@
+/*++
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name:
+ EdkLogger.java
+
+ Abstract:
+
+ --*/
+package org.tianocore.common.logger;
+
+import java.io.File;
+
+public class EdkLog {
+ public static final String always = "ALWAYS";
+
+ public static final String error = "ERROR";
+
+ public static final String warning = "WARNING";
+
+ public static final String info = "INFO";
+
+ public static final String verbose = "VERBOSE";
+
+ public static final String debug = "DEBUG";
+
+ public static final int EDK_ALWAYS = -1;
+
+ public static final int EDK_ERROR = 0;
+
+ public static final int EDK_WARNING = 1;
+
+ public static final int EDK_INFO = 2;
+
+ public static final int EDK_VERBOSE = 3;
+
+ public static final int EDK_DEBUG = 4;
+
+ private static int logLevel = EDK_INFO;
+
+ private static LogMethod logger = new DefaultLogger();
+
+ public static void log(int level, String message) {
+ if (level <= logLevel) {
+ logger.putMessage(null, level, message);
+ }
+ }
+
+ public static void log(String message) {
+ if (EDK_INFO <= logLevel) {
+ logger.putMessage(null, EDK_INFO, message);
+ }
+ }
+
+ public static void log(Object o, int level, String message) {
+ if (level <= logLevel) {
+ logger.putMessage(o, level, message);
+ }
+ }
+
+ public static void log(Object o, String message) {
+ if (EDK_INFO <= logLevel) {
+ logger.putMessage(o, EDK_INFO, message);
+ }
+ }
+
+ public static void flushLogToFile(File file) {
+ logger.flushToFile(file);
+ }
+
+ public static void setLogger(LogMethod l) {
+ logger = l;
+ }
+
+ public static void setLogLevel(int level) {
+ logLevel = level;
+ }
+
+ public static void setLogLevel(String level) {
+ if (level == null) {
+ return;
+ }
+ String levelStr = level.trim();
+ if (levelStr.equalsIgnoreCase(error)) {
+ logLevel = EDK_ERROR;
+ }
+ if (levelStr.equalsIgnoreCase(debug)) {
+ logLevel = EDK_DEBUG;
+ }
+ if (levelStr.equalsIgnoreCase(info)) {
+ logLevel = EDK_INFO;
+ }
+ if (levelStr.equalsIgnoreCase(verbose)) {
+ logLevel = EDK_VERBOSE;
+ }
+ if (levelStr.equalsIgnoreCase(warning)) {
+ logLevel = EDK_WARNING;
+ }
+ }
+
+ public static int getLogLevel() {
+ return logLevel;
+ }
+}
diff --git a/Tools/Java/Source/Common/org/tianocore/common/logger/LogMethod.java b/Tools/Java/Source/Common/org/tianocore/common/logger/LogMethod.java
new file mode 100644
index 0000000000..f9a6802430
--- /dev/null
+++ b/Tools/Java/Source/Common/org/tianocore/common/logger/LogMethod.java
@@ -0,0 +1,27 @@
+/*++
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name:
+ LogMethod.java
+
+ Abstract:
+
+ --*/
+
+package org.tianocore.common.logger;
+
+import java.io.File;
+
+public interface LogMethod {
+ public void putMessage(Object msgSource, int msgLevel, String msg);
+
+ public void flushToFile(File file);
+}