More control over logging
how about splitting into multiple ones, and put then in a dedicated class
(Logging) tied to the session, like this :
Session {
val logging = new Logging
}
class Logging {
...
def logger_=(l: Option[String => Unit])
def resultSetLogger_=(l: Option[String => Unit])
def statementLogger_=(l: Option[String => Unit])
def updateLogger_=(l: Option[String => Unit])
def insertLogger_=(l: Option[String => Unit])
def deleteLogger_=(l: Option[String => Unit])
}
all loggers would form a hierarchy :
logger
->resultSetLogger
->statementLogger
->updateLogger
->insertLogger
->deleteLogge
if you assign a closure to a logger it also gets assigned to all descendants,
ex.1: if you set a closure on logger, it gets assigned to all others,
that would be equivalent to the current behavior.
ex.2: if you set a closure on statement logger, it also gets set on update, insert and delete loggers,
etc...
the current setLogger would become deprecated, and simply do :
def setLogger(l: String=>Unit) =
this.logging.logger = l
(Logging) tied to the session, like this :
Session {
val logging = new Logging
}
class Logging {
...
def logger_=(l: Option[String => Unit])
def resultSetLogger_=(l: Option[String => Unit])
def statementLogger_=(l: Option[String => Unit])
def updateLogger_=(l: Option[String => Unit])
def insertLogger_=(l: Option[String => Unit])
def deleteLogger_=(l: Option[String => Unit])
}
all loggers would form a hierarchy :
logger
->resultSetLogger
->statementLogger
->updateLogger
->insertLogger
->deleteLogge
if you assign a closure to a logger it also gets assigned to all descendants,
ex.1: if you set a closure on logger, it gets assigned to all others,
that would be equivalent to the current behavior.
ex.2: if you set a closure on statement logger, it also gets set on update, insert and delete loggers,
etc...
the current setLogger would become deprecated, and simply do :
def setLogger(l: String=>Unit) =
this.logging.logger = l
Leave a comment