Author: nextgens
Date: 2007-02-24 14:45:05 +0000 (Sat, 24 Feb 2007)
New Revision: 11905

Modified:
   trunk/freenet/src/freenet/support/Logger.java
   trunk/freenet/src/freenet/support/LoggerHook.java
Log:
indent

Modified: trunk/freenet/src/freenet/support/Logger.java
===================================================================
--- trunk/freenet/src/freenet/support/Logger.java       2007-02-24 14:44:10 UTC 
(rev 11904)
+++ trunk/freenet/src/freenet/support/Logger.java       2007-02-24 14:45:05 UTC 
(rev 11905)
@@ -4,8 +4,8 @@

 /**
  * @author Iakin
- 
- */
+
+*/
 public abstract class Logger {

        /** These indicate the verbosity levels for calls to log() * */
@@ -24,81 +24,81 @@

        /** Internal occurrances used for eg distribution stats * */
        public static final int INTERNAL = 1;
-       
+
        /**
         * Single global LoggerHook.
         */
        static Logger logger = new VoidLogger();
-       
+
        public synchronized static FileLoggerHook setupStdoutLogging(int level, 
String detail) throws InvalidThresholdException {
-           setupChain();
-           logger.setThreshold(level);
-           logger.setDetailedThresholds(detail);
-           FileLoggerHook fh;
-           fh = new FileLoggerHook(System.out, "d (c, t, p): m", "MMM dd, yyyy 
HH:mm:ss:SSS", level);
-           if(detail != null)
-               fh.setDetailedThresholds(detail);
-           ((LoggerHookChain) logger).addHook(fh);
-           fh.start();
-           return fh;
+               setupChain();
+               logger.setThreshold(level);
+               logger.setDetailedThresholds(detail);
+               FileLoggerHook fh;
+               fh = new FileLoggerHook(System.out, "d (c, t, p): m", "MMM dd, 
yyyy HH:mm:ss:SSS", level);
+               if(detail != null)
+                       fh.setDetailedThresholds(detail);
+               ((LoggerHookChain) logger).addHook(fh);
+               fh.start();
+               return fh;
        }

-    public synchronized static void setupChain() {
-        logger = new LoggerHookChain();
-    }
+       public synchronized static void setupChain() {
+               logger = new LoggerHookChain();
+       }

-    public synchronized static void debug(Object o, String s) {
-           logger.log(o, s, DEBUG);
+       public synchronized static void debug(Object o, String s) {
+               logger.log(o, s, DEBUG);
        }
-       
-    public synchronized static void debug(Object o, String s, Throwable t) {
-        logger.log(o, s, t, DEBUG);
-    }
-    
+
+       public synchronized static void debug(Object o, String s, Throwable t) {
+               logger.log(o, s, t, DEBUG);
+       }
+
        public synchronized static void error(Class c, String s) {
-           logger.log(c, s, ERROR);
+               logger.log(c, s, ERROR);
        }
-       
+
        public synchronized static void error(Object o, String s) {
-           logger.log(o, s, ERROR);
+               logger.log(o, s, ERROR);
        }
-       
+
        public synchronized static void error(Object o, String s, Throwable e) {
-           logger.log(o, s, e, ERROR);
+               logger.log(o, s, e, ERROR);
        }
-       
+
        public synchronized static void minor(Class c, String s) {
                logger.log(c, s, MINOR);
        }
-       
+
        public synchronized static void minor(Object o, String s) {
-           logger.log(o, s, MINOR);
+               logger.log(o, s, MINOR);
        }
-       
+
        public synchronized static void minor(Object o, String s, Throwable t) {
-           logger.log(o, s, t, MINOR);
+               logger.log(o, s, t, MINOR);
        }
-       
-    public synchronized static void minor(Class class1, String string, 
Throwable t) {
-        logger.log(class1, string, t, MINOR);
-    }
-    
+
+       public synchronized static void minor(Class class1, String string, 
Throwable t) {
+               logger.log(class1, string, t, MINOR);
+       }
+
        public synchronized static void normal(Object o, String s) {
-           logger.log(o, s, NORMAL);
+               logger.log(o, s, NORMAL);
        }
-       
+
        public synchronized static void normal(Object o, String s, Throwable t) 
{
-           logger.log(o, s, t, NORMAL);
+               logger.log(o, s, t, NORMAL);
        }
-       
+
        public synchronized static void normal(Class c, String s) {
-           logger.log(c, s, NORMAL);
+               logger.log(c, s, NORMAL);
        }
-       
+
        public synchronized static void logStatic(Object o, String s, int prio) 
{
                logger.log(o, s, prio);
        }
-       
+
        /**
         * Log a message
         * 
@@ -115,64 +115,64 @@
         *            Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
         */
        public abstract void log(
-               Object o,
-               Class source,
-               String message,
-               Throwable e,
-               int priority);
-       
-        /**
-     * Log a message.
-     * @param source        The source object where this message was generated
-     * @param message A clear and verbose message describing the event
-     * @param priority The priority of the mesage, one of Logger.ERROR,
-     *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
-     **/
-    public abstract void log(Object source, String message, int priority);
-    
-    /** 
-     * Log a message with an exception.
-     * @param o   The source object where this message was generated.
-     * @param message  A clear and verbose message describing the event.
-     * @param e        Logs this exception with the message.
-     * @param priority The priority of the mesage, one of Logger.ERROR,
-     *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
-     * @see #log(Object o, String message, int priority)
-     */
-    public abstract void log(Object o, String message, Throwable e, 
-                    int priority);
-    /**
-     * Log a message from static code.
-     * @param c        The class where this message was generated.
-     * @param message  A clear and verbose message describing the event
-     * @param priority The priority of the mesage, one of Logger.ERROR,
-     *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
-     */
-    public abstract void log(Class c, String message, int priority);
+                       Object o,
+                       Class source,
+                       String message,
+                       Throwable e,
+                       int priority);

-    /**
-     * Log a message from static code.
-     * @param c     The class where this message was generated.
-     * @param message A clear and verbose message describing the event
-     * @param e        Logs this exception with the message.
-     * @param priority The priority of the mesage, one of Logger.ERROR,
-     *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
-     */
-    public abstract void log(Class c, String message, Throwable e,
-                    int priority);
-       
+       /**
+        * Log a message.
+        * @param source        The source object where this message was 
generated
+        * @param message A clear and verbose message describing the event
+        * @param priority The priority of the mesage, one of Logger.ERROR,
+        *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
+        **/
+       public abstract void log(Object source, String message, int priority);
+
+       /** 
+        * Log a message with an exception.
+        * @param o   The source object where this message was generated.
+        * @param message  A clear and verbose message describing the event.
+        * @param e        Logs this exception with the message.
+        * @param priority The priority of the mesage, one of Logger.ERROR,
+        *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
+        * @see #log(Object o, String message, int priority)
+        */
+       public abstract void log(Object o, String message, Throwable e, 
+                       int priority);
+       /**
+        * Log a message from static code.
+        * @param c        The class where this message was generated.
+        * @param message  A clear and verbose message describing the event
+        * @param priority The priority of the mesage, one of Logger.ERROR,
+        *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
+        */
+       public abstract void log(Class c, String message, int priority);
+
+       /**
+        * Log a message from static code.
+        * @param c     The class where this message was generated.
+        * @param message A clear and verbose message describing the event
+        * @param e        Logs this exception with the message.
+        * @param priority The priority of the mesage, one of Logger.ERROR,
+        *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
+        */
+       public abstract void log(Class c, String message, Throwable e,
+                       int priority);
+
        public abstract boolean instanceShouldLog(int priority, Class c);
-       
+
        public synchronized static boolean shouldLog(int priority, Class c) {
-           return logger.instanceShouldLog(priority, c);
+               return logger.instanceShouldLog(priority, c);
        }
-       
+
        public static boolean shouldLog(int priority, Object o) {
-           return shouldLog(priority, o.getClass());
+               return shouldLog(priority, o.getClass());
        }

        public abstract boolean instanceShouldLog(int prio, Object o);
-       
+
        /**
         * Changes the priority threshold.
         * 
@@ -180,7 +180,7 @@
         *            The new threshhold
         */
        public abstract void setThreshold(int thresh);
-       
+
        /**
         * Changes the priority threshold.
         * 
@@ -189,39 +189,39 @@
         * @throws InvalidThresholdException 
         */
        public abstract void setThreshold(String symbolicThreshold) throws 
InvalidThresholdException;
-       
+
        /**
         * @return The currently used logging threshold
         */
        public abstract int getThreshold();
-       
+
        public abstract void setDetailedThresholds(String details) throws 
InvalidThresholdException;

-    /**
-     * Report a fatal error and exit.
-     * @param cause the object or class involved
-     * @param retcode the return code
-     * @param message the reason why
-     */
-    public static void fatal(Object cause, int retcode, String message) {
-        error(cause, message);
-        System.exit(retcode);
-    }
+       /**
+        * Report a fatal error and exit.
+        * @param cause the object or class involved
+        * @param retcode the return code
+        * @param message the reason why
+        */
+       public static void fatal(Object cause, int retcode, String message) {
+               error(cause, message);
+               System.exit(retcode);
+       }

-    public synchronized static void globalAddHook(LoggerHook logger2) {
-       if(logger instanceof VoidLogger)
-               setupChain();
-               ((LoggerHookChain)logger).addHook(logger2);
-    }
+       public synchronized static void globalAddHook(LoggerHook logger2) {
+               if(logger instanceof VoidLogger)
+                       setupChain();
+               ((LoggerHookChain)logger).addHook(logger2);
+       }

-    public synchronized static void globalSetThreshold(int i) {
-        logger.setThreshold(i);
-    }
+       public synchronized static void globalSetThreshold(int i) {
+               logger.setThreshold(i);
+       }

        public synchronized static int globalGetThreshold() {
                return logger.getThreshold();
        }
-       
+
        public synchronized static void globalRemoveHook(FileLoggerHook hook) {
                if(logger instanceof LoggerHookChain)
                        ((LoggerHookChain)logger).removeHook(hook);

Modified: trunk/freenet/src/freenet/support/LoggerHook.java
===================================================================
--- trunk/freenet/src/freenet/support/LoggerHook.java   2007-02-24 14:44:10 UTC 
(rev 11904)
+++ trunk/freenet/src/freenet/support/LoggerHook.java   2007-02-24 14:45:05 UTC 
(rev 11905)
@@ -15,11 +15,11 @@
                        this.dThreshold = thresh;
                }
        }
-       
+
        LoggerHook(int thresh){
                this.threshold = thresh;
        }
-       
+
        LoggerHook(String thresh) throws InvalidThresholdException{
                this.threshold = priorityOf(thresh);
        }
@@ -42,53 +42,53 @@
         *            Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
         */
        public abstract void log(
-               Object o,
-               Class source,
-               String message,
-               Throwable e,
-               int priority);
-       
-        /**
-     * Log a message.
-     * @param source        The source object where this message was generated
-     * @param message A clear and verbose message describing the event
-     * @param priority The priority of the mesage, one of Logger.ERROR,
-     *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
-     **/
-    public void log(Object source, String message, int priority) {
-        if (!instanceShouldLog(priority,source)) return;
-        log(source, source == null ? null : source.getClass(), 
-            message, null, priority);
-    }
+                       Object o,
+                       Class source,
+                       String message,
+                       Throwable e,
+                       int priority);

-    /** 
-     * Log a message with an exception.
-     * @param o   The source object where this message was generated.
-     * @param message  A clear and verbose message describing the event.
-     * @param e        Logs this exception with the message.
-     * @param priority The priority of the mesage, one of Logger.ERROR,
-     *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
-     * @see #log(Object o, String message, int priority)
-     */
-    public void log(Object o, String message, Throwable e, 
-                    int priority) {
-        if (!instanceShouldLog(priority,o)) return;
-        log(o, o == null ? null : o.getClass(), message, e, priority);
-    }
+       /**
+        * Log a message.
+        * @param source        The source object where this message was 
generated
+        * @param message A clear and verbose message describing the event
+        * @param priority The priority of the mesage, one of Logger.ERROR,
+        *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
+        **/
+       public void log(Object source, String message, int priority) {
+               if (!instanceShouldLog(priority,source)) return;
+               log(source, source == null ? null : source.getClass(), 
+                               message, null, priority);
+       }

-    /**
-     * Log a message from static code.
-     * @param c        The class where this message was generated.
-     * @param message  A clear and verbose message describing the event
-     * @param priority The priority of the mesage, one of Logger.ERROR,
-     *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
-     */
-    public void log(Class c, String message, int priority) {
-        if (!instanceShouldLog(priority,c)) return;
-        log(null, c, message, null, priority);
-    }
+       /** 
+        * Log a message with an exception.
+        * @param o   The source object where this message was generated.
+        * @param message  A clear and verbose message describing the event.
+        * @param e        Logs this exception with the message.
+        * @param priority The priority of the mesage, one of Logger.ERROR,
+        *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
+        * @see #log(Object o, String message, int priority)
+        */
+       public void log(Object o, String message, Throwable e, 
+                       int priority) {
+               if (!instanceShouldLog(priority,o)) return;
+               log(o, o == null ? null : o.getClass(), message, e, priority);
+       }

+       /**
+        * Log a message from static code.
+        * @param c        The class where this message was generated.
+        * @param message  A clear and verbose message describing the event
+        * @param priority The priority of the mesage, one of Logger.ERROR,
+        *                 Logger.NORMAL, Logger.MINOR, or Logger.DEBUGGING.
+        */
+       public void log(Class c, String message, int priority) {
+               if (!instanceShouldLog(priority,c)) return;
+               log(null, c, message, null, priority);
+       }

+
        public void log(Class c, String message, Throwable e, int priority) {
                if (!instanceShouldLog(priority, c))
                        return;
@@ -102,7 +102,7 @@
        public void setThreshold(int thresh) {
                this.threshold = thresh;
        }
-       
+
        public int getThreshold() {
                return threshold;
        }
@@ -147,51 +147,51 @@
                }
                return sb.toString();
        }
