Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

Slf4JPlexusLogger.java 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 final 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. @Override
  41. public void debug( String message )
  42. {
  43. log.debug( message );
  44. }
  45. @Override
  46. public void debug( String message, Throwable throwable )
  47. {
  48. log.debug( message, throwable );
  49. }
  50. @Override
  51. public void error( String message )
  52. {
  53. log.error( message );
  54. }
  55. @Override
  56. public void error( String message, Throwable throwable )
  57. {
  58. log.error( message, throwable );
  59. }
  60. @Override
  61. public void fatalError( String message )
  62. {
  63. log.error( message );
  64. }
  65. @Override
  66. public void fatalError( String message, Throwable throwable )
  67. {
  68. log.error( message, throwable );
  69. }
  70. @Override
  71. public org.codehaus.plexus.logging.Logger getChildLogger( String name )
  72. {
  73. return new Slf4JPlexusLogger( log.getName() + "." + name );
  74. }
  75. @Override
  76. public String getName()
  77. {
  78. return log.getName();
  79. }
  80. @Override
  81. public int getThreshold()
  82. {
  83. if ( log.isTraceEnabled() )
  84. {
  85. return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG;
  86. }
  87. else if ( log.isDebugEnabled() )
  88. {
  89. return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG;
  90. }
  91. else if ( log.isInfoEnabled() )
  92. {
  93. return org.codehaus.plexus.logging.Logger.LEVEL_INFO;
  94. }
  95. else if ( log.isWarnEnabled() )
  96. {
  97. return org.codehaus.plexus.logging.Logger.LEVEL_WARN;
  98. }
  99. else if ( log.isErrorEnabled() )
  100. {
  101. return org.codehaus.plexus.logging.Logger.LEVEL_ERROR;
  102. }
  103. return org.codehaus.plexus.logging.Logger.LEVEL_DISABLED;
  104. }
  105. @Override
  106. public void info( String message )
  107. {
  108. log.info( message );
  109. }
  110. @Override
  111. public void info( String message, Throwable throwable )
  112. {
  113. log.info( message, throwable );
  114. }
  115. @Override
  116. public boolean isDebugEnabled()
  117. {
  118. return log.isDebugEnabled();
  119. }
  120. @Override
  121. public boolean isErrorEnabled()
  122. {
  123. return log.isErrorEnabled();
  124. }
  125. @Override
  126. public boolean isFatalErrorEnabled()
  127. {
  128. return log.isErrorEnabled();
  129. }
  130. @Override
  131. public boolean isInfoEnabled()
  132. {
  133. return log.isInfoEnabled();
  134. }
  135. @Override
  136. public boolean isWarnEnabled()
  137. {
  138. return log.isWarnEnabled();
  139. }
  140. @Override
  141. public void setThreshold( int threshold )
  142. {
  143. /* do nothing */
  144. }
  145. @Override
  146. public void warn( String message )
  147. {
  148. log.warn( message );
  149. }
  150. @Override
  151. public void warn( String message, Throwable throwable )
  152. {
  153. log.warn( message, throwable );
  154. }
  155. }