mirror of https://github.com/acidanthera/audk.git
Add log and exception mechanism
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@566 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
0ffa12863e
commit
652f4bd848
|
@ -0,0 +1,47 @@
|
|||
/*++
|
||||
|
||||
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.exception;
|
||||
|
||||
public class EdkException extends Exception {
|
||||
private StackTraceElement[] stackTrace;
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*++
|
||||
|
||||
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.logger;
|
||||
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) {
|
||||
logger.log(levelMap[msgLevel], msg);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*++
|
||||
|
||||
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.logger;
|
||||
|
||||
import org.tianocore.logger.LogMethod;
|
||||
|
||||
|
||||
public class EdkLog {
|
||||
private static final String error = "ERROR";
|
||||
private static final String warning = "WARNING";
|
||||
private static final String info = "INFO";
|
||||
private static final String verbose = "VERBOSE";
|
||||
private static final String debug = "DEBUG";
|
||||
|
||||
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, logLevel, message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void log(int logLevel, String message, Exception cause) {
|
||||
|
||||
}
|
||||
|
||||
public static void log(int logLevel, Exception cause) {
|
||||
|
||||
}
|
||||
|
||||
public static void log(Exception cause) {
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/*++
|
||||
|
||||
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.logger;
|
||||
|
||||
|
||||
public interface LogMethod {
|
||||
public void putMessage(Object msgSource, int msgLevel, String msg);
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*++
|
||||
|
||||
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:
|
||||
GenBuildLogger.java
|
||||
|
||||
Abstract:
|
||||
|
||||
--*/
|
||||
|
||||
package org.tianocore.build.global;
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.tianocore.logger.LogMethod;
|
||||
|
||||
class GenBuildLogger implements LogMethod {
|
||||
private Project project;
|
||||
public GenBuildLogger(Project project) {
|
||||
this.project = project;
|
||||
|
||||
}
|
||||
|
||||
public void putMessage(Object msgSource, int msgLevel, String msg) {
|
||||
this.project.log(msg, Project.MSG_INFO);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue