Started refactoring the Log system to use java.util.logging classes.
authorcli
Thu, 20 Aug 2009 18:41:21 +0200
changeset 15f2293e8566f5
parent 14 efce4ec25564
child 16 5a4a41cfc0a3
Started refactoring the Log system to use java.util.logging classes.
org/sonews/Main.java
org/sonews/config/BackendConfig.java
org/sonews/config/Config.java
org/sonews/daemon/AbstractDaemon.java
org/sonews/daemon/ChannelReader.java
org/sonews/daemon/ChannelWriter.java
org/sonews/daemon/CommandSelector.java
org/sonews/daemon/ConnectionWorker.java
org/sonews/daemon/Connections.java
org/sonews/daemon/NNTPConnection.java
org/sonews/daemon/NNTPDaemon.java
org/sonews/daemon/command/OverCommand.java
org/sonews/daemon/command/PostCommand.java
org/sonews/feed/PullFeeder.java
org/sonews/feed/PushFeeder.java
org/sonews/util/Log.java
     1.1 --- a/org/sonews/Main.java	Thu Aug 20 16:57:38 2009 +0200
     1.2 +++ b/org/sonews/Main.java	Thu Aug 20 18:41:21 2009 +0200
     1.3 @@ -48,7 +48,7 @@
     1.4    }
     1.5  
     1.6    /** Version information of the sonews daemon */
     1.7 -  public static final String VERSION = "sonews/1.0.0";
     1.8 +  public static final String VERSION = "sonews/1.1.0";
     1.9    public static final Date   STARTDATE = new Date();
    1.10    
    1.11    /**
    1.12 @@ -120,7 +120,7 @@
    1.13        if(!StorageManager.current().isGroupExisting("control"))
    1.14        {
    1.15          StorageManager.current().addGroup("control", 0);
    1.16 -        Log.msg("Group 'control' created.", true);
    1.17 +        Log.get().info("Group 'control' created.");
    1.18        }
    1.19      }
    1.20      catch(StorageBackendException ex)
     2.1 --- a/org/sonews/config/BackendConfig.java	Thu Aug 20 16:57:38 2009 +0200
     2.2 +++ b/org/sonews/config/BackendConfig.java	Thu Aug 20 18:41:21 2009 +0200
     2.3 @@ -18,6 +18,7 @@
     2.4  
     2.5  package org.sonews.config;
     2.6  
     2.7 +import java.util.logging.Level;
     2.8  import org.sonews.util.Log;
     2.9  import org.sonews.storage.StorageBackendException;
    2.10  import org.sonews.storage.StorageManager;
    2.11 @@ -64,7 +65,7 @@
    2.12        {
    2.13          if(StorageManager.current() == null)
    2.14          {
    2.15 -          Log.msg("Warning: BackendConfig not available, using default.", false);
    2.16 +          Log.get().warning("BackendConfig not available, using default.");
    2.17            return defaultValue;
    2.18          }
    2.19  
    2.20 @@ -86,7 +87,7 @@
    2.21      }
    2.22      catch(StorageBackendException ex)
    2.23      {
    2.24 -      Log.msg(ex.getMessage(), false);
    2.25 +      Log.get().log(Level.SEVERE, "Storage backend problem", ex);
    2.26        return defaultValue;
    2.27      }
    2.28    }
     3.1 --- a/org/sonews/config/Config.java	Thu Aug 20 16:57:38 2009 +0200
     3.2 +++ b/org/sonews/config/Config.java	Thu Aug 20 18:41:21 2009 +0200
     3.3 @@ -42,6 +42,7 @@
     3.4    public static final String HOSTNAME          = "sonews.hostname";
     3.5    public static final String PORT              = "sonews.port";
     3.6    public static final String TIMEOUT           = "sonews.timeout";
     3.7 +  public static final String LOGLEVEL          = "sonews.loglevel";
     3.8    public static final String MLPOLL_DELETEUNKNOWN = "sonews.mlpoll.deleteunknown";
     3.9    public static final String MLPOLL_HOST       = "sonews.mlpoll.host";
    3.10    public static final String MLPOLL_PASSWORD   = "sonews.mlpoll.password";
     4.1 --- a/org/sonews/daemon/AbstractDaemon.java	Thu Aug 20 16:57:38 2009 +0200
     4.2 +++ b/org/sonews/daemon/AbstractDaemon.java	Thu Aug 20 18:41:21 2009 +0200
     4.3 @@ -81,7 +81,7 @@
     4.4      }
     4.5      catch(SQLException ex)
     4.6      {
     4.7 -      Log.msg(ex, true);
     4.8 +      Log.get().warning(ex.toString());
     4.9      }
    4.10    }
    4.11    
     5.1 --- a/org/sonews/daemon/ChannelReader.java	Thu Aug 20 16:57:38 2009 +0200
     5.2 +++ b/org/sonews/daemon/ChannelReader.java	Thu Aug 20 18:41:21 2009 +0200
     5.3 @@ -26,6 +26,7 @@
     5.4  import java.nio.channels.SocketChannel;
     5.5  import java.util.Iterator;
     5.6  import java.util.Set;
     5.7 +import java.util.logging.Level;
     5.8  import org.sonews.util.Log;
     5.9  
    5.10  /**
    5.11 @@ -130,11 +131,8 @@
    5.12        }
    5.13        catch(CancelledKeyException ex)
    5.14        {
    5.15 -        Log.msg("ChannelReader.run(): " + ex, false);
    5.16 -        if(Log.isDebug())
    5.17 -        {
    5.18 -          ex.printStackTrace();
    5.19 -        }
    5.20 +        Log.get().warning("ChannelReader.run(): " + ex);
    5.21 +        Log.get().log(Level.INFO, "", ex);
    5.22        }
    5.23        catch(Exception ex)
    5.24        {
    5.25 @@ -177,15 +175,11 @@
    5.26          {
    5.27            // The connection was probably closed by the remote host
    5.28            // in a non-clean fashion
    5.29 -          Log.msg("ChannelReader.processSelectionKey(): " + ex, true);
    5.30 +          Log.get().info("ChannelReader.processSelectionKey(): " + ex);
    5.31          }
    5.32          catch(Exception ex) 
    5.33          {
    5.34 -          Log.msg("ChannelReader.processSelectionKey(): " + ex, false);
    5.35 -          if(Log.isDebug())
    5.36 -          {
    5.37 -            ex.printStackTrace();
    5.38 -          }
    5.39 +          Log.get().warning("ChannelReader.processSelectionKey(): " + ex);
    5.40          }
    5.41          
    5.42          if(read == -1) // End of stream
    5.43 @@ -201,7 +195,7 @@
    5.44      else
    5.45      {
    5.46        // Should not happen
    5.47 -      Log.msg(selKey, false);
    5.48 +      Log.get().severe("Should not happen: " + selKey.toString());
    5.49      }
    5.50    }
    5.51    
     6.1 --- a/org/sonews/daemon/ChannelWriter.java	Thu Aug 20 16:57:38 2009 +0200
     6.2 +++ b/org/sonews/daemon/ChannelWriter.java	Thu Aug 20 18:41:21 2009 +0200
     6.3 @@ -123,7 +123,7 @@
     6.4            }
     6.5            catch (IOException ex)
     6.6            {
     6.7 -            Log.msg("Error writing to channel: " + ex, false);
     6.8 +            Log.get().warning("Error writing to channel: " + ex);
     6.9  
    6.10              // Cancel write events for this channel
    6.11              selKey.cancel();
    6.12 @@ -137,7 +137,7 @@
    6.13        }
    6.14        catch(CancelledKeyException ex)
    6.15        {
    6.16 -        Log.msg("ChannelWriter.run(): " + ex, true);
    6.17 +        Log.get().info("ChannelWriter.run(): " + ex);
    6.18        }
    6.19        catch(Exception ex)
    6.20        {
    6.21 @@ -192,14 +192,14 @@
    6.22      }
    6.23      else
    6.24      {
    6.25 -      Log.msg("Invalid OP_WRITE key: " + selKey, false);
    6.26 +      Log.get().warning("Invalid OP_WRITE key: " + selKey);
    6.27  
    6.28 -      if (socketChannel.socket().isClosed())
    6.29 +      if(socketChannel.socket().isClosed())
    6.30        {
    6.31          connection.shutdownInput();
    6.32          connection.shutdownOutput();
    6.33          socketChannel.close();
    6.34 -        Log.msg("Connection closed.", true);
    6.35 +        Log.get().info("Connection closed.");
    6.36        }
    6.37      }
    6.38    }
     7.1 --- a/org/sonews/daemon/CommandSelector.java	Thu Aug 20 16:57:38 2009 +0200
     7.2 +++ b/org/sonews/daemon/CommandSelector.java	Thu Aug 20 18:41:21 2009 +0200
     7.3 @@ -73,15 +73,15 @@
     7.4        }
     7.5        catch(ClassNotFoundException ex)
     7.6        {
     7.7 -        Log.msg("Could not load command class: " + ex, false);
     7.8 +        Log.get().warning("Could not load command class: " + ex);
     7.9        }
    7.10        catch(InstantiationException ex)
    7.11        {
    7.12 -        Log.msg("Could not instantiate command class: " + ex, false);
    7.13 +        Log.get().severe("Could not instantiate command class: " + ex);
    7.14        }
    7.15        catch(IllegalAccessException ex)
    7.16        {
    7.17 -        Log.msg("Could not access command class: " + ex, false);
    7.18 +        Log.get().severe("Could not access command class: " + ex);
    7.19        }
    7.20      }
    7.21    }
     8.1 --- a/org/sonews/daemon/ConnectionWorker.java	Thu Aug 20 16:57:38 2009 +0200
     8.2 +++ b/org/sonews/daemon/ConnectionWorker.java	Thu Aug 20 18:41:21 2009 +0200
     8.3 @@ -89,11 +89,11 @@
     8.4        }
     8.5        catch(InterruptedException ex)
     8.6        {
     8.7 -        Log.msg("ConnectionWorker interrupted: " + ex, true);
     8.8 +        Log.get().info("ConnectionWorker interrupted: " + ex);
     8.9        }
    8.10        catch(Exception ex)
    8.11        {
    8.12 -        Log.msg("Exception in ConnectionWorker: " + ex, false);
    8.13 +        Log.get().severe("Exception in ConnectionWorker: " + ex);
    8.14          ex.printStackTrace();
    8.15        }
    8.16      } // end while(isRunning())
     9.1 --- a/org/sonews/daemon/Connections.java	Thu Aug 20 16:57:38 2009 +0200
     9.2 +++ b/org/sonews/daemon/Connections.java	Thu Aug 20 18:41:21 2009 +0200
     9.3 @@ -147,12 +147,12 @@
     9.4              {
     9.5                // Close the channel; implicitely cancels all selectionkeys
     9.6                channel.close();
     9.7 -              Log.msg("Disconnected: " + channel.socket().getRemoteSocketAddress() +
     9.8 -                " (timeout)", true);
     9.9 +              Log.get().info("Disconnected: " + channel.socket().getRemoteSocketAddress() +
    9.10 +                " (timeout)");
    9.11              }
    9.12              catch(IOException ex)
    9.13              {
    9.14 -              Log.msg("Connections.run(): " + ex, false);
    9.15 +              Log.get().warning("Connections.run(): " + ex);
    9.16              }
    9.17  
    9.18              // Recycle the used buffers
    9.19 @@ -169,7 +169,7 @@
    9.20        }
    9.21        catch(InterruptedException ex)
    9.22        {
    9.23 -        Log.msg("Connections Thread was interrupted: " + ex.getMessage(), false);
    9.24 +        Log.get().warning("Connections Thread was interrupted: " + ex.getMessage());
    9.25        }
    9.26      }
    9.27    }
    10.1 --- a/org/sonews/daemon/NNTPConnection.java	Thu Aug 20 16:57:38 2009 +0200
    10.2 +++ b/org/sonews/daemon/NNTPConnection.java	Thu Aug 20 18:41:21 2009 +0200
    10.3 @@ -166,11 +166,7 @@
    10.4      }
    10.5      catch(IOException ex)
    10.6      {
    10.7 -      Log.msg("Exception in NNTPConnection.shutdownInput(): " + ex, false);
    10.8 -      if(Log.isDebug())
    10.9 -      {
   10.10 -        ex.printStackTrace();
   10.11 -      }
   10.12 +      Log.get().warning("Exception in NNTPConnection.shutdownInput(): " + ex);
   10.13      }
   10.14    }
   10.15    
   10.16 @@ -190,15 +186,11 @@
   10.17          catch(SocketException ex)
   10.18          {
   10.19            // Socket was already disconnected
   10.20 -          Log.msg("NNTPConnection.shutdownOutput(): " + ex, true);
   10.21 +          Log.get().info("NNTPConnection.shutdownOutput(): " + ex);
   10.22          }
   10.23          catch(Exception ex)
   10.24          {
   10.25 -          Log.msg("NNTPConnection.shutdownOutput(): " + ex, false);
   10.26 -          if(Log.isDebug())
   10.27 -          {
   10.28 -            ex.printStackTrace();
   10.29 -          }
   10.30 +          Log.get().warning("NNTPConnection.shutdownOutput(): " + ex);
   10.31          }
   10.32        }
   10.33      }, 3000);
   10.34 @@ -272,7 +264,7 @@
   10.35        raw  = Arrays.copyOf(raw, raw.length - 1);
   10.36      }
   10.37      
   10.38 -    Log.msg("<< " + line, true);
   10.39 +    Log.get().fine("<< " + line);
   10.40      
   10.41      if(command == null)
   10.42      {
   10.43 @@ -289,8 +281,8 @@
   10.44      {
   10.45        try
   10.46        {
   10.47 -        Log.msg("Connection to " + channel.socket().getRemoteSocketAddress() 
   10.48 -            + " closed: " + ex0, true);
   10.49 +        Log.get().info("Connection to " + channel.socket().getRemoteSocketAddress()
   10.50 +            + " closed: " + ex0);
   10.51        }
   10.52        catch(Exception ex0a)
   10.53        {
   10.54 @@ -367,7 +359,7 @@
   10.55    {
   10.56      if(!charset.canEncode())
   10.57      {
   10.58 -      Log.msg("FATAL: Charset " + charset + " cannot encode!", false);
   10.59 +      Log.get().severe("FATAL: Charset " + charset + " cannot encode!");
   10.60        return;
   10.61      }
   10.62      
   10.63 @@ -386,9 +378,9 @@
   10.64        this.writeSelKey.interestOps(SelectionKey.OP_WRITE);
   10.65        ChannelWriter.getInstance().getSelector().wakeup();
   10.66      }
   10.67 -    catch (Exception ex) // CancelledKeyException and ChannelCloseException
   10.68 +    catch(Exception ex) // CancelledKeyException and ChannelCloseException
   10.69      {
   10.70 -      Log.msg("NNTPConnection.writeToChannel(): " + ex, false);
   10.71 +      Log.get().warning("NNTPConnection.writeToChannel(): " + ex);
   10.72        return;
   10.73      }
   10.74  
   10.75 @@ -396,7 +388,7 @@
   10.76      this.lastActivity = System.currentTimeMillis();
   10.77      if(debugLine != null)
   10.78      {
   10.79 -      Log.msg(">> " + debugLine, true);
   10.80 +      Log.get().fine(">> " + debugLine);
   10.81      }
   10.82    }
   10.83    
    11.1 --- a/org/sonews/daemon/NNTPDaemon.java	Thu Aug 20 16:57:38 2009 +0200
    11.2 +++ b/org/sonews/daemon/NNTPDaemon.java	Thu Aug 20 18:41:21 2009 +0200
    11.3 @@ -61,7 +61,7 @@
    11.4    
    11.5    private NNTPDaemon(final int port)
    11.6    {
    11.7 -    Log.msg("Server listening on port " + port, false);
    11.8 +    Log.get().info("Server listening on port " + port);
    11.9      this.port = port;
   11.10    }
   11.11  
   11.12 @@ -113,8 +113,8 @@
   11.13            // Under heavy load an IOException "Too many open files may
   11.14            // be thrown. It most cases we should slow down the connection
   11.15            // accepting, to give the worker threads some time to process work.
   11.16 -          Log.msg("IOException while accepting connection: " + ex.getMessage(), false);
   11.17 -          Log.msg("Connection accepting sleeping for seconds...", true);
   11.18 +          Log.get().severe("IOException while accepting connection: " + ex.getMessage());
   11.19 +          Log.get().info("Connection accepting sleeping for seconds...");
   11.20            Thread.sleep(5000); // 5 seconds
   11.21            continue;
   11.22          }
   11.23 @@ -127,7 +127,7 @@
   11.24          }
   11.25          catch(IOException ex)
   11.26          {
   11.27 -          Log.msg(ex.getLocalizedMessage(), false);
   11.28 +          Log.get().warning(ex.toString());
   11.29            socketChannel.close();
   11.30            continue;
   11.31          }
   11.32 @@ -138,7 +138,7 @@
   11.33              registerSelector(writeSelector, socketChannel, SelectionKey.OP_WRITE);
   11.34            registerSelector(readSelector, socketChannel, SelectionKey.OP_READ);
   11.35            
   11.36 -          Log.msg("Connected: " + socketChannel.socket().getRemoteSocketAddress(), true);
   11.37 +          Log.get().info("Connected: " + socketChannel.socket().getRemoteSocketAddress());
   11.38  
   11.39            // Set write selection key and send hello to client
   11.40            conn.setWriteSelectionKey(selKeyWrite);
   11.41 @@ -147,13 +147,13 @@
   11.42          }
   11.43          catch(CancelledKeyException cke)
   11.44          {
   11.45 -          Log.msg("CancelledKeyException " + cke.getMessage() + " was thrown: " 
   11.46 -            + socketChannel.socket(), false);
   11.47 +          Log.get().warning("CancelledKeyException " + cke.getMessage() + " was thrown: "
   11.48 +            + socketChannel.socket());
   11.49          }
   11.50          catch(ClosedChannelException cce)
   11.51          {
   11.52 -          Log.msg("ClosedChannelException " + cce.getMessage() + " was thrown: " 
   11.53 -            + socketChannel.socket(), false);
   11.54 +          Log.get().warning("ClosedChannelException " + cce.getMessage() + " was thrown: "
   11.55 +            + socketChannel.socket());
   11.56          }
   11.57        }
   11.58      }
    12.1 --- a/org/sonews/daemon/command/OverCommand.java	Thu Aug 20 16:57:38 2009 +0200
    12.2 +++ b/org/sonews/daemon/command/OverCommand.java	Thu Aug 20 18:41:21 2009 +0200
    12.3 @@ -168,7 +168,7 @@
    12.4            }
    12.5            catch(NumberFormatException e) 
    12.6            {
    12.7 -            Log.msg(e.getMessage(), true);
    12.8 +            Log.get().info(e.getMessage());
    12.9              artStart = Integer.parseInt(command[1]);
   12.10            }
   12.11          }
    13.1 --- a/org/sonews/daemon/command/PostCommand.java	Thu Aug 20 16:57:38 2009 +0200
    13.2 +++ b/org/sonews/daemon/command/PostCommand.java	Thu Aug 20 18:41:21 2009 +0200
    13.3 @@ -226,7 +226,7 @@
    13.4        default:
    13.5        {
    13.6          // Should never happen
    13.7 -        Log.msg("PostCommand::processLine(): already finished...", false);
    13.8 +        Log.get().severe("PostCommand::processLine(): already finished...");
    13.9        }
   13.10      }
   13.11    }
   13.12 @@ -252,7 +252,7 @@
   13.13        }
   13.14        catch(StorageBackendException ex)
   13.15        {
   13.16 -        Log.msg(ex, false);
   13.17 +        Log.get().severe(ex.toString());
   13.18          conn.println("500 internal server error");
   13.19        }
   13.20      }
   13.21 @@ -274,7 +274,7 @@
   13.22      }
   13.23      catch(StorageBackendException ex)
   13.24      {
   13.25 -      Log.msg(ex, false);
   13.26 +      Log.get().severe(ex.toString());
   13.27        conn.println("500 internal server error");
   13.28      }
   13.29    }
   13.30 @@ -338,7 +338,7 @@
   13.31        }
   13.32        catch(AddressException ex)
   13.33        {
   13.34 -        Log.msg(ex.getMessage(), true);
   13.35 +        Log.get().warning(ex.getMessage());
   13.36          conn.println("441 invalid sender address");
   13.37        }
   13.38        catch(MessagingException ex)
    14.1 --- a/org/sonews/feed/PullFeeder.java	Thu Aug 20 16:57:38 2009 +0200
    14.2 +++ b/org/sonews/feed/PullFeeder.java	Thu Aug 20 18:41:21 2009 +0200
    14.3 @@ -163,7 +163,7 @@
    14.4        String host = "localhost";
    14.5        int    port = 119;
    14.6        
    14.7 -      Log.msg("Start PullFeeder run...", true);
    14.8 +      Log.get().info("Start PullFeeder run...");
    14.9  
   14.10        try
   14.11        {
   14.12 @@ -174,14 +174,14 @@
   14.13  
   14.14            try
   14.15            {
   14.16 -            Log.msg("Feeding " + sub.getGroup() + " from " + sub.getHost(), true);
   14.17 +            Log.get().info("Feeding " + sub.getGroup() + " from " + sub.getHost());
   14.18              try
   14.19              {
   14.20                connectTo(host, port);
   14.21              }
   14.22              catch(SocketException ex)
   14.23              {
   14.24 -              Log.msg("Skipping " + sub.getHost() + ": " + ex, false);
   14.25 +              Log.get().info("Skipping " + sub.getHost() + ": " + ex);
   14.26                continue;
   14.27              }
   14.28              
   14.29 @@ -202,13 +202,14 @@
   14.30                      ArticleReader aread =
   14.31                        new ArticleReader(sub.getHost(), sub.getPort(), messageID);
   14.32                      byte[] abuf = aread.getArticleData();
   14.33 -                    if (abuf == null)
   14.34 +                    if(abuf == null)
   14.35                      {
   14.36 -                      Log.msg("Could not feed " + messageID + " from " + sub.getHost(), true);
   14.37 +                      Log.get().warning("Could not feed " + messageID
   14.38 +                        + " from " + sub.getHost());
   14.39                      }
   14.40                      else
   14.41                      {
   14.42 -                      Log.msg("Feeding " + messageID, true);
   14.43 +                      Log.get().info("Feeding " + messageID);
   14.44                        ArticleWriter awrite = new ArticleWriter(
   14.45                          "localhost", Config.inst().get(Config.PORT, 119));
   14.46                        awrite.writeArticle(abuf);
   14.47 @@ -220,7 +221,7 @@
   14.48                    {
   14.49                      // There may be a temporary network failure
   14.50                      ex.printStackTrace();
   14.51 -                    Log.msg("Skipping mail " + messageID + " due to exception.", false);
   14.52 +                    Log.get().warning("Skipping mail " + messageID + " due to exception.");
   14.53                    }
   14.54                  }
   14.55                } // for(;;)
   14.56 @@ -236,16 +237,16 @@
   14.57            catch(IOException ex)
   14.58            {
   14.59              ex.printStackTrace();
   14.60 -            Log.msg("PullFeeder run stopped due to exception.", false);
   14.61 +            Log.get().severe("PullFeeder run stopped due to exception.");
   14.62            }
   14.63          } // for(Subscription sub : subscriptions)
   14.64          
   14.65 -        Log.msg("PullFeeder run ended. Waiting " + pullInterval / 1000 + "s", true);
   14.66 +        Log.get().info("PullFeeder run ended. Waiting " + pullInterval / 1000 + "s");
   14.67          Thread.sleep(pullInterval);
   14.68        }
   14.69        catch(InterruptedException ex)
   14.70        {
   14.71 -        Log.msg(ex.getMessage(), false);
   14.72 +        Log.get().warning(ex.getMessage());
   14.73        }
   14.74      }
   14.75    }
    15.1 --- a/org/sonews/feed/PushFeeder.java	Thu Aug 20 16:57:38 2009 +0200
    15.2 +++ b/org/sonews/feed/PushFeeder.java	Thu Aug 20 18:41:21 2009 +0200
    15.3 @@ -51,14 +51,14 @@
    15.4          
    15.5          Article  article = this.articleQueue.poll();
    15.6          String[] groups  = article.getHeader(Headers.NEWSGROUPS)[0].split(",");
    15.7 -        Log.msg("PushFeed: " + article.getMessageID(), true);
    15.8 +        Log.get().info("PushFeed: " + article.getMessageID());
    15.9          for(Subscription sub : this.subscriptions)
   15.10          {
   15.11            // Circle check
   15.12            if(article.getHeader(Headers.PATH)[0].contains(sub.getHost()))
   15.13            {
   15.14 -            Log.msg(article.getMessageID() + " skipped for host " 
   15.15 -              + sub.getHost(), true);
   15.16 +            Log.get().info(article.getMessageID() + " skipped for host "
   15.17 +              + sub.getHost());
   15.18              continue;
   15.19            }
   15.20  
   15.21 @@ -84,13 +84,13 @@
   15.22            }
   15.23            catch(IOException ex)
   15.24            {
   15.25 -            Log.msg(ex, false);
   15.26 +            Log.get().warning(ex.toString());
   15.27            }
   15.28          }
   15.29        }
   15.30        catch(InterruptedException ex)
   15.31        {
   15.32 -        Log.msg("PushFeeder interrupted: " + ex, true);
   15.33 +        Log.get().warning("PushFeeder interrupted: " + ex);
   15.34        }
   15.35      }
   15.36    }
    16.1 --- a/org/sonews/util/Log.java	Thu Aug 20 16:57:38 2009 +0200
    16.2 +++ b/org/sonews/util/Log.java	Thu Aug 20 18:41:21 2009 +0200
    16.3 @@ -18,7 +18,11 @@
    16.4  
    16.5  package org.sonews.util;
    16.6  
    16.7 -import java.util.Date;
    16.8 +import java.util.logging.Level;
    16.9 +import java.util.logging.LogManager;
   16.10 +import java.util.logging.Logger;
   16.11 +import java.util.logging.SimpleFormatter;
   16.12 +import java.util.logging.StreamHandler;
   16.13  import org.sonews.config.Config;
   16.14  
   16.15  /**
   16.16 @@ -28,32 +32,26 @@
   16.17   */
   16.18  public class Log
   16.19  {
   16.20 -  
   16.21 -  public static boolean isDebug()
   16.22 +
   16.23 +  public static final String MAIN = "main";
   16.24 +
   16.25 +  static
   16.26    {
   16.27 -    // We must use FileConfig here otherwise we come
   16.28 -    // into hell's kittchen when using the Logger within the
   16.29 -    // Database class.
   16.30 -    return Config.inst().get(Config.DEBUG, false);
   16.31 +    Logger mainLogger = Logger.getLogger(MAIN);
   16.32 +    StreamHandler handler = new StreamHandler(System.out, new SimpleFormatter());
   16.33 +    handler.setLevel(Level.parse(Config.inst().get(Config.LOGLEVEL, "INFO")));
   16.34 +    mainLogger.addHandler(handler);
   16.35 +    LogManager.getLogManager().addLogger(mainLogger);
   16.36    }
   16.37 -  
   16.38 -  /**
   16.39 -   * Writes the given message to the debug output.
   16.40 -   * @param msg A String message or an object.
   16.41 -   * @param If true this message is only shown if debug mode is enabled.
   16.42 -   */
   16.43 -  public static void msg(final Object msg, boolean debug)
   16.44 +
   16.45 +  public static Logger get()
   16.46    {
   16.47 -    if(isDebug() || !debug)
   16.48 -    {
   16.49 -      synchronized(System.out)
   16.50 -      {
   16.51 -        System.out.print(new Date().toString());
   16.52 -        System.out.print(": ");
   16.53 -        System.out.println(msg);
   16.54 -        System.out.flush();
   16.55 -      }
   16.56 -    }
   16.57 +    return get(MAIN);
   16.58 +  }
   16.59 +
   16.60 +  public static Logger get(String name)
   16.61 +  {
   16.62 +    return LogManager.getLogManager().getLogger(name);
   16.63    }
   16.64  
   16.65  }