#2703 - unprivatizing NoLogging and adding a Java API for obtaining the reference

This commit is contained in:
Viktor Klang 2012-11-15 02:31:40 +01:00
parent 299d375f0c
commit 8194ddd13c
3 changed files with 28 additions and 11 deletions

View file

@ -1,5 +1,7 @@
package akka.japi; package akka.japi;
import akka.event.LoggingAdapter;
import akka.event.NoLogging;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -46,4 +48,10 @@ public class JavaAPITestBase {
public void shouldBeSingleton() { public void shouldBeSingleton() {
assertSame(Option.none(), Option.none()); assertSame(Option.none(), Option.none());
} }
@Test
public void mustBeAbleToGetNoLogging() {
LoggingAdapter a = NoLogging.getInstance();
assertNotNull(a);
}
} }

View file

@ -878,15 +878,25 @@ class BusLogging(val bus: LoggingBus, val logSource: String, val logClass: Class
protected def notifyDebug(message: String): Unit = bus.publish(Debug(logSource, logClass, message)) protected def notifyDebug(message: String): Unit = bus.publish(Debug(logSource, logClass, message))
} }
private[akka] object NoLogging extends LoggingAdapter { /**
def isErrorEnabled = false * NoLogging is a LoggingAdapter that does absolutely nothing no logging at all.
def isWarningEnabled = false */
def isInfoEnabled = false object NoLogging extends LoggingAdapter {
def isDebugEnabled = false
protected def notifyError(message: String): Unit = () /**
protected def notifyError(cause: Throwable, message: String): Unit = () * Java API to return the reference to NoLogging
protected def notifyWarning(message: String): Unit = () * @return The NoLogging instance
protected def notifyInfo(message: String): Unit = () */
protected def notifyDebug(message: String): Unit = () def getInstance = this
final override def isErrorEnabled = false
final override def isWarningEnabled = false
final override def isInfoEnabled = false
final override def isDebugEnabled = false
final protected override def notifyError(message: String): Unit = ()
final protected override def notifyError(cause: Throwable, message: String): Unit = ()
final protected override def notifyWarning(message: String): Unit = ()
final protected override def notifyInfo(message: String): Unit = ()
final protected override def notifyDebug(message: String): Unit = ()
} }

View file

@ -119,5 +119,4 @@ public class LoggingDocTestBase {
} }
} }
//#deadletter-actor //#deadletter-actor
} }