View Javadoc

1   /**
2      This file is part of GoldenGate Project (named also GoldenGate or GG).
3   
4      Copyright 2009, Frederic Bregier, and individual contributors by the @author
5      tags. See the COPYRIGHT.txt in the distribution for a full listing of
6      individual contributors.
7   
8      All GoldenGate Project is free software: you can redistribute it and/or 
9      modify it under the terms of the GNU General Public License as published 
10     by the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12  
13     GoldenGate is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17  
18     You should have received a copy of the GNU General Public License
19     along with GoldenGate .  If not, see <http://www.gnu.org/licenses/>.
20   */
21  package goldengate.common.logging;
22  
23  import java.util.logging.Level;
24  import java.util.logging.Logger;
25  
26  import org.jboss.netty.logging.InternalLogger;
27  import org.jboss.netty.logging.JdkLoggerFactory;
28  
29  /**
30   * Logger factory which creates a <a href=
31   * "http://java.sun.com/javase/6/docs/technotes/guides/logging/index.html"
32   * >java.util.logging</a> logger.
33   *
34   * Based on The Netty Project (netty-dev@lists.jboss.org)
35   *
36   * @author Trustin Lee (tlee@redhat.com)
37   * @author Frederic Bregier
38   */
39  public class GgJdkLoggerFactory extends JdkLoggerFactory implements GgInternalLoggerInterface {
40      /**
41       *
42       * @param level
43       */
44      public GgJdkLoggerFactory(Level level) {
45          super();
46  
47          Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
48          if (level == null) {
49              logger.info("Default level: "+logger.getLevel());
50          } else {
51              logger.setLevel(level);
52          }
53      }
54  
55      @Override
56      public InternalLogger newInstance(String name) {
57          final java.util.logging.Logger logger = java.util.logging.Logger
58                  .getLogger(name);
59          return new GgJdkLogger(logger, name);
60      }
61  }