-       
-    /**
-     * Returns the priority level matching the string. If no priority
-     * matches, Logger.NORMAL is returned.
-     * @param s  A string matching one of the logging priorities, case
-     *           insensitive.
-     **/
-    public static int priorityOf(String s) throws InvalidThresholdException {
-        if (s.equalsIgnoreCase("error"))
-            return Logger.ERROR;
-        else if (s.equalsIgnoreCase("normal"))
-            return Logger.NORMAL;
-        else if (s.equalsIgnoreCase("minor"))
-            return Logger.MINOR;
-        else if (s.equalsIgnoreCase("debugging"))
-            return Logger.DEBUG;
-        else if (s.equalsIgnoreCase("debug"))
-            return Logger.DEBUG;
-        else
-               throw new InvalidThresholdException("Unrecognized priority: 
"+s);
-        // return Logger.NORMAL;
-    }
-    
-    public static class InvalidThresholdException extends Exception {
-       private static final long serialVersionUID = -1;
-       
-       InvalidThresholdException(String msg) {
-               super(msg);
-       }
-    }
-    
-    /**
-     * Returns the name of the priority matching a number, null if none do
-     * @param priority  The priority
-     */
-    public static String priorityOf(int priority) {
-        switch (priority) {
-            case ERROR:     return "ERROR";
-            case NORMAL:    return "NORMAL";
-            case MINOR:     return "MINOR";
-            case DEBUG:     return "DEBUG";
-            default:        return null;
-        }
-    }

+       /**
+        * Returns the priority level matching the string. If no priority
+        * matches, Logger.NORMAL is returned.
+        * @param s  A string matching one of the logging priorities, case
+        *           insensitive.
+        **/
+       public static int priorityOf(String s) throws InvalidThresholdException 
{
+               if (s.equalsIgnoreCase("error"))
+                       return Logger.ERROR;
+               else if (s.equalsIgnoreCase("normal"))
+                       return Logger.NORMAL;
+               else if (s.equalsIgnoreCase("minor"))
+                       return Logger.MINOR;
+               else if (s.equalsIgnoreCase("debugging"))
+                       return Logger.DEBUG;
+               else if (s.equalsIgnoreCase("debug"))
+                       return Logger.DEBUG;
+               else
+                       throw new InvalidThresholdException("Unrecognized 
priority: "+s);
+               // return Logger.NORMAL;
+       }
+
+       public static class InvalidThresholdException extends Exception {
+               private static final long serialVersionUID = -1;
+
+               InvalidThresholdException(String msg) {
+                       super(msg);
+               }
+       }
+
+       /**
+        * Returns the name of the priority matching a number, null if none do
+        * @param priority  The priority
+        */
+       public static String priorityOf(int priority) {
+               switch (priority) {
+                       case ERROR:     return "ERROR";
+                       case NORMAL:    return "NORMAL";
+                       case MINOR:     return "MINOR";
+                       case DEBUG:     return "DEBUG";
+                       default:        return null;
+               }
+       }
+
        public boolean instanceShouldLog(int priority, Class c) {
                int thresh = threshold;
                if ((c != null) && (detailedThresholds.length != 0)) {
@@ -209,8 +209,8 @@
        public final boolean instanceShouldLog(int prio, Object o) {
                return instanceShouldLog(prio, o == null ? null : o.getClass());
        }
-       

+
        public abstract long minFlags(); // ignore unless all these bits set

        public abstract long notFlags(); // reject if any of these bits set


Reply via email to