OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Recommendation for adding APLOGNO() before string format which is passed to ap_log_cerror()


Our team works on enhance logging practices by learning from historical log revisions in evolution. 
By mining historical patches, we find two patches that both add APLOGNO(*****) before the format string which is then passed to ap_log_cerror().

However, when apply this rule to httpd-2.4.27, we find one missed spot:
1) Line 1135 in httpd-2.4.27/modules/http2/h2_proxy_session.c
static void ev_proto_error(h2_proxy_session *session, int arg, const char *msg)
{
    switch (session->state) {
        case H2_PROXYS_ST_DONE:
        case H2_PROXYS_ST_LOCAL_SHUTDOWN:
            /* just leave */
            transit(session, "proto error", H2_PROXYS_ST_DONE);
            break;
        
        default:
            ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
                          "h2_proxy_session(%s): proto error -> shutdown", session->id);

Here are the two patches we find in evolution history:
1) Line 1829 in httpd/versions/httpd-2.4.20/modules/http2/h2_session.c
         case H2_SESSION_ST_LOCAL_SHUTDOWN:
             /* just leave */
             transit(session, "conn error", H2_SESSION_ST_DONE);
             break;
         
         default:
-            ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+            ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03401)
                           "h2_session(%ld): conn error -> shutdown", session->id);
             h2_session_shutdown(session, arg, msg, 0);
             break;
     }
 }

2) Line 1846 in httpd/versions/httpd-2.4.20/modules/http2/h2_session.c
         case H2_SESSION_ST_LOCAL_SHUTDOWN:
             /* just leave */
             transit(session, "proto error", H2_SESSION_ST_DONE);
             break;
         
         default:
-            ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+            ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03402)
                           "h2_session(%ld): proto error -> shutdown", session->id);
             h2_session_shutdown(session, arg, msg, 0);
             break;
     }
 }

By the way, we find the definition of APLOGNO() and its comments:
Line 117 of httpd-2.4.27/include/httpd-log.h 
/**
 * APLOGNO() should be used at the start of the format string passed
 * to ap_log_error() and friends. The argument must be a 5 digit decimal
 * number. It creates a tag of the form "AH02182: "
 * See docs/log-message-tags/README for details.
 */
#define APLOGNO(n)              "AH" #n ": "


Thanks for your reading and we are looking forward to your reply.
May you a good day!

Best regards,
Xu