You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2013/10/31 16:18:25 UTC

[06/17] git commit: TS-2302: merge Log::error into Log::va_error

TS-2302: merge Log::error into Log::va_error

These functions are supposed to be identical, but had diverged.
Merge them so that this  can't happen. Also add format checking to
Log::error().


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/62953539
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/62953539
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/62953539

Branch: refs/heads/master
Commit: 62953539abdb3aeefaab72650bb954836ed67450
Parents: 4952315
Author: James Peach <jp...@apache.org>
Authored: Wed Sep 25 11:47:07 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Oct 31 08:16:27 2013 -0700

----------------------------------------------------------------------
 proxy/http/HttpBodyFactory.cc |  4 +--
 proxy/logging/Log.cc          | 59 +++++++++-----------------------------
 proxy/logging/Log.h           |  4 +--
 3 files changed, 17 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/62953539/proxy/http/HttpBodyFactory.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpBodyFactory.cc b/proxy/http/HttpBodyFactory.cc
index bdd0448..ca0e7f1 100644
--- a/proxy/http/HttpBodyFactory.cc
+++ b/proxy/http/HttpBodyFactory.cc
@@ -149,8 +149,8 @@ HttpBodyFactory::fabricate_with_old_api(const char *type, HttpTransact::State *
   ///////////////////////////////////
   if (buffer && (*resulting_buffer_length > max_buffer_length)) {
     if (enable_logging) {
-      Log::error(("BODY_FACTORY: template '%s/%s' consumed %d bytes, "
-                  "exceeding %d byte limit, using internal default"),
+      Log::error(("BODY_FACTORY: template '%s/%s' consumed %" PRId64 " bytes, "
+                  "exceeding %" PRId64 " byte limit, using internal default"),
                  set, type, *resulting_buffer_length, max_buffer_length);
     }
     *resulting_buffer_length = 0;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/62953539/proxy/logging/Log.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index a74c826..ab81d86 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -24,7 +24,6 @@
 /***************************************************************************
  Log.cc
 
-
  This file defines the implementation of the static Log class, which is
  primarily used as a namespace.  That is, there are no Log objects, but the
  class scope and static members provide a protected namespace for all of
@@ -32,7 +31,6 @@
  widely-implemented, Log could be implemented as a namespace rather than a
  class.
 
-
  ***************************************************************************/
 #include "libts.h"
 
@@ -203,7 +201,6 @@ struct PeriodicWakeup : Continuation
   }
 };
 
-
 /*-------------------------------------------------------------------------
   Log::periodic_tasks
 
@@ -896,7 +893,6 @@ Log::init_fields()
   init_status |= FIELDS_INITIALIZED;
 }
 
-
 /*-------------------------------------------------------------------------
 
   Initialization functions
@@ -1170,57 +1166,24 @@ done:
 int
 Log::error(const char *format, ...)
 {
-  int ret_val = Log::SKIP;
-  ProxyMutex *mutex = this_ethread()->mutex;
-
-  if (error_log) {
-    ink_assert(format != NULL);
-    va_list ap;
-    va_start(ap, format);
-    ret_val = error_log->va_write(format, ap);
-    va_end(ap);
-
-    switch (ret_val) {
-    case Log::LOG_OK:
-      RecIncrRawStat(log_rsb, mutex->thread_holding,
-                     log_stat_event_log_error_ok_stat, 1);
-      break;
-    case Log::SKIP:
-      RecIncrRawStat(log_rsb, mutex->thread_holding,
-                     log_stat_event_log_error_skip_stat, 1);
-      break;
-    case Log::AGGR:
-      RecIncrRawStat(log_rsb, mutex->thread_holding,
-                     log_stat_event_log_error_aggr_stat, 1);
-      break;
-    case Log::FULL:
-      RecIncrRawStat(log_rsb, mutex->thread_holding,
-                     log_stat_event_log_error_full_stat, 1);
-      break;
-    case Log::FAIL:
-      RecIncrRawStat(log_rsb, mutex->thread_holding,
-                     log_stat_event_log_error_fail_stat, 1);
-      break;
-    default:
-      ink_release_assert(!"Unexpected result");
-    }
+  va_list ap;
+  int ret;
 
-    return ret_val;
-  }
+  va_start(ap, format);
+  ret = Log::va_error(format, ap);
+  va_end(ap);
 
-  RecIncrRawStat(log_rsb, mutex->thread_holding,
-                 log_stat_event_log_error_skip_stat, 1);
-  return ret_val;
+  return ret;
 }
 
 int
-Log::va_error(char *format, va_list ap)
+Log::va_error(const char *format, va_list ap)
 {
   int ret_val = Log::SKIP;
+  ProxyMutex *mutex = this_ethread()->mutex;
 
   if (error_log) {
     ink_assert(format != NULL);
-    ProxyMutex *mutex = this_ethread()->mutex; 
     ret_val = error_log->va_write(format, ap);
 
     switch (ret_val) {
@@ -1247,8 +1210,13 @@ Log::va_error(char *format, va_list ap)
     default:
       ink_release_assert(!"Unexpected result");
     }
+
+    return ret_val;
   }
 
+  RecIncrRawStat(log_rsb, mutex->thread_holding,
+                 log_stat_event_log_error_skip_stat, 1);
+
   return ret_val;
 }
 
@@ -1434,7 +1402,6 @@ Log::collate_thread_main(void * /* args ATS_UNUSED */)
   int sock_id;
   int new_client;
 
-
   Debug("log-thread", "Log collation thread is alive ...");
 
   Log::collate_notify.lock();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/62953539/proxy/logging/Log.h
----------------------------------------------------------------------
diff --git a/proxy/logging/Log.h b/proxy/logging/Log.h
index 07485d9..8f2292f 100644
--- a/proxy/logging/Log.h
+++ b/proxy/logging/Log.h
@@ -400,8 +400,8 @@ public:
   }
 
   inkcoreapi static int access(LogAccess * lad);
-  inkcoreapi static int error(const char *format, ...);
-  inkcoreapi static int va_error(char *format, va_list ap);
+  inkcoreapi static int va_error(const char *format, va_list ap);
+  inkcoreapi static int error(const char *format, ...) TS_PRINTFLIKE(1, 2);
 
   // public data members
   inkcoreapi static TextLogObject *error_log;