I've added first shot at the new logging code:
I've tried to keep it as simple as possible, really just a Scala layer
on top of the SLF4J api.
Note that no backend (log4j or logback) configuration is included. This
has to go into lift-util to use runmode etc.
You can have your choice of a nested logger:
object MyObj extends Logging {
logger.info("nested Hello")
}
or direct access:
object MyObj extends Loggable {
info("direct Hello")
}
Thoughts?
Next step, when this has been committed, is to update Lift internals to
use the new code (as part of #310) and deprecate the old logging in util.
/Jeppe
Br's,
Marius
On 14 feb., 15:40, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
> Hi,
>
> I've added first shot at the new logging code:
>
> http://github.com/dpp/liftweb/blob/e7ed6c6bc013aea768bfe34a6e4eca22d2...
Not sure if we need both. I prefer Loggable because it minimizes
clutter, but in some case (such as inside a Specification) there might
already be a warn etc in scope, in which case Logging can be used.
/Jeppe
Hi,
I've tried to keep it as simple as possible, really just a Scala layer
on top of the SLF4J api.
Note that no backend (log4j or logback) configuration is included. This
has to go into lift-util to use runmode etc.
You can have your choice of a nested logger:
object MyObj extends Logging {
logger.info("nested Hello")
}
or direct access:
object MyObj extends Loggable {
info("direct Hello")
}
Thoughts?
Makes sense, and that was actually close to what I had initially: The
Logger trait was called LiftLogger, but this clashed with the current
LiftLogger.
This name (Logger in current code) probably doesn't matter too much as
it's usually not needed in client code. But AbstractLogger doesn't
sound very nice :-)
/Jeppe
Makes sense, and that was actually close to what I had initially: The
Logger trait was called LiftLogger, but this clashed with the current
LiftLogger.
This name (Logger in current code) probably doesn't matter too much as
it's usually not needed in client code. But AbstractLogger doesn't
sound very nice :-)
Agreed. Suggestions?
/Jeppe
> Even if (probably) not needed, we should try to name it the best possibleAgreed. Suggestions?
> way. Changing now causes no pain at all, but later ... you know.
I know, but before there was an extra (abstract) trait Logger which
was what I asked about :-). But this is a moot point now, it has been
eliminated and naming is now as you proposed above....
One issue remains, which I don't know how to handle (if possible at
all): The current mixins use the dynamic type of an instance to
determine the logger name. This may not always be the preferred way.
E.g:
trait PaymentSystem extends Logger
trait FullfillmentSystem extends Logger
object MyStore extends PaymentSystem with FullfillmentSystem with Logger
Now everything in the subsystems will be logged with the MyStore
logger which is not how I would like to see it. The only solution I've
found so far is to not use the mixins and create private loggers in
the subsystem, where the static type is known. E.g. val logger =
Logger(classOf[PaymentSystem])
But this kind of restricts the usage of the mixins. Any thoughts on
this issue is appreciated....
/Jeppe
On Feb 15, 1:52 pm, Heiko Seeberger <heiko.seeber...@googlemail.com>
wrote:
> On 15 February 2010 09:45, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
>
> > > Even if (probably) not needed, we should try to name it the best possible
> > > way. Changing now causes no pain at all, but later ... you know.
>
> > Agreed. Suggestions?
>
> I already made mine, just to make sure everyone has a chance to see them:
> Like *Iterable* and *Iterator* lets call the trait that offers the logging
> methods (info, warn, etc.) *Logger* and the trait that gives access to a *
> Logger* should be called *Loggable*.
+1
The restriction might be worthwhile in this case for the sake of
predictability. Having class/object specific logger is to be able to
filter in/out the logs (via configuration) at deployment time. It should
not be too sensitive to minor rearrangement of mixins in the code.
Would it be overcomplicated to make the Logger trait typed?
>
> /Jeppe
>
>> http://github.com/dpp/liftweb/blob/add01980aa81875617f38260d710e0558c7ae1b1/framework/lift-base/lift-common/src/main/scala/net/liftweb/common/Logging.scala
>>
>> One issue remains, which I don't know how to handle (if possible at
>> all): The current mixins use the dynamic type of an instance to
>> determine the logger name. This may not always be the preferred way.
>> E.g:
>>
>> trait PaymentSystem extends Logger
>> trait FullfillmentSystem extends Logger
>>
>> object MyStore extends PaymentSystem with FullfillmentSystem with Logger
>>
>> Now everything in the subsystems will be logged with the MyStore
>> logger which is not how I would like to see it. The only solution I've
>> found so far is to not use the mixins and create private loggers in
>> the subsystem, where the static type is known. E.g. val logger =
>> Logger(classOf[PaymentSystem])
>>
>> But this kind of restricts the usage of the mixins. Any thoughts on
>> this issue is appreciated....
>
> The restriction might be worthwhile in this case for the sake of
> predictability. Having class/object specific logger is to be able to filter
> in/out the logs (via configuration) at deployment time. It should not be too
> sensitive to minor rearrangement of mixins in the code.
>
> Would it be overcomplicated to make the Logger trait typed?
Not sure I follow? Logger is already a trait...Or did you mean something else?
Having thought a little more about this, it seems like both solutions
(mixin and private loggers) has their uses:
Mixins as convenience for application services that should not be
subclassed and private loggers for reusable components .
/Jeppe
/Jeppe
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.