#2703 - unprivatizing NoLogging and adding a Java API for obtaining the reference
This commit is contained in:
parent
299d375f0c
commit
8194ddd13c
3 changed files with 28 additions and 11 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package akka.japi;
|
||||
|
||||
import akka.event.LoggingAdapter;
|
||||
import akka.event.NoLogging;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
|
@ -46,4 +48,10 @@ public class JavaAPITestBase {
|
|||
public void shouldBeSingleton() {
|
||||
assertSame(Option.none(), Option.none());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mustBeAbleToGetNoLogging() {
|
||||
LoggingAdapter a = NoLogging.getInstance();
|
||||
assertNotNull(a);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
||||
private[akka] object NoLogging extends LoggingAdapter {
|
||||
def isErrorEnabled = false
|
||||
def isWarningEnabled = false
|
||||
def isInfoEnabled = false
|
||||
def isDebugEnabled = false
|
||||
/**
|
||||
* NoLogging is a LoggingAdapter that does absolutely nothing – no logging at all.
|
||||
*/
|
||||
object NoLogging extends LoggingAdapter {
|
||||
|
||||
protected def notifyError(message: String): Unit = ()
|
||||
protected def notifyError(cause: Throwable, message: String): Unit = ()
|
||||
protected def notifyWarning(message: String): Unit = ()
|
||||
protected def notifyInfo(message: String): Unit = ()
|
||||
protected def notifyDebug(message: String): Unit = ()
|
||||
/**
|
||||
* Java API to return the reference to NoLogging
|
||||
* @return The NoLogging instance
|
||||
*/
|
||||
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 = ()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,5 +119,4 @@ public class LoggingDocTestBase {
|
|||
}
|
||||
}
|
||||
//#deadletter-actor
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue