trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject git commit: TS-1887: make diagnostic location logging more succinct
Date Fri, 10 May 2013 20:25:52 GMT
Updated Branches:
  refs/heads/master 1490f9f8a -> d2843e077


TS-1887: make diagnostic location logging more succinct


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

Branch: refs/heads/master
Commit: d2843e07760dd436b5681dfa93f66ce07b3cc6ff
Parents: 1490f9f
Author: James Peach <jpeach@apache.org>
Authored: Fri May 10 13:25:03 2013 -0700
Committer: James Peach <jpeach@apache.org>
Committed: Fri May 10 13:25:03 2013 -0700

----------------------------------------------------------------------
 CHANGES         |    2 ++
 lib/ts/Diags.cc |   16 +++++++++++-----
 lib/ts/Diags.h  |   19 ++++++++++---------
 3 files changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d2843e07/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index f501e75..05d69a8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.3
 
 
+  *) [TS-1887] Make diagnostic location logging more succinct.
+
   *) [TS-1884] Remove deprecated IPv4-only NetProcessor API.
 
   *) [TS-1444] [TS-1881] URL lookup with regex through the web interface was broken.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d2843e07/lib/ts/Diags.cc
----------------------------------------------------------------------
diff --git a/lib/ts/Diags.cc b/lib/ts/Diags.cc
index 92c358a..3ccd355 100644
--- a/lib/ts/Diags.cc
+++ b/lib/ts/Diags.cc
@@ -64,14 +64,20 @@ inkcoreapi Diags *diags = NULL;
 //////////////////////////////////////////////////////////////////////////////
 
 char *
-SrcLoc::str(char *buf, int buflen)
+SrcLoc::str(char *buf, int buflen) const
 {
-  if (!valid || buflen < 1)
+  const char * shortname;
+
+  if (!this->valid() || buflen < 1)
     return (NULL);
+
+  shortname = strrchr(file, '/');
+  shortname = shortname ? (shortname + 1) : file;
+
   if (func != NULL) {
-    snprintf(buf, buflen, "%s:%d (%s)", file, line, func);
+    snprintf(buf, buflen, "%s:%d (%s)", shortname, line, func);
   } else {
-    snprintf(buf, buflen, "%s:%d", file, line);
+    snprintf(buf, buflen, "%s:%d", shortname, line);
   }
   buf[buflen - 1] = NUL;
   return (buf);
@@ -220,7 +226,7 @@ Diags::print_va(const char *debug_tag, DiagsLevel diags_level ,SrcLoc
*loc,
   // append location, if any //
   /////////////////////////////
 
-  if (loc && loc->valid) {
+  if (loc && loc->valid()) {
     char *lp, buf[256];
     lp = loc->str(buf, sizeof(buf));
     if (lp) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d2843e07/lib/ts/Diags.h
----------------------------------------------------------------------
diff --git a/lib/ts/Diags.h b/lib/ts/Diags.h
index 7614e52..b669bb4 100644
--- a/lib/ts/Diags.h
+++ b/lib/ts/Diags.h
@@ -103,30 +103,31 @@ struct DiagsConfigState
 class SrcLoc
 {
 public:
-  bool valid;
   const char *file;
   const char *func;
   int line;
 
-  void set(const char *_file, const char *_func, int _line)
-  {
-    valid = true;
+  void set(const char *_file, const char *_func, int _line) {
     file = _file;
     func = _func;
     line = _line;
   }
 
-  SrcLoc(const char *_file, const char *_func, int _line)
-  {
+  bool valid() const {
+    return file && line;
+  }
+
+  SrcLoc(const char *_file, const char *_func, int _line) {
     set(_file, _func, _line);
   }
 
-SrcLoc():valid(false), file(NULL), func(NULL), line(0) {
+  SrcLoc(): file(NULL), func(NULL), line(0) {
   }
+
   ~SrcLoc() {
-  };
+  }
 
-  char *str(char *buf, int buflen);
+  char * str(char *buf, int buflen) const;
 };
 
 


Mime
View raw message