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 2016/08/31 18:20:50 UTC

[trafficserver] 02/02: TS-4423: Update Show Location Options.

This is an automated email from the ASF dual-hosted git repository.

jpeach pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit 5063618e2ad2d7c10a107f0eeaf4943c47b742fe
Author: Eric Schwartz <es...@inducedeuce.corp.gq1.yahoo.com>
AuthorDate: Thu Aug 25 20:39:11 2016 +0000

    TS-4423: Update Show Location Options.
    
    Don't show function / filename / line numbers on "operational logs".
    
    Previous behavior:
      0 - don't show any line numbers
      1 (DEFAULT) - show for all messages
    
    New behavior:
      0 - don't show any line numbers
      1 (DEFAULT) - show for Debug() messages only
      2 - show for all messages
    
    This closes #928.
---
 cmd/traffic_ctl/traffic_ctl.cc              | 2 +-
 doc/admin-guide/files/records.config.en.rst | 5 +++--
 lib/ts/Diags.cc                             | 4 ++--
 lib/ts/Diags.h                              | 8 +++++++-
 proxy/shared/DiagsConfig.cc                 | 4 ++--
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/cmd/traffic_ctl/traffic_ctl.cc b/cmd/traffic_ctl/traffic_ctl.cc
index 12224ed..c3559ac 100644
--- a/cmd/traffic_ctl/traffic_ctl.cc
+++ b/cmd/traffic_ctl/traffic_ctl.cc
@@ -240,7 +240,7 @@ main(int argc, const char **argv)
   if (debug) {
     diags->activate_taglist("traffic_ctl", DiagsTagType_Debug);
     diags->config.enabled[DiagsTagType_Debug] = true;
-    diags->show_location                      = true;
+    diags->show_location                      = SHOW_LOCATION_DEBUG;
   }
 
   CtrlDebug("debug logging active");
diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst
index 10852e8..104d030 100644
--- a/doc/admin-guide/files/records.config.en.rst
+++ b/doc/admin-guide/files/records.config.en.rst
@@ -2783,9 +2783,10 @@ Diagnostic Logging Configuration
 
         CONFIG proxy.config.diags.output.debug STRING SL
 
-.. ts:cv:: CONFIG proxy.config.diags.show_location INT 0
+.. ts:cv:: CONFIG proxy.config.diags.show_location INT 1
 
-   Annotates diagnostic messages with the source code location.
+   Annotates diagnostic messages with the source code location. Set to 1 to enable
+   for Debug() messages only. Set to 2 to enable for all messages.
 
 .. ts:cv:: CONFIG proxy.config.diags.debug.enabled INT 0
 
diff --git a/lib/ts/Diags.cc b/lib/ts/Diags.cc
index 71b5a09..7bf37bd 100644
--- a/lib/ts/Diags.cc
+++ b/lib/ts/Diags.cc
@@ -517,7 +517,7 @@ Diags::log(const char *tag, DiagsLevel level, const char *file, const char *func
 
   va_list ap;
   va_start(ap, format_string);
-  if (show_location) {
+  if (show_location == SHOW_LOCATION_ALL || (show_location == SHOW_LOCATION_DEBUG && level == DL_Debug)) {
     SourceLocation lp(file, func, line);
     print_va(tag, level, &lp, format_string, ap);
   } else {
@@ -535,7 +535,7 @@ Diags::error_va(DiagsLevel level, const char *file, const char *func, const int
     va_copy(ap2, ap);
   }
 
-  if (show_location) {
+  if (show_location == SHOW_LOCATION_ALL || (show_location == SHOW_LOCATION_DEBUG && level == DL_Debug)) {
     SourceLocation lp(file, func, line);
     print_va(NULL, level, &lp, format_string, ap);
   } else {
diff --git a/lib/ts/Diags.h b/lib/ts/Diags.h
index f898699..7d1f9c8 100644
--- a/lib/ts/Diags.h
+++ b/lib/ts/Diags.h
@@ -77,6 +77,12 @@ typedef enum {  // do not renumber --- used as array index
 
 enum RollingEnabledValues { NO_ROLLING = 0, ROLL_ON_TIME, ROLL_ON_SIZE, INVALID_ROLLING_VALUE };
 
+enum DiagsShowLocation {
+  SHOW_LOCATION_NONE = 0,
+  SHOW_LOCATION_DEBUG,
+  SHOW_LOCATION_ALL
+};
+
 #define DiagsLevel_Count DL_Undefined
 
 #define DiagsLevel_IsTerminal(_l) (((_l) >= DL_Fatal) && ((_l) < DL_Undefined))
@@ -168,7 +174,7 @@ public:
   {
     va_list ap;
     va_start(ap, format_string);
-    if (show_location) {
+    if (show_location == SHOW_LOCATION_ALL || (show_location == SHOW_LOCATION_DEBUG && dl == DL_Debug)) {
       SourceLocation lp(file, func, line);
       print_va(tag, dl, &lp, format_string, ap);
     } else {
diff --git a/proxy/shared/DiagsConfig.cc b/proxy/shared/DiagsConfig.cc
index 3dbb854..8b97f5d 100644
--- a/proxy/shared/DiagsConfig.cc
+++ b/proxy/shared/DiagsConfig.cc
@@ -84,7 +84,7 @@ DiagsConfig::reconfigure_diags()
   all_found = all_found && found;
 
   e                    = (int)REC_readInteger("proxy.config.diags.show_location", &found);
-  diags->show_location = ((e && found) ? 1 : 0);
+  diags->show_location = ((e == 1 && found) ? SHOW_LOCATION_DIAGS : ((e == 2 && found) ? SHOW_LOCATION_ALL : SHOW_LOCATION_NONE));
   all_found            = all_found && found;
 
   // read output routing values
@@ -248,7 +248,7 @@ DiagsConfig::RegisterDiagConfig()
   RecRegisterConfigString(RECT_CONFIG, "proxy.config.diags.debug.tags", "", RECU_NULL, RECC_NULL, NULL, REC_SOURCE_DEFAULT);
   RecRegisterConfigInt(RECT_CONFIG, "proxy.config.diags.action.enabled", 0, RECU_NULL, RECC_NULL, NULL, REC_SOURCE_DEFAULT);
   RecRegisterConfigString(RECT_CONFIG, "proxy.config.diags.action.tags", "", RECU_NULL, RECC_NULL, NULL, REC_SOURCE_DEFAULT);
-  RecRegisterConfigInt(RECT_CONFIG, "proxy.config.diags.show_location", 0, RECU_NULL, RECC_NULL, NULL, REC_SOURCE_DEFAULT);
+  RecRegisterConfigInt(RECT_CONFIG, "proxy.config.diags.show_location", 1, RECU_NULL, RECC_NULL, NULL, REC_SOURCE_DEFAULT);
   RecRegisterConfigString(RECT_CONFIG, "proxy.config.diags.output.diag", "L", RECU_NULL, RECC_NULL, NULL, REC_SOURCE_DEFAULT);
   RecRegisterConfigString(RECT_CONFIG, "proxy.config.diags.output.debug", "L", RECU_NULL, RECC_NULL, NULL, REC_SOURCE_DEFAULT);
   RecRegisterConfigString(RECT_CONFIG, "proxy.config.diags.output.status", "L", RECU_NULL, RECC_NULL, NULL, REC_SOURCE_DEFAULT);

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.