1. /*
  2. * Copyright 2002-2004 the original author or authors.
  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. package org.springframework.ui.velocity;
  17. import org.apache.commons.logging.Log;
  18. import org.apache.commons.logging.LogFactory;
  19. import org.apache.velocity.app.VelocityEngine;
  20. import org.apache.velocity.runtime.RuntimeServices;
  21. import org.apache.velocity.runtime.log.LogSystem;
  22. /**
  23. * Velocity LogSystem implementation for Jakarta Commons Logging.
  24. * Used by VelocityConfigurer to redirect log output.
  25. * @author Juergen Hoeller
  26. * @since 07.08.2003
  27. * @see VelocityEngineFactoryBean
  28. */
  29. public class CommonsLoggingLogSystem implements LogSystem {
  30. private static final Log logger = LogFactory.getLog(VelocityEngine.class);
  31. public void init(RuntimeServices runtimeServices) {
  32. }
  33. public void logVelocityMessage(int type, String msg) {
  34. switch (type) {
  35. case ERROR_ID:
  36. logger.error(msg);
  37. break;
  38. case WARN_ID:
  39. logger.warn(msg);
  40. break;
  41. case INFO_ID:
  42. logger.info(msg);
  43. break;
  44. case DEBUG_ID:
  45. logger.debug(msg);
  46. break;
  47. }
  48. }
  49. }