ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1056040 - /ant/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java
Date Thu, 06 Jan 2011 19:49:15 GMT
Author: hibou
Date: Thu Jan  6 19:49:14 2011
New Revision: 1056040

URL: http://svn.apache.org/viewvc?rev=1056040&view=rev
Log:
Add a generic function to log

Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java?rev=1056040&r1=1056039&r2=1056040&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java Thu Jan  6 19:49:14 2011
@@ -49,13 +49,13 @@ public final class Message {
     /** Message priority of "debug". */
     public static final int MSG_DEBUG = 4;
 
-
     private static boolean showedInfo = false;
 
     private static MessageLogger defaultLogger = new DefaultMessageLogger(Message.MSG_INFO);
 
     /**
      * Returns the current default logger.
+     * 
      * @return the current default logger; is never <code>null</code>.
      */
     public static MessageLogger getDefaultLogger() {
@@ -64,7 +64,9 @@ public final class Message {
 
     /**
      * Change the default logger used when no other logger is currently configured
-     * @param logger the new default logger, must not be <code>null</code>
+     * 
+     * @param logger
+     *            the new default logger, must not be <code>null</code>
      */
     public static void setDefaultLogger(MessageLogger logger) {
         Checks.checkNotNull(logger, "logger");
@@ -111,6 +113,28 @@ public final class Message {
         getLogger().error(msg);
     }
 
+    public static void log(int logLevel, String msg) {
+        switch (logLevel) {
+            case MSG_DEBUG:
+                debug(msg);
+                break;
+            case MSG_VERBOSE:
+                verbose(msg);
+                break;
+            case MSG_INFO:
+                info(msg);
+                break;
+            case MSG_WARN:
+                warn(msg);
+                break;
+            case MSG_ERR:
+                error(msg);
+                break;
+            default:
+                throw new IllegalArgumentException("Unknown log level " + logLevel);
+        }
+    }
+
     public static List getProblems() {
         return getLogger().getProblems();
     }



Mime
View raw message