View Javadoc

1   package org.lsst.ccs.utilities.logging;
2   
3   import org.lsst.ccs.utilities.tracers.Tracer;
4   
5   import java.io.IOException;
6   import java.util.logging.FileHandler;
7   import java.util.logging.Level;
8   import java.util.logging.LogRecord;
9   
10  /**
11   * @author bamade
12   */
13  // Date: 29/07/13
14  
15  public class FileHandlerN extends FileHandler {
16      public FileHandlerN() throws IOException, SecurityException {
17          //super(getFilePattern());
18      }
19  
20      public FileHandlerN(String pattern) throws IOException, SecurityException {
21          super(pattern);
22      }
23  
24      public FileHandlerN(String pattern, boolean append) throws IOException, SecurityException {
25          super(pattern, append);
26      }
27  
28      public FileHandlerN(String pattern, int limit, int count) throws IOException, SecurityException {
29          super(pattern, limit, count);
30      }
31  
32      public FileHandlerN(String pattern, int limit, int count, boolean append) throws IOException, SecurityException {
33          super(pattern, limit, count, append);
34      }
35  
36      protected IsLoggableDelegate isLoggableDelegate = new IsLoggableDelegate();
37      /**
38       * NOTE : this is to hack a Java util logging bug!
39       * BEWARE shpild be changed when BUG 9005710 is corrected!
40       */
41      protected IsLoggableDelegate isLoggableDelegate2 = new IsLoggableDelegate();
42  
43      @Override
44      public boolean isLoggable(LogRecord record) {
45          boolean res = super.isLoggable(record) ;
46          if(! res) {return false ;}
47          boolean delegateVal = isLoggableDelegate.isLoggable(record);
48          if(delegateVal) return true ;
49          assert Tracer.trace(record + " loggable ? " + res);
50          return isLoggableDelegate2.isLoggable(record);
51      }
52  
53      private static final int offValue = Level.OFF.intValue();
54  
55      /*
56      private boolean handlerLoggable(LogRecord record) {
57          int levelValue = getLevel().intValue();
58          if (record.getLevel().intValue() < levelValue || levelValue == offValue) {
59              return false;
60          }
61          Filter filter = getFilter();
62          if (filter == null) {
63              return true;
64          }
65          return filter.isLoggable(record);
66      }*/
67  
68      @Override
69      public void publish(LogRecord record) {
70          assert Tracer.trace("record to be written :" + record.getMessage());
71          super.publish(record);
72      }
73  
74  
75  
76  }