Issue #538 fixed.
authorcli
Thu Aug 20 21:31:03 2009 +0200 (2009-08-20)
changeset 165a4a41cfc0a3
parent 15 f2293e8566f5
child 17 4ae6ada7ea23
Issue #538 fixed.
org/sonews/mlgw/Dispatcher.java
org/sonews/mlgw/MailPoller.java
org/sonews/storage/Article.java
org/sonews/storage/Group.java
org/sonews/storage/impl/JDBCDatabase.java
org/sonews/util/Log.java
org/sonews/util/Purger.java
org/sonews/util/Stats.java
org/sonews/util/io/ArticleReader.java
     1.1 --- a/org/sonews/mlgw/Dispatcher.java	Thu Aug 20 18:41:21 2009 +0200
     1.2 +++ b/org/sonews/mlgw/Dispatcher.java	Thu Aug 20 21:31:03 2009 +0200
     1.3 @@ -115,7 +115,7 @@
     1.4      }
     1.5      else if(fallback)
     1.6      {
     1.7 -      Log.msg("Using fallback recipient discovery for: " + msg.getSubject(), true);
     1.8 +      Log.get().info("Using fallback recipient discovery for: " + msg.getSubject());
     1.9        groups = new ArrayList<String>();
    1.10        // Fallback to TO/CC/BCC addresses
    1.11        Address[] to = msg.getAllRecipients();
    1.12 @@ -181,7 +181,7 @@
    1.13              groups.append(',');
    1.14            }
    1.15          }
    1.16 -        Log.msg("Posting to group " + groups.toString(), true);
    1.17 +        Log.get().info("Posting to group " + groups.toString());
    1.18  
    1.19          article.setGroup(groups.toString());
    1.20          //article.removeHeader(Headers.REPLY_TO);
    1.21 @@ -190,14 +190,15 @@
    1.22          // Write article to database
    1.23          if(updateReq)
    1.24          {
    1.25 -          Log.msg("Updating " + article.getMessageID() + " with additional groups", true);
    1.26 +          Log.get().info("Updating " + article.getMessageID()
    1.27 +            + " with additional groups");
    1.28            StorageManager.current().delete(article.getMessageID());
    1.29            StorageManager.current().addArticle(article);
    1.30          }
    1.31          else
    1.32          {
    1.33 -          Log.msg("Gatewaying " + article.getMessageID() + " to "
    1.34 -            + article.getHeader(Headers.NEWSGROUPS)[0], true);
    1.35 +          Log.get().info("Gatewaying " + article.getMessageID() + " to "
    1.36 +            + article.getHeader(Headers.NEWSGROUPS)[0]);
    1.37            StorageManager.current().addArticle(article);
    1.38            Stats.getInstance().mailGatewayed(
    1.39              article.getHeader(Headers.NEWSGROUPS)[0]);
    1.40 @@ -213,7 +214,7 @@
    1.41            buf.append(toa.toString());
    1.42          }
    1.43          buf.append(" " + article.getHeader(Headers.LIST_POST)[0]);
    1.44 -        Log.msg("No group for" + buf.toString(), false);
    1.45 +        Log.get().warning("No group for" + buf.toString());
    1.46        }
    1.47        return posted;
    1.48      }
    1.49 @@ -237,7 +238,7 @@
    1.50  
    1.51      if(rcptAddresses == null || rcptAddresses.size() == 0)
    1.52      {
    1.53 -      Log.msg("No ML-address for " + group + " found.", false);
    1.54 +      Log.get().warning("No ML-address for " + group + " found.");
    1.55        return;
    1.56      }
    1.57  
    1.58 @@ -271,8 +272,8 @@
    1.59        smtpTransport.close();
    1.60  
    1.61        Stats.getInstance().mailGatewayed(group);
    1.62 -      Log.msg("MLGateway: Mail " + article.getHeader("Subject")[0]
    1.63 -        + " was delivered to " + rcptAddress + ".", true);
    1.64 +      Log.get().info("MLGateway: Mail " + article.getHeader("Subject")[0]
    1.65 +        + " was delivered to " + rcptAddress + ".");
    1.66      }
    1.67    }
    1.68    
     2.1 --- a/org/sonews/mlgw/MailPoller.java	Thu Aug 20 18:41:21 2009 +0200
     2.2 +++ b/org/sonews/mlgw/MailPoller.java	Thu Aug 20 21:31:03 2009 +0200
     2.3 @@ -61,7 +61,7 @@
     2.4    @Override
     2.5    public void run()
     2.6    {
     2.7 -    Log.msg("Starting Mailinglist Poller...", false);
     2.8 +    Log.get().info("Starting Mailinglist Poller...");
     2.9      int errors = 0;
    2.10      while(isRunning() && errors < 5)
    2.11      {
    2.12 @@ -119,7 +119,7 @@
    2.13        }
    2.14        catch(NoSuchProviderException ex)
    2.15        {
    2.16 -        Log.msg(ex.toString(), false);
    2.17 +        Log.get().severe(ex.toString());
    2.18          shutdown();
    2.19        }
    2.20        catch(AuthenticationFailedException ex)
    2.21 @@ -145,7 +145,7 @@
    2.22          errors++;
    2.23        }
    2.24      }
    2.25 -    Log.msg("MailPoller exited.", false);
    2.26 +    Log.get().severe("MailPoller exited.");
    2.27    }
    2.28    
    2.29  }
     3.1 --- a/org/sonews/storage/Article.java	Thu Aug 20 18:41:21 2009 +0200
     3.2 +++ b/org/sonews/storage/Article.java	Thu Aug 20 21:31:03 2009 +0200
     3.3 @@ -139,8 +139,10 @@
     3.4        // Unknown content is probably a malformed mail we should skip.
     3.5        // On the other hand we produce an inconsistent mail mirror, but no
     3.6        // mail system must transport invalid content.
     3.7 -      Log.msg("Skipping message due to unknown content. Throwing exception...", true);
     3.8 -      throw new MessagingException("Unknown content: " + content);
     3.9 +      Log.get().severe("Skipping message due to unknown content. Throwing exception...");
    3.10 +      MessagingException ex = new MessagingException("Unknown content: " + content);
    3.11 +      Log.get().throwing("Article.java", "<init>", ex);
    3.12 +      throw ex;
    3.13      }
    3.14      
    3.15      // Validate headers
    3.16 @@ -264,8 +266,8 @@
    3.17      }
    3.18      catch(Exception ex)
    3.19      {
    3.20 -      Log.msg(ex.getMessage(), false);
    3.21 -      Log.msg("Article.getBodyCharset(): Unknown charset: " + charsetName, false);
    3.22 +      Log.get().severe(ex.getMessage());
    3.23 +      Log.get().severe("Article.getBodyCharset(): Unknown charset: " + charsetName);
    3.24      }
    3.25      return charset;
    3.26    }
     4.1 --- a/org/sonews/storage/Group.java	Thu Aug 20 18:41:21 2009 +0200
     4.2 +++ b/org/sonews/storage/Group.java	Thu Aug 20 21:31:03 2009 +0200
     4.3 @@ -65,7 +65,7 @@
     4.4      }
     4.5      catch(StorageBackendException ex)
     4.6      {
     4.7 -      Log.msg(ex.getMessage(), false);
     4.8 +      Log.get().severe(ex.getMessage());
     4.9        return null;
    4.10      }
    4.11    }
     5.1 --- a/org/sonews/storage/impl/JDBCDatabase.java	Thu Aug 20 18:41:21 2009 +0200
     5.2 +++ b/org/sonews/storage/impl/JDBCDatabase.java	Thu Aug 20 21:31:03 2009 +0200
     5.3 @@ -121,7 +121,7 @@
     5.4        this.conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
     5.5        if(this.conn.getTransactionIsolation() != Connection.TRANSACTION_SERIALIZABLE)
     5.6        {
     5.7 -        Log.msg("Warning: Database is NOT fully serializable!", false);
     5.8 +        Log.get().warning("Database is NOT fully serializable!");
     5.9        }
    5.10  
    5.11        // Prepare statements for method addArticle()
    5.12 @@ -360,7 +360,7 @@
    5.13        }
    5.14        catch(SQLException ex2)
    5.15        {
    5.16 -        Log.msg("Rollback of addArticle() failed: " + ex2, false);
    5.17 +        Log.get().severe("Rollback of addArticle() failed: " + ex2);
    5.18        }
    5.19        
    5.20        try
    5.21 @@ -369,7 +369,7 @@
    5.22        }
    5.23        catch(SQLException ex2)
    5.24        {
    5.25 -        Log.msg("setAutoCommit(true) of addArticle() failed: " + ex2, false);
    5.26 +        Log.get().severe("setAutoCommit(true) of addArticle() failed: " + ex2);
    5.27        }
    5.28  
    5.29        restartConnection(ex);
    5.30 @@ -1486,7 +1486,7 @@
    5.31        }
    5.32        else
    5.33        {
    5.34 -        Log.msg("Warning: Count on postings return nothing!", true);
    5.35 +        Log.get().warning("Count on postings return nothing!");
    5.36          return 0;
    5.37        }
    5.38      }
    5.39 @@ -1696,8 +1696,8 @@
    5.40      throws StorageBackendException
    5.41    {
    5.42      restarts++;
    5.43 -    Log.msg(Thread.currentThread() 
    5.44 -      + ": Database connection was closed (restart " + restarts + ").", false);
    5.45 +    Log.get().severe(Thread.currentThread()
    5.46 +      + ": Database connection was closed (restart " + restarts + ").");
    5.47      
    5.48      if(restarts >= MAX_RESTARTS)
    5.49      {
    5.50 @@ -1715,7 +1715,7 @@
    5.51      }
    5.52      catch(InterruptedException ex)
    5.53      {
    5.54 -      Log.msg("Interrupted: " + ex.getMessage(), false);
    5.55 +      Log.get().warning("Interrupted: " + ex.getMessage());
    5.56      }
    5.57      
    5.58      // Try to properly close the old database connection
    5.59 @@ -1728,7 +1728,7 @@
    5.60      }
    5.61      catch(SQLException ex)
    5.62      {
    5.63 -      Log.msg(ex.getMessage(), true);
    5.64 +      Log.get().warning(ex.getMessage());
    5.65      }
    5.66      
    5.67      try
    5.68 @@ -1738,7 +1738,7 @@
    5.69      }
    5.70      catch(SQLException ex)
    5.71      {
    5.72 -      Log.msg(ex.getMessage(), true);
    5.73 +      Log.get().warning(ex.getMessage());
    5.74        restartConnection(ex);
    5.75      }
    5.76    }
     6.1 --- a/org/sonews/util/Log.java	Thu Aug 20 18:41:21 2009 +0200
     6.2 +++ b/org/sonews/util/Log.java	Thu Aug 20 21:31:03 2009 +0200
     6.3 @@ -39,8 +39,10 @@
     6.4    {
     6.5      Logger mainLogger = Logger.getLogger(MAIN);
     6.6      StreamHandler handler = new StreamHandler(System.out, new SimpleFormatter());
     6.7 -    handler.setLevel(Level.parse(Config.inst().get(Config.LOGLEVEL, "INFO")));
     6.8 +    Level level = Level.parse(Config.inst().get(Config.LOGLEVEL, "INFO"));
     6.9 +    handler.setLevel(level);
    6.10      mainLogger.addHandler(handler);
    6.11 +    mainLogger.setLevel(level);
    6.12      LogManager.getLogManager().addLogger(mainLogger);
    6.13    }
    6.14  
    6.15 @@ -51,7 +53,10 @@
    6.16  
    6.17    public static Logger get(String name)
    6.18    {
    6.19 -    return LogManager.getLogManager().getLogger(name);
    6.20 +    Level level = Level.parse(Config.inst().get(Config.LOGLEVEL, "INFO"));
    6.21 +    Logger logger = LogManager.getLogManager().getLogger(name);
    6.22 +    logger.setLevel(level);
    6.23 +    return logger;
    6.24    }
    6.25  
    6.26  }
     7.1 --- a/org/sonews/util/Purger.java	Thu Aug 20 18:41:21 2009 +0200
     7.2 +++ b/org/sonews/util/Purger.java	Thu Aug 20 21:31:03 2009 +0200
     7.3 @@ -63,7 +63,7 @@
     7.4      }
     7.5      catch(InterruptedException ex)
     7.6      {
     7.7 -      Log.msg("Purger interrupted: " + ex, true);
     7.8 +      Log.get().warning("Purger interrupted: " + ex);
     7.9      }
    7.10    }
    7.11  
    7.12 @@ -84,14 +84,14 @@
    7.13          if(ids.size() == 0)
    7.14          {
    7.15            StorageManager.current().purgeGroup(group);
    7.16 -          Log.msg("Group " + group.getName() + " purged.", true);
    7.17 +          Log.get().info("Group " + group.getName() + " purged.");
    7.18          }
    7.19  
    7.20          for(int n = 0; n < ids.size() && n < 10; n++)
    7.21          {
    7.22            Article art = StorageManager.current().getArticle(ids.get(n), group.getInternalID());
    7.23            StorageManager.current().delete(art.getMessageID());
    7.24 -          Log.msg("Article " + art.getMessageID() + " purged.", true);
    7.25 +          Log.get().info("Article " + art.getMessageID() + " purged.");
    7.26          }
    7.27        }
    7.28      }
    7.29 @@ -107,7 +107,7 @@
    7.30  
    7.31      if(lifetime > 0 || articleMaximum < Stats.getInstance().getNumberOfNews())
    7.32      {
    7.33 -      Log.msg("Purging old messages...", true);
    7.34 +      Log.get().info("Purging old messages...");
    7.35        String mid = StorageManager.current().getOldestArticle();
    7.36        if (mid == null) // No articles in the database
    7.37        {
    7.38 @@ -123,7 +123,7 @@
    7.39        }
    7.40        catch (IllegalArgumentException ex)
    7.41        {
    7.42 -        Log.msg("Could not parse date string: " + dateStr + " " + ex, true);
    7.43 +        Log.get().warning("Could not parse date string: " + dateStr + " " + ex);
    7.44        }
    7.45  
    7.46        // Should we delete the message because of its age or because the
    7.47 @@ -141,7 +141,7 @@
    7.48      }
    7.49      else
    7.50      {
    7.51 -      Log.msg("Lifetime purger is disabled", true);
    7.52 +      Log.get().info("Lifetime purger is disabled");
    7.53        Thread.sleep(1000 * 60 * 30); // Wait 30 minutes
    7.54      }
    7.55    }
     8.1 --- a/org/sonews/util/Stats.java	Thu Aug 20 18:41:21 2009 +0200
     8.2 +++ b/org/sonews/util/Stats.java	Thu Aug 20 21:31:03 2009 +0200
     8.3 @@ -76,7 +76,7 @@
     8.4        }
     8.5        else
     8.6        {
     8.7 -        Log.msg("Group " + groupname + " does not exist.", true);
     8.8 +        Log.get().info("Group " + groupname + " does not exist.");
     8.9        }
    8.10      }
    8.11    }
     9.1 --- a/org/sonews/util/io/ArticleReader.java	Thu Aug 20 18:41:21 2009 +0200
     9.2 +++ b/org/sonews/util/io/ArticleReader.java	Thu Aug 20 21:31:03 2009 +0200
     9.3 @@ -95,7 +95,7 @@
     9.4            buf.write(10);
     9.5            if(buf.size() > maxSize)
     9.6            {
     9.7 -            Log.msg("Skipping message that is too large: " + buf.size(), false);
     9.8 +            Log.get().warning("Skipping message that is too large: " + buf.size());
     9.9              return null;
    9.10            }
    9.11          }
    9.12 @@ -104,7 +104,7 @@
    9.13        }
    9.14        else
    9.15        {
    9.16 -        Log.msg("ArticleReader: " + line, false);
    9.17 +        Log.get().warning("ArticleReader: " + line);
    9.18          return null;
    9.19        }
    9.20      }