Fix EDKT256: using unified logging mechanism in PcdAutogen tools.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1626 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2006-09-26 06:11:15 +00:00
parent 97aac8557c
commit e8c0c170fa
5 changed files with 5 additions and 197 deletions

View File

@ -37,7 +37,6 @@ import org.apache.xmlbeans.XmlObject;
import org.tianocore.common.definitions.EdkDefinitions; import org.tianocore.common.definitions.EdkDefinitions;
import org.tianocore.common.exception.EdkException; import org.tianocore.common.exception.EdkException;
import org.tianocore.common.logger.EdkLog; import org.tianocore.common.logger.EdkLog;
import org.tianocore.pcd.action.ActionMessage;
import org.tianocore.build.FrameworkBuildTask; import org.tianocore.build.FrameworkBuildTask;
import org.tianocore.build.global.GlobalData; import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.OutputManager; import org.tianocore.build.global.OutputManager;
@ -454,7 +453,7 @@ public class FpdParserTask extends Task {
// Pcd Collection. Call CollectPCDAction to collect pcd info. // Pcd Collection. Call CollectPCDAction to collect pcd info.
// //
PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding(); PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();
ca.perform(platformId.getFpdFile().getPath(), ActionMessage.NULL_MESSAGE_LEVEL); ca.perform(platformId.getFpdFile().getPath());
} catch (IOException ex) { } catch (IOException ex) {
BuildException buildException = new BuildException("Parsing of the FPD file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage()); BuildException buildException = new BuildException("Parsing of the FPD file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());
buildException.setStackTrace(ex.getStackTrace()); buildException.setStackTrace(ex.getStackTrace());

View File

@ -25,7 +25,7 @@ import org.tianocore.build.FrameworkBuildTask;
import org.tianocore.build.autogen.CommonDefinition; import org.tianocore.build.autogen.CommonDefinition;
import org.tianocore.build.global.GlobalData; import org.tianocore.build.global.GlobalData;
import org.tianocore.build.id.ModuleIdentification; import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.pcd.action.ActionMessage; import org.tianocore.common.logger.EdkLog;
import org.tianocore.pcd.action.BuildAction; import org.tianocore.pcd.action.BuildAction;
import org.tianocore.pcd.entity.MemoryDatabaseManager; import org.tianocore.pcd.entity.MemoryDatabaseManager;
import org.tianocore.pcd.entity.Token; import org.tianocore.pcd.entity.Token;
@ -190,8 +190,7 @@ public class PCDAutoGenAction extends BuildAction {
@throws BuildActionException Failed to execute this aciton class. @throws BuildActionException Failed to execute this aciton class.
**/ **/
public void performAction() { public void performAction() {
ActionMessage.debug(this, EdkLog.log(EdkLog.EDK_DEBUG, "Starting PCDAutoGenAction to generate autogen.h and autogen.c!...");
"Starting PCDAutoGenAction to generate autogen.h and autogen.c!...");
dbManager = GlobalData.getPCDMemoryDBManager(); dbManager = GlobalData.getPCDMemoryDBManager();
@ -199,8 +198,7 @@ public class PCDAutoGenAction extends BuildAction {
return; return;
} }
ActionMessage.debug(this, EdkLog.log(EdkLog.EDK_DEBUG, "PCD memory database contains " + dbManager.getDBSize() + " PCD tokens.");
"PCD memory database contains " + dbManager.getDBSize() + " PCD tokens.");
generateAutogenForModule(); generateAutogenForModule();
} }

View File

@ -32,7 +32,6 @@ import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.build.exception.PlatformPcdPreprocessBuildException; import org.tianocore.build.exception.PlatformPcdPreprocessBuildException;
import org.tianocore.build.global.GlobalData; import org.tianocore.build.global.GlobalData;
import org.tianocore.build.id.FpdModuleIdentification; import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.pcd.action.ActionMessage;
import org.tianocore.pcd.action.PlatformPcdPreprocessAction; import org.tianocore.pcd.action.PlatformPcdPreprocessAction;
import org.tianocore.pcd.entity.MemoryDatabaseManager; import org.tianocore.pcd.entity.MemoryDatabaseManager;
import org.tianocore.pcd.entity.ModulePcdInfoFromFpd; import org.tianocore.pcd.entity.ModulePcdInfoFromFpd;
@ -62,18 +61,6 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
/// ///
private PlatformSurfaceAreaDocument fpdDocInstance; private PlatformSurfaceAreaDocument fpdDocInstance;
/**
Set action message level for CollectPcdAction tool.
The message should be restored when this action exit.
@param actionMessageLevel parameter for this action
**/
public void setActionMessageLevel(int actionMessageLevel) {
originalMessageLevel = ActionMessage.messageLevel;
ActionMessage.messageLevel = actionMessageLevel;
}
/** /**
Set FPDFileName parameter for this action class. Set FPDFileName parameter for this action class.
@ -87,20 +74,17 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
Common function interface for outer. Common function interface for outer.
@param fpdFilePath The fpd file path of current build or processing. @param fpdFilePath The fpd file path of current build or processing.
@param messageLevel The message level for this Action.
@throws PlatformPreprocessBuildException @throws PlatformPreprocessBuildException
The exception of this function. Because it can *not* be predict The exception of this function. Because it can *not* be predict
where the action class will be used. So only Exception can be throw. where the action class will be used. So only Exception can be throw.
**/ **/
public void perform(String fpdFilePath, int messageLevel) public void perform(String fpdFilePath)
throws PlatformPcdPreprocessBuildException { throws PlatformPcdPreprocessBuildException {
this.fpdFilePath = fpdFilePath; this.fpdFilePath = fpdFilePath;
setActionMessageLevel(messageLevel);
checkParameter(); checkParameter();
execute(); execute();
ActionMessage.messageLevel = originalMessageLevel;
} }
/** /**

View File

@ -1,126 +0,0 @@
/** @file
ActionMessage class.
ActionMessage class take over all message for loging and waning. This class should
dispatch message into different class according to instance class type.
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.pcd.action;
import org.apache.tools.ant.Task;
/** ActionMessage class take over all message for loging and waning. This class
should dispatch message into different Action class according to instance
class type.
**/
public class ActionMessage {
///
/// Macro definition for NULL messge level.
/// In this meessage level, all message will be hidden.
///
public final static int NULL_MESSAGE_LEVEL = 0;
///
/// Macro definition for Log messge level.
/// In this message level, Only log information will be shown.
///
public final static int LOG_MESSAGE_LEVEL = 1;
///
/// Macro definition for Warning message level.
/// In this message level, log and waning message will be shown.
///
public final static int WARNING_MESSAGE_LEVEL = 2;
///
/// Macro definition for Debug mesage level.
/// In this message level, log, warning, debug message will be shown.
///
public final static int DEBUG_MESSAGE_LEVEL = 3;
///
/// Macor definition for MAX message level.
/// In this message level, all message will be shown.
///
public final static int MAX_MESSAGE_LEVEL = 4;
///
/// Current message level. It will control all message output for PCD tool.
///
public static int messageLevel = NULL_MESSAGE_LEVEL;
/**
Log() function provide common log information functionality for all
PCD tool includes all function
This function will dispatch message to special class such as BuildAction
Class, Entity Class etc.
@param thisClass The class object who want log information.
@param logStr The string contains log information.
**/
public static void log(Object thisClass, String logStr) {
if(messageLevel < LOG_MESSAGE_LEVEL) {
return;
}
if(thisClass instanceof Task) {
BuildAction.logMsg(thisClass, "$$LOG$$:" + logStr);
} else {
System.out.println("$$LOG$$:" + logStr);
}
}
/**
Warning() function provide common warning information functionality for all
PCD tool.
This function will dispatch message to special class such as BuildAction
Class, Entity Class etc.
@param thisClass The class object who want warn information.
@param warningStr The string contains warning information.
**/
public static void warning(Object thisClass, String warningStr) {
if(messageLevel < WARNING_MESSAGE_LEVEL) {
return;
}
if(thisClass instanceof Task) {
BuildAction.warningMsg(thisClass, "**WARNING**:" + warningStr);
} else {
System.out.println("**WARNING**:" + warningStr);
}
}
/**
Debug() function provide common Debug information functionality for all
PCD tool.
This function will dispatch message to special class such as BuildAction
Class, Entity Class etc.
@param thisClass The class object who want Debug information.
@param debugStr The string contains Debug information.
**/
public static void debug(Object thisClass, String debugStr) {
if(messageLevel < DEBUG_MESSAGE_LEVEL) {
return;
}
if(thisClass instanceof Task) {
BuildAction.logMsg(thisClass, "%%DEBUG%%:" + debugStr);
} else {
System.out.println("%%DEBUG%%:" + debugStr);
}
}
}

View File

@ -44,48 +44,6 @@ public abstract class BuildAction extends Task {
**/ **/
public abstract void performAction() throws BuildActionException; public abstract void performAction() throws BuildActionException;
/**
setMessageLevel function set current message for task instance object.
The message should be restored when this action exit.
@param messageLevel The message level for this action.
**/
public void setMessageLevel(int messageLevel) {
originalMessageLevel = ActionMessage.messageLevel;
ActionMessage.messageLevel = messageLevel;
}
/**
logMsg function provide common log information functionality for all
PCD tool extends from ANT task class.
This function will use the log function in Ant task class.
@param action The class object who want log information.
@param logStr The string contains log information.
**/
public static void logMsg(Object action, String logStr) {
try {
((Task) action).log(logStr, Project.MSG_INFO);
} catch (Exception exp) {
}
}
/**
warningMsg function provide common warning information functionality for all
PCD tool.
This function will dispatch message to special class such as BuildAction
Class, Entity Class etc.
@param action The class object who want warn information.
@param warningStr The string contains warning information.
**/
public static void warningMsg(Object action, String warningStr) {
((Task) action).log(warningStr, Project.MSG_WARN);
}
/** /**
execute function is the main flow for all build action class. execute function is the main flow for all build action class.
@ -99,10 +57,5 @@ public abstract class BuildAction extends Task {
public void execute() throws BuildActionException { public void execute() throws BuildActionException {
checkParameter(); checkParameter();
performAction(); performAction();
//
// Restore orignal message level when exist the action.
//
ActionMessage.messageLevel = originalMessageLevel;
} }
} }