View Javadoc

1   /*
2    *   Copyright 2004 The Apache Software Foundation
3    *
4    *   Licensed under the Apache License, Version 2.0 (the "License");
5    *   you may not use this file except in compliance with the License.
6    *   You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
15   *
16   */
17  package org.apache.asn1.ber.digester ;
18  
19  
20  import org.slf4j.LoggerFactory;
21  import org.slf4j.Logger;
22  
23  
24  /***
25   * A logging BER digestor monitor.
26   *
27   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
28   * @version $Rev: 231081 $
29   */
30  public class BERDigesterLoggingMonitor implements BERDigesterMonitor
31  {
32      /*** logging facility for the digester */
33      private static Logger log = LoggerFactory.getLogger( "BERDigester" ) ;
34  
35  
36      /***
37       * Callback used to log a rule callback failure when triggered by the
38       * digester.
39       *
40       * @param digester the digester triggering the rule
41       * @param rule     the rule that failed
42       * @param msg      a message regarding the failure
43       * @param fault    the fault that caused the failure
44       */
45      public void ruleFailed( BERDigester digester, Rule rule, String msg,
46                              Throwable fault )
47      {
48          if ( log.isErrorEnabled() )
49          {
50              log.error( "Error while triggering rule " + rule
51                      + " with digester " + digester + ": " + msg, fault ) ;
52          }
53      }
54  
55  
56      /***
57       * Callback used to monitor successful rule firing.
58       *
59       * @param digester the digester triggering the rule
60       * @param rule     the rule that completed firing successfully
61       */
62      public void ruleCompleted( BERDigester digester, Rule rule )
63      {
64          if ( log.isDebugEnabled() )
65          {
66              log.debug( "Rule " + rule + " fired successfully by digester "
67                      + digester ) ;
68          }
69      }
70  }