2009-08-09 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Sun, 9 Aug 2009 16:01:18 +0000 (16:01 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sun, 9 Aug 2009 16:01:18 +0000 (16:01 -0000)
* ConsoleLogger.cs: Change the format of the error and warnings
strings to work when invoked inside Emacs by not rendering the
column if available, by using lowercase "error"/"warning" strings
instead of camelcased versions and to not have unnecessary padding.

2009-07-31  Ankit Jain  <jankit@novell.com>

svn path=/trunk/mcs/; revision=139618

mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs

index 476085ab2b3cb0ae96b2adbd0dbfad762a947f1b..9900ef24808dfdca54c688d9f4f0e29e6f2f48ab 100644 (file)
@@ -1,3 +1,10 @@
+2009-08-09  Miguel de Icaza  <miguel@novell.com>
+
+       * ConsoleLogger.cs: Change the format of the error and warnings
+       strings to work when invoked inside Emacs by not rendering the
+       column if available, by using lowercase "error"/"warning" strings
+       instead of camelcased versions and to not have unnecessary padding.
+
 2009-07-31  Ankit Jain  <jankit@novell.com>
 
        * ConsoleLogger.cs: Keep track of all the errors and warnings
index d1919c0c72e8f5061e246e254d595e1f7b2595a3..52740db4423945c07a63d99ca265d984883be8d8 100644 (file)
@@ -261,27 +261,49 @@ namespace Microsoft.Build.BuildEngine {
                public virtual void Shutdown ()
                {
                }
+
+               static bool InEmacs = Environment.GetEnvironmentVariable ("EMACS") == "t";
                
                private string FormatErrorEvent (BuildErrorEventArgs args)
                {
-                       // FIXME: show more complicated args
-                       if (args.LineNumber != 0 && args.ColumnNumber != 0) {
-                               return String.Format ("{0}({1},{2}): {3} Error {4}: {5}", args.File, args.LineNumber, args.ColumnNumber,
-                                       args.Subcategory, args.Code, args.Message);
+                       // For some reason we get an 1-char empty string as Subcategory somtimes.
+                       string subprefix = args.Subcategory == null || args.Subcategory == "" || args.Subcategory == " " ? "" : " ";
+                       string subcat = subprefix == "" ? "" : args.Subcategory;
+                               
+                       if (args.LineNumber != 0){
+                               if (args.ColumnNumber != 0 && !InEmacs) 
+                                       return String.Format ("{0}({1},{2}): {3}{4}error {5}: {6}",
+                                                             args.File, args.LineNumber, args.ColumnNumber,
+                                                             subprefix, subcat, args.Code, args.Message);
+
+                               return String.Format ("{0}({1}): {2}{3}error {4}: {5}",
+                                                     args.File, args.LineNumber,
+                                                     subprefix, subcat, args.Code, args.Message);
                        } else {
-                               return String.Format ("{0}: {1} Error {2}: {3}", args.File, args.Subcategory, args.Code,
+                               return String.Format ("{0}: {1}{2}error {3}: {4}", args.File, subprefix, subcat, args.Code,
                                        args.Message);
                        }
                }
 
                private string FormatWarningEvent (BuildWarningEventArgs args)
                {
+                       // For some reason we get an 1-char empty string as Subcategory somtimes.
+                       string subprefix = args.Subcategory == null || args.Subcategory == "" || args.Subcategory == " " ? "" : " ";
+                       string subcat = subprefix == "" ? "" : args.Subcategory;
+
                        // FIXME: show more complicated args
-                       if (args.LineNumber != 0 && args.ColumnNumber != 0) {
-                               return String.Format ("{0}({1},{2}): {3} Warning {4}: {5}", args.File, args.LineNumber, args.ColumnNumber,
-                                       args.Subcategory, args.Code, args.Message);
+                       if (args.LineNumber != 0){
+
+                               if (args.ColumnNumber != 0 && !InEmacs) {
+                                       return String.Format ("{0}({1},{2}): {3}{4}warning {5}: {6}",
+                                                             args.File, args.LineNumber, args.ColumnNumber,
+                                                             subprefix, subcat, args.Code, args.Message);
+                               }
+                               return String.Format ("{0}({1}): {2}{3}warning {4}: {5}",
+                                                     args.File, args.LineNumber,
+                                                     subprefix, subcat, args.Code, args.Message);
                        } else {
-                               return String.Format ("{0}: {1} Warning {2}: {3}", args.File, args.Subcategory, args.Code,
+                               return String.Format ("{0}: {1} warning {2}: {3}", args.File, args.Subcategory, args.Code,
                                        args.Message);
                        }
                }