You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Slf4JPlexusLogger.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package org.apache.archiva.common.utils;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import org.slf4j.Logger;
  21. import org.slf4j.LoggerFactory;
  22. /**
  23. * Slf4JPlexusLogger - temporary logger to provide an Slf4j Logger to those components
  24. * outside of the archiva codebase that require a plexus logger.
  25. *
  26. *
  27. */
  28. public class Slf4JPlexusLogger
  29. implements org.codehaus.plexus.logging.Logger
  30. {
  31. private Logger log;
  32. public Slf4JPlexusLogger( Class<?> clazz )
  33. {
  34. log = LoggerFactory.getLogger( clazz );
  35. }
  36. public Slf4JPlexusLogger( String name )
  37. {
  38. log = LoggerFactory.getLogger( name );
  39. }
  40. public void debug( String message )
  41. {
  42. log.debug( message );
  43. }
  44. public void debug( String message, Throwable throwable )
  45. {
  46. log.debug( message, throwable );
  47. }
  48. public void error( String message )
  49. {
  50. log.error( message );
  51. }
  52. public void error( String message, Throwable throwable )
  53. {
  54. log.error( message, throwable );
  55. }
  56. public void fatalError( String message )
  57. {
  58. log.error( message );
  59. }
  60. public void fatalError( String message, Throwable throwable )
  61. {
  62. log.error( message, throwable );
  63. }
  64. public org.codehaus.plexus.logging.Logger getChildLogger( String name )
  65. {
  66. return new Slf4JPlexusLogger( log.getName() + "." + name );
  67. }
  68. public String getName()
  69. {
  70. return log.getName();
  71. }
  72. public int getThreshold()
  73. {
  74. if ( log.isTraceEnabled() )
  75. {
  76. return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG;
  77. }
  78. else if ( log.isDebugEnabled() )
  79. {
  80. return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG;
  81. }
  82. else if ( log.isInfoEnabled() )
  83. {
  84. return org.codehaus.plexus.logging.Logger.LEVEL_INFO;
  85. }
  86. else if ( log.isWarnEnabled() )
  87. {
  88. return org.codehaus.plexus.logging.Logger.LEVEL_WARN;
  89. }
  90. else if ( log.isErrorEnabled() )
  91. {
  92. return org.codehaus.plexus.logging.Logger.LEVEL_ERROR;
  93. }
  94. return org.codehaus.plexus.logging.Logger.LEVEL_DISABLED;
  95. }
  96. public void info( String message )
  97. {
  98. log.info( message );
  99. }
  100. public void info( String message, Throwable throwable )
  101. {
  102. log.info( message, throwable );
  103. }
  104. public boolean isDebugEnabled()
  105. {
  106. return log.isDebugEnabled();
  107. }
  108. public boolean isErrorEnabled()
  109. {
  110. return log.isErrorEnabled();
  111. }
  112. public boolean isFatalErrorEnabled()
  113. {
  114. return log.isErrorEnabled();
  115. }
  116. public boolean isInfoEnabled()
  117. {
  118. return log.isInfoEnabled();
  119. }
  120. public boolean isWarnEnabled()
  121. {
  122. return log.isWarnEnabled();
  123. }
  124. public void setThreshold( int threshold )
  125. {
  126. /* do nothing */
  127. }
  128. public void warn( String message )
  129. {
  130. log.warn( message );
  131. }
  132. public void warn( String message, Throwable throwable )
  133. {
  134. log.warn( message, throwable );
  135. }
  136. }