james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <server-...@james.apache.org>
Subject [jira] [Commented] (JAMES-2171) LogMessage mailet improvments
Date Fri, 28 Dec 2018 08:56:01 GMT

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

ASF GitHub Bot commented on JAMES-2171:
---------------------------------------

Github user chibenwa commented on a diff in the pull request:

    https://github.com/apache/james-project/pull/145#discussion_r244281616
  
    --- Diff: mailet/base/src/main/java/org/apache/mailet/base/MailetUtil.java ---
    @@ -96,19 +96,19 @@ public static String normalizeSubject(String subj, String prefix)
{
          * <p>Gets a boolean valued init parameter.</p>
          * @param config not null
          * @param name name of the init parameter to be queried
    -     * @return true when the init parameter is <code>true</code> (ignoring
case);
    -     * false when the init parameter is <code>false</code> (ignoring case);
    +     * @return true when the init parameter is <code>true</code>;
    +     * false when the init parameter is <code>false</code>;
    +     * throw an exception when the value is not of Boolean type;
          * otherwise the default value
          */
         public static Optional<Boolean> getInitParameter(MailetConfig config, String
name) {
    -        String value = config.getInitParameter(name);
    -        if ("true".equalsIgnoreCase(value)) {
    -            return Optional.of(true);
    +        Object value = config.getInitParameter(name, Boolean.class);
    +        if(value != null){
    +            if(Boolean.class.isInstance(value)){
    +                return Optional.of((Boolean)value);
    +            } else throw new ClassCastException(name + " property is not of type " +
Boolean.class);
             }
    -        if ("false".equalsIgnoreCase(value)) {
    -            return Optional.of(false);
    -        }
    -        return Optional.empty();
    +        else return Optional.empty();
    --- End diff --
    
    This will probably not pass the checkstyle rules. You need to explicitly define blocks
of code using `{}`


> LogMessage mailet improvments
> -----------------------------
>
>                 Key: JAMES-2171
>                 URL: https://issues.apache.org/jira/browse/JAMES-2171
>             Project: James Server
>          Issue Type: Improvement
>          Components: Mailet Contributions
>    Affects Versions: master
>            Reporter: Tellier Benoit
>            Priority: Major
>              Labels: easyfix, newbie
>
> Today, one can use the LogMessage to generate log messages upon mail reception
> But the LogMessage have the following limits:
>  - It do not let you configure the warn level
>  - It does generate several logs. One would be simpler to review.
>  - It does add some unneeded informations, like mail name already carried by the MDC
>  - It does not allow logging of specific headers or specific attributeNames. This leads
to missing information as well as "to much information".
>  - The code quality of the mailet is poor.
> You will:
>  - Ensure a single log message will be generated. For this you will call the logger one
time and concatenate log messages parts.
>  - Remove the log line with mail name.
>  - Add a **level** configuration option. It can takes value **warn**, **info**, **debug**
or **error**. It will be used to set the logger log level.
>  - Add a **specificHeaders** configuration option. It takes a comma separated list of
header names to include in the log message. By default it is empty.
>  - Add a **specificAttributes** configuration option.  It takes a comma separated list
of attribute names to be included in the log message. By default it is empty.
>  - **body** configuration option should be false by default
>  - **header** configuration option should be false by default
>  - **init** should propagate exception while initilizing (Integer parse exception, also
passing a negative max body should throw.)
>  - Remove inlined affectation for field. They can be unset on their declaration and set
when init is called.
> Correct *LogMessageTest* accordingly.
> Don't hesitate to reach us on the *gitter* chat if you have any question.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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


Mime
View raw message