logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Nikki (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LOG4J2-599) Support lambda functions (or similar) for log message parameters
Date Fri, 07 Aug 2015 08:05:46 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14661470#comment-14661470
] 

Jukka Nikki edited comment on LOG4J2-599 at 8/7/15 8:05 AM:
------------------------------------------------------------

I personally find names which refer to functionality better than ones referring technology,
and would question if "Lambda" as term is expressing well which is aim of "LambdaLogger".
I personally would feel comfortable with name like "LazyLogger" instead -- even if my need
is really to use it with lambdas. 

Callable can be used here, but as it's signature is "V call() throws Exception" I doubt it
could be better idea to craft own Interface instead and define that lazy evaluation of parameters
shouldn't propagate exceptions (at least checked) to caller. 

There might be also variants of evaluators, like one for whole message like "LazyMessageEvaluator"
having "String evaluate ()", in addition to evaluators for parameters like "LazyParameterEvaluator<T>"
having "T evaluate ()".

IMHO: if "LazyLogger" (Or "LambdaLogger") works as concept (minor addition, 2.X) it could
make sense to take concept of it to 3.0 and add Lazy functionality to Logger interface itself
then.


was (Author: nikkijuk):
I personally find names which refer to functionality better than ones referring technology,
and would question if "Lambda" as term is expressing well which is aim of "LambdaLogger".
I personally would feel comfortable with name like "LazyLogger" instead -- even if my need
is really to use it with lambdas. 

Callable can be used here, but as it's signature is "V call() throws Exception" I doubt it
could be better idea to craft own Interface instead and define that lazy evaluation of parameters
shouldn't propagate exceptions (at least checked) to caller. 

There might be also variants of evaluators, like one for whole message like "LazyMessageEvaluator<T>"
having "String evaluate (T)", in addition to evaluators for parameters like "LazyParameterEvaluator<T,R>"
having "R evaluate (T)".

IMHO: if "LazyLogger" (Or "LambdaLogger") works as concept (minor addition, 2.X) it could
make sense to take concept of it to 3.0 and add Lazy functionality to Logger interface itself
then.

> Support lambda functions (or similar) for log message parameters
> ----------------------------------------------------------------
>
>                 Key: LOG4J2-599
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-599
>             Project: Log4j 2
>          Issue Type: Brainstorming
>          Components: Core
>            Reporter: Matt Sicker
>            Priority: Minor
>              Labels: Java8
>
> It would be nice if we could support 0-param lambda functions (or the equivalent: interfaces
with a single empty-parameter message call), or more simply, allow Runnables (or something
similar) to be passed which will be dynamically executed if the log message is enabled.
> The use case here is that although string construction of the log message is a performance
issue that is already solved quite well, the problem of adding in information to the log message
that makes other calculations still needs to be wrapped in an if check.
> I'm not sure if it'd be best to just use Runnable, or create a new interface, or try
to emulate how Java 1.8 lambdas work via an interface with a single method defined. The details
here would still need to be fleshed out, but I think this sort of feature could be rather
handy (especially in a Java 1.8+ environment, or in Groovy/Scala/etc.).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message