NoOpLog.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. package org.apache.commons.logging.impl;

  18. import java.io.Serializable;

  19. import org.apache.commons.logging.Log;

  20. /**
  21.  * Trivial implementation of Log that throws away all messages. No configurable system properties are supported.
  22.  */
  23. public class NoOpLog implements Log, Serializable {

  24.     /** Serializable version identifier. */
  25.     private static final long serialVersionUID = 561423906191706148L;

  26.     /** Convenience constructor */
  27.     public NoOpLog() {
  28.         // no-op
  29.     }

  30.     /**
  31.      * Base constructor
  32.      *
  33.      * @param ignoredName unused.
  34.      */
  35.     public NoOpLog(final String ignoredName) {
  36.         // no-op
  37.     }

  38.     /** Do nothing */
  39.     @Override
  40.     public void debug(final Object message) {
  41.         // no-op
  42.     }

  43.     /** Do nothing */
  44.     @Override
  45.     public void debug(final Object message, final Throwable t) {
  46.         // no-op
  47.     }

  48.     /** Do nothing */
  49.     @Override
  50.     public void error(final Object message) {
  51.         // no-op
  52.     }

  53.     /** Do nothing */
  54.     @Override
  55.     public void error(final Object message, final Throwable t) {
  56.         // no-op
  57.     }

  58.     /** Do nothing */
  59.     @Override
  60.     public void fatal(final Object message) {
  61.         // no-op
  62.     }

  63.     /** Do nothing */
  64.     @Override
  65.     public void fatal(final Object message, final Throwable t) {
  66.         // no-op
  67.     }

  68.     /** Do nothing */
  69.     @Override
  70.     public void info(final Object message) {
  71.         // no-op
  72.     }

  73.     /** Do nothing */
  74.     @Override
  75.     public void info(final Object message, final Throwable t) {
  76.         // no-op
  77.     }

  78.     /**
  79.      * Debug is never enabled.
  80.      *
  81.      * @return false
  82.      */
  83.     @Override
  84.     public final boolean isDebugEnabled() {
  85.         return false;
  86.     }

  87.     /**
  88.      * Error is never enabled.
  89.      *
  90.      * @return false
  91.      */
  92.     @Override
  93.     public final boolean isErrorEnabled() {
  94.         return false;
  95.     }

  96.     /**
  97.      * Fatal is never enabled.
  98.      *
  99.      * @return false
  100.      */
  101.     @Override
  102.     public final boolean isFatalEnabled() {
  103.         return false;
  104.     }

  105.     /**
  106.      * Info is never enabled.
  107.      *
  108.      * @return false
  109.      */
  110.     @Override
  111.     public final boolean isInfoEnabled() {
  112.         return false;
  113.     }

  114.     /**
  115.      * Trace is never enabled.
  116.      *
  117.      * @return false
  118.      */
  119.     @Override
  120.     public final boolean isTraceEnabled() {
  121.         return false;
  122.     }

  123.     /**
  124.      * Warn is never enabled.
  125.      *
  126.      * @return false
  127.      */
  128.     @Override
  129.     public final boolean isWarnEnabled() {
  130.         return false;
  131.     }

  132.     /** Do nothing */
  133.     @Override
  134.     public void trace(final Object message) {
  135.         // no-op
  136.     }

  137.     /** Do nothing */
  138.     @Override
  139.     public void trace(final Object message, final Throwable t) {
  140.         // no-op
  141.     }

  142.     /** Do nothing */
  143.     @Override
  144.     public void warn(final Object message) {
  145.         // no-op
  146.     }

  147.     /** Do nothing */
  148.     @Override
  149.     public void warn(final Object message, final Throwable t) {
  150.         // no-op
  151.     }
  152. }