]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java
Add two definitions to ToolDefinitions. Enhance EdkLog and GenBuildLogger. GenBuildLo...
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / GenBuildLogger.java
index e1bafd668a778476c8c90670f84cbf6c7b8aa9a6..9bc3f2d176a80d91e889a2c9ccf475bfde4327b4 100644 (file)
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
+ Copyright (c) 2006, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution.  The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
 GenBuildLogger.java\r
+ Module Name:\r
+ GenBuildLogger.java\r
 \r
-Abstract:\r
+ Abstract:\r
 \r
---*/\r
+ --*/\r
 \r
 package org.tianocore.build.global;\r
 \r
+import java.io.File;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
 import org.apache.tools.ant.Project;\r
 \r
+import org.tianocore.common.logger.EdkLog;\r
 import org.tianocore.common.logger.LogMethod;\r
 \r
 public class GenBuildLogger implements LogMethod {\r
-    private Project project;\r
-    public GenBuildLogger(Project project) {\r
+    private Project project = null;\r
+\r
+    ///\r
+    /// flag to present whether cache all msg or not\r
+    /// true means not to cache.\r
+    ///\r
+    private boolean flag = true;\r
+\r
+    private List<String> v = null;\r
+\r
+    public GenBuildLogger (Project project) {\r
+        this.project = project;\r
+    }\r
+\r
+    public GenBuildLogger (Project project, boolean flag) {\r
         this.project = project;\r
+        this.flag = flag;\r
 \r
+        //\r
+        // Only flag is false, v will be initialized and used.\r
+        //\r
+        if (!flag) {\r
+            v = new Vector<String>(2048);\r
+        }\r
     }\r
 \r
-    public void putMessage(Object msgSource, int msgLevel, String msg) {\r
-        if (this.project != null){\r
+    /**\r
+      Rules: flag = true: means no cache Action: Print it to console\r
+      \r
+      flag = false: mean cache all msg exception some special Action: loglevel\r
+      is EDK_ALWAYS -- Print but no cache loglevel is EDK_ERROR -- Print and\r
+      cache the msg others -- No print and cache the msg\r
+    **/\r
+    public synchronized void putMessage(Object msgSource, int msgLevel,\r
+                    String msg) {\r
+        if (this.project == null) {\r
+            return;\r
+        }\r
+\r
+        //\r
+        // If msgLevel is always print, then print it\r
+        //\r
+        switch (msgLevel) {\r
+        case EdkLog.EDK_ALWAYS:\r
             this.project.log(msg, Project.MSG_INFO);\r
+            break;\r
+        case EdkLog.EDK_ERROR:\r
+            if (flag) {\r
+                this.project.log(msg, Project.MSG_ERR);\r
+            } else {\r
+                this.project.log(msg, Project.MSG_ERR);\r
+                v.add(msg);\r
+            }\r
+            break;\r
+        case EdkLog.EDK_WARNING:\r
+            if (flag) {\r
+                this.project.log(msg, Project.MSG_WARN);\r
+            } else {\r
+                v.add(msg);\r
+            }\r
+            break;\r
+        case EdkLog.EDK_INFO:\r
+            if (flag) {\r
+                this.project.log(msg, Project.MSG_INFO);\r
+            } else {\r
+                v.add(msg);\r
+            }\r
+            break;\r
+        case EdkLog.EDK_VERBOSE:\r
+            if (flag) {\r
+                this.project.log(msg, Project.MSG_VERBOSE);\r
+            } else {\r
+                v.add(msg);\r
+            }\r
+            break;\r
+        case EdkLog.EDK_DEBUG:\r
+            if (flag) {\r
+                this.project.log(msg, Project.MSG_DEBUG);\r
+            } else {\r
+                v.add(msg);\r
+            }\r
+            break;\r
         }\r
+    }\r
+\r
+    public void flushToFile(File file) {\r
+        //\r
+        // Sort msg and store to the file (TBD)\r
+        //\r
 \r
     }\r
 }
\ No newline at end of file