Created
August 6, 2013 20:08
-
-
Save paul-lysak/6168137 to your computer and use it in GitHub Desktop.
Illustration of caveats of defining logger in superclass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.typesafe.scalalogging.slf4j.Logging | |
import org.slf4j.LoggerFactory | |
class SuperClassA extends Logging { | |
def doSuper { | |
logger.info("Hi, SuperClassA") | |
} | |
} | |
class SubClassA extends SuperClassA { | |
def doSub { | |
logger.info("Hi, SubClassA") | |
} | |
} | |
class SuperClassB { | |
def doSuper { | |
logger.info("Hi, SuperClassB") | |
} | |
private val logger = LoggerFactory.getLogger(classOf[SuperClassB]) | |
} | |
class SubClassB extends SuperClassB { | |
def doSub { | |
logger.info("Hi, SubClassB") | |
} | |
private val logger = LoggerFactory.getLogger(classOf[SubClassB]) | |
} | |
object LoggerDemo { | |
def main(args: Array[String]) { | |
val a = new SubClassA | |
a.doSuper | |
a.doSub | |
val b = new SubClassB | |
b.doSuper | |
b.doSub | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment