View Javadoc

1   /*
2    * $Id: VelocityLogger.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.tools.visualizer.util;
12  
13  import org.mule.tools.visualizer.config.GraphEnvironment;
14  
15  import org.apache.velocity.runtime.RuntimeServices;
16  import org.apache.velocity.runtime.log.LogSystem;
17  
18  public class VelocityLogger implements LogSystem
19  {
20      private final boolean debugEnabled;
21  
22      private GraphEnvironment environment = null;
23  
24      public VelocityLogger(GraphEnvironment environment)
25      {
26          this.environment = environment;
27          this.debugEnabled = environment.getConfig().isDebug();
28      }
29  
30      public void init(RuntimeServices arg0) throws Exception
31      {
32          // nothing to do
33      }
34  
35      public void logVelocityMessage(int arg0, String arg1)
36      {
37          if (environment != null)
38          {
39              if(arg0 >= ERROR_ID || debugEnabled)
40              {
41                  environment.log(arg1);
42              }
43          }
44      }
45  
46      public GraphEnvironment getEnvironment()
47      {
48          return environment;
49      }
50  
51      public void setEnvironment(GraphEnvironment environment)
52      {
53          this.environment = environment;
54      }
55  
56  }