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/12/10 20:26:18 UTC

[1/3] git commit: TS-2424: make g_diags private to RecDebug.cc

Updated Branches:
  refs/heads/master 39862b62a -> 536fb8e01


TS-2424: make g_diags private to RecDebug.cc


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

Branch: refs/heads/master
Commit: e510c586b3ee5121bf162add11ed5188dc70a80f
Parents: 39862b6
Author: James Peach <jp...@apache.org>
Authored: Mon Dec 9 16:15:31 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Tue Dec 10 11:22:07 2013 -0800

----------------------------------------------------------------------
 cmd/traffic_cop/traffic_cop.cc |  2 --
 lib/records/P_RecCore.h        |  2 --
 lib/records/RecCore.cc         | 16 ----------------
 lib/records/RecDebug.cc        | 15 +++++++++++++++
 4 files changed, 15 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e510c586/cmd/traffic_cop/traffic_cop.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_cop/traffic_cop.cc b/cmd/traffic_cop/traffic_cop.cc
index 564f070..21ea7d1 100644
--- a/cmd/traffic_cop/traffic_cop.cc
+++ b/cmd/traffic_cop/traffic_cop.cc
@@ -61,8 +61,6 @@ static const char COP_TRACE_FILE[] = "/tmp/traffic_cop.trace";
 #define COP_WARNING  LOG_ERR
 #define COP_DEBUG    LOG_DEBUG
 
-Diags * g_diags; // link time dependency
-
 static const char *root_dir;
 static const char *runtime_dir;
 static const char *config_dir;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e510c586/lib/records/P_RecCore.h
----------------------------------------------------------------------
diff --git a/lib/records/P_RecCore.h b/lib/records/P_RecCore.h
index 2d92f81..375f526 100644
--- a/lib/records/P_RecCore.h
+++ b/lib/records/P_RecCore.h
@@ -43,8 +43,6 @@ extern int g_num_update[];
 extern RecModeT g_mode_type;
 extern RecTree *g_records_tree;
 
-extern Diags *g_diags;
-
 // records.config items
 extern const char *g_rec_config_fpath;
 extern LLQ *g_rec_config_contents_llq;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e510c586/lib/records/RecCore.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 96cddfc..759dcef 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -31,8 +31,6 @@
 
 static bool g_initialized = false;
 
-Diags *g_diags = NULL;
-
 RecRecord *g_records = NULL;
 InkHashTable *g_records_ht = NULL;
 ink_rwlock g_records_rwlock;
@@ -216,20 +214,6 @@ RecCoreInit(RecModeT mode_type, Diags *_diags)
   return REC_ERR_OKAY;
 }
 
-
-//-------------------------------------------------------------------------
-// RecSetDiags
-//-------------------------------------------------------------------------
-int
-RecSetDiags(Diags * _diags)
-{
-  // Warning! It's very dangerous to change diags on the fly!  This
-  // function only exists so that we can boot-strap TM on startup.
-  ink_atomic_swap(&g_diags, _diags);
-  return REC_ERR_OKAY;
-}
-
-
 //-------------------------------------------------------------------------
 // RecLinkCnfigXXX
 //-------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e510c586/lib/records/RecDebug.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecDebug.cc b/lib/records/RecDebug.cc
index ec7f5da..836ff23 100644
--- a/lib/records/RecDebug.cc
+++ b/lib/records/RecDebug.cc
@@ -24,6 +24,21 @@
 #include "P_RecUtils.h"
 #include "P_RecCore.h"
 
+static Diags *g_diags = NULL;
+
+//-------------------------------------------------------------------------
+// RecSetDiags
+//-------------------------------------------------------------------------
+int
+RecSetDiags(Diags * _diags)
+{
+  // Warning! It's very dangerous to change diags on the fly!  This
+  // function only exists so that we can boot-strap TM on startup.
+  ink_atomic_swap(&g_diags, _diags);
+  return REC_ERR_OKAY;
+}
+
+
 //-------------------------------------------------------------------------
 // RecLog
 //-------------------------------------------------------------------------


[2/3] git commit: TS-2424: set diags log file for each caller

Posted by jp...@apache.org.
TS-2424: set diags log file for each caller

Since DiagsConfig.cc is built into a static library, we can't rely
on the preprocessor to determine what the diagnostic log file should
be. Add a filename to the constructor so that each usage uses an
explicit name.


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

Branch: refs/heads/master
Commit: 4b94cdfd7942595fc461344f1bae834672e84502
Parents: e510c58
Author: James Peach <jp...@apache.org>
Authored: Tue Dec 10 09:04:18 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Tue Dec 10 11:22:15 2013 -0800

----------------------------------------------------------------------
 mgmt/Main.cc                   |  5 +++--
 proxy/Main.cc                  |  5 +++--
 proxy/logging/LogStandalone.cc | 14 ++++++++++++--
 proxy/sac.cc                   |  5 ++++-
 proxy/shared/DiagsConfig.cc    | 20 ++++----------------
 proxy/shared/DiagsConfig.h     | 13 +++++++++----
 6 files changed, 35 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b94cdfd/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index 0219e68..2452f16 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -59,6 +59,7 @@
 #include <grp.h>
 
 #define FD_THROTTLE_HEADROOM (128 + 64) // TODO: consolidate with THROTTLE_FD_HEADROOM
+#define DIAGS_LOG_FILENAME "manager.log"
 
 #if defined(freebsd)
 extern "C" int getpwnam_r(const char *name, struct passwd *result, char *buffer, size_t buflen, struct passwd **resptr);
@@ -520,7 +521,7 @@ main(int argc, char **argv)
 
   // Bootstrap the Diags facility so that we can use it while starting
   //  up the manager
-  diagsConfig = NEW(new DiagsConfig(debug_tags, action_tags, false));
+  diagsConfig = NEW(new DiagsConfig(DIAGS_LOG_FILENAME, debug_tags, action_tags, false));
   diags = diagsConfig->diags;
   diags->prefix_str = "Manager ";
 
@@ -570,7 +571,7 @@ main(int argc, char **argv)
   }
   // INKqa11968: need to set up callbacks and diags data structures
   // using configuration in records.config
-  diagsConfig = NEW(new DiagsConfig(debug_tags, action_tags, true));
+  diagsConfig = NEW(new DiagsConfig(DIAGS_LOG_FILENAME, debug_tags, action_tags, true));
   diags = diagsConfig->diags;
   RecSetDiags(diags);
   diags->prefix_str = "Manager ";

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b94cdfd/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index bc7c2d5..b03465b 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -112,6 +112,7 @@ extern "C" int plock(int);
 #endif
 
 #define DEFAULT_REMOTE_MANAGEMENT_FLAG    0
+#define DIAGS_LOG_FILENAME                "diags.log"
 
 static const long MAX_LOGIN =  sysconf(_SC_LOGIN_NAME_MAX) <= 0 ? _POSIX_LOGIN_NAME_MAX :  sysconf(_SC_LOGIN_NAME_MAX);
 
@@ -1285,7 +1286,7 @@ main(int /* argc ATS_UNUSED */, char **argv)
   // re-start Diag completely) because at initialize, TM only has 1 thread.
   // In TS, some threads have already created, so if we delete Diag and
   // re-start it again, TS will crash.
-  diagsConfig = NEW(new DiagsConfig(error_tags, action_tags, false));
+  diagsConfig = NEW(new DiagsConfig(DIAGS_LOG_FILENAME, error_tags, action_tags, false));
   diags = diagsConfig->diags;
   diags->prefix_str = "Server ";
   if (is_debug_tag_set("diags"))
@@ -1347,7 +1348,7 @@ main(int /* argc ATS_UNUSED */, char **argv)
     RecDebugOff();
     delete(diagsConfig);
   }
-  diagsConfig = NEW(new DiagsConfig(error_tags, action_tags, true));
+  diagsConfig = NEW(new DiagsConfig(DIAGS_LOG_FILENAME, error_tags, action_tags, true));
   diags = diagsConfig->diags;
   RecSetDiags(diags);
   diags->prefix_str = "Server ";

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b94cdfd/proxy/logging/LogStandalone.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogStandalone.cc b/proxy/logging/LogStandalone.cc
index 5d79f80..931a254 100644
--- a/proxy/logging/LogStandalone.cc
+++ b/proxy/logging/LogStandalone.cc
@@ -42,6 +42,8 @@
 // Needs LibRecordsConfigInit()
 #include "RecordsConfig.h"
 
+#define LOG_FILENAME_SIZE 255
+
 class HttpBodyFactory;
 
 // globals the rest of the system depends on
@@ -196,11 +198,16 @@ check_lockfile()
 void
 init_log_standalone(const char *pgm_name, bool one_copy)
 {
+  char logfile[LOG_FILENAME_SIZE];
+
   // ensure that only one copy of the sac is running
   //
   if (one_copy) {
     check_lockfile();
   }
+
+  snprintf(logfile, sizeof(logfile), "%s.log", pgm_name);
+
   // set stdin/stdout to be unbuffered
   //
   setbuf(stdin, NULL);
@@ -210,7 +217,7 @@ init_log_standalone(const char *pgm_name, bool one_copy)
 
   init_system();
   initialize_process_manager();
-  diagsConfig = NEW(new DiagsConfig(error_tags, action_tags));
+  diagsConfig = NEW(new DiagsConfig(logfile, error_tags, action_tags));
   diags = diagsConfig->diags;
   diags_init = 1;
 }
@@ -232,11 +239,14 @@ init_log_standalone(const char *pgm_name, bool one_copy)
 void
 init_log_standalone_basic(const char *pgm_name)
 {
+  char logfile[LOG_FILENAME_SIZE];
+
+  snprintf(logfile, sizeof(logfile), "%s.log", pgm_name);
   openlog(pgm_name, LOG_PID | LOG_NDELAY | LOG_NOWAIT, LOG_DAEMON);
 
   init_system();
   const bool use_records = false;
-  diagsConfig = NEW(new DiagsConfig(error_tags, action_tags, use_records));
+  diagsConfig = NEW(new DiagsConfig(logfile, error_tags, action_tags, use_records));
   diags = diagsConfig->diags;
   // set stdin/stdout to be unbuffered
   //

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b94cdfd/proxy/sac.cc
----------------------------------------------------------------------
diff --git a/proxy/sac.cc b/proxy/sac.cc
index a9e4a9b..661b3cf 100644
--- a/proxy/sac.cc
+++ b/proxy/sac.cc
@@ -46,6 +46,8 @@
 #include "DiagsConfig.h"
 #include "I_Machine.h"
 
+#define DIAGS_LOG_FILENAME "collector.log"
+
 // sac-specific command-line flags
 //
 static int version_flag = 0;
@@ -90,8 +92,9 @@ main(int /* argc ATS_UNUSED */, char *argv[])
     _exit(0);
   }
 
-  diagsConfig = NEW(new DiagsConfig(error_tags, action_tags, false));
+  diagsConfig = NEW(new DiagsConfig(DIAGS_LOG_FILENAME, error_tags, action_tags, false));
   diags = diagsConfig->diags;
+  diags->prefix_str = "Collector ";
 
   // initialize this application for standalone logging operation
   //

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b94cdfd/proxy/shared/DiagsConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/shared/DiagsConfig.cc b/proxy/shared/DiagsConfig.cc
index 3cb6a3d..6576ff9 100644
--- a/proxy/shared/DiagsConfig.cc
+++ b/proxy/shared/DiagsConfig.cc
@@ -24,18 +24,6 @@
 #include "libts.h"
 #include "I_Layout.h"
 #include "DiagsConfig.h"
-#ifdef LOCAL_MANAGER
-
-#include "mgmt/Main.h"
-#define DIAGS_LOG_FILE "manager.log"
-
-#else
-#include "proxy/Main.h"
-#include "ProxyConfig.h"
-#define DIAGS_LOG_FILE "diags.log"
-
-#endif
-
 #include "P_RecCore.h"
 
 
@@ -285,7 +273,7 @@ DiagsConfig::RegisterDiagConfig()
 }
 
 
-DiagsConfig::DiagsConfig(char *bdt, char *bat, bool use_records)
+DiagsConfig::DiagsConfig(const char * filename, const char * tags, const char * actions, bool use_records)
 {
   char diags_logpath[PATH_NAME_MAX + 1];
   xptr<char> logpath;
@@ -301,7 +289,7 @@ DiagsConfig::DiagsConfig(char *bdt, char *bat, bool use_records)
   ////////////////////////////////////////////////////////////////////
 
   if (!use_records) {
-    diags = NEW(new Diags(bdt, bat, NULL));
+    diags = NEW(new Diags(tags, actions, NULL));
     config_diags_norecords();
     return;
   }
@@ -317,7 +305,7 @@ DiagsConfig::DiagsConfig(char *bdt, char *bat, bool use_records)
     _exit(1);
   }
 
-  ink_filepath_make(diags_logpath, sizeof(diags_logpath), logpath, DIAGS_LOG_FILE);
+  ink_filepath_make(diags_logpath, sizeof(diags_logpath), logpath, filename);
 
   // open write append
   // diags_log_fp = fopen(diags_logpath,"w");
@@ -331,7 +319,7 @@ DiagsConfig::DiagsConfig(char *bdt, char *bat, bool use_records)
     }
   }
 
-  diags = NEW(new Diags(bdt, bat, diags_log_fp));
+  diags = NEW(new Diags(tags, actions, diags_log_fp));
   if (diags_log_fp == NULL) {
 
     diags->print(NULL, DTA(DL_Warning),

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b94cdfd/proxy/shared/DiagsConfig.h
----------------------------------------------------------------------
diff --git a/proxy/shared/DiagsConfig.h b/proxy/shared/DiagsConfig.h
index b5a69b9..730d134 100644
--- a/proxy/shared/DiagsConfig.h
+++ b/proxy/shared/DiagsConfig.h
@@ -27,17 +27,22 @@
 
 struct DiagsConfig
 {
-  bool callbacks_established;
-  FILE *diags_log_fp;
-  Diags *diags;
 
   void reconfigure_diags();
   void config_diags_norecords();
   void parse_output_string(char *s, DiagsModeOutput * o);
   void RegisterDiagConfig();
   void register_diags_callbacks();
-    DiagsConfig(char *bdt, char *bat, bool use_records = true);
+
+  DiagsConfig(const char * filename, const char * tags, const char * actions, bool use_records = true);
    ~DiagsConfig();
+
+private:
+  bool callbacks_established;
+  FILE *diags_log_fp;
+
+public:
+  Diags *diags;
 };
 
 


[3/3] git commit: TS-2424: document diagnostic logging configuration

Posted by jp...@apache.org.
TS-2424: document diagnostic logging configuration


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

Branch: refs/heads/master
Commit: 536fb8e018c5556e5e12ce42f4c5011b84fdcf2e
Parents: 4b94cdf
Author: James Peach <jp...@apache.org>
Authored: Tue Dec 10 11:21:42 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Tue Dec 10 11:25:41 2013 -0800

----------------------------------------------------------------------
 .../configuration/records.config.en.rst         | 53 ++++++++++++++++----
 .../unable-to-debug-tags.en.rst                 |  4 +-
 2 files changed, 45 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/536fb8e0/doc/reference/configuration/records.config.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/configuration/records.config.en.rst b/doc/reference/configuration/records.config.en.rst
index bbe1a4d..9d9cb39 100644
--- a/doc/reference/configuration/records.config.en.rst
+++ b/doc/reference/configuration/records.config.en.rst
@@ -1796,14 +1796,20 @@ server, refer to `logs_xml.config <logs_xml.config>`_.
 Diagnostic Logging Configuration
 ================================
 
-.. ts:cv:: CONFIG proxy.config.diags.output.status STRING
-
-.. ts:cv:: CONFIG proxy.config.diags.output.warning STRING
-
-.. ts:cv:: CONFIG proxy.config.diags.output.emergency STRING
-
-   control where Traffic Server should log diagnostic output. Messages at diagnostic level can be directed to any combination of diagnostic
-   destinations. Valid diagnostic message destinations are:::
+.. ts:cv:: CONFIG proxy.config.diags.output.diag STRING E
+.. ts:cv:: CONFIG proxy.config.diags.output.debug STRING E
+.. ts:cv:: CONFIG proxy.config.diags.output.status STRING L
+.. ts:cv:: CONFIG proxy.config.diags.output.note STRING L
+.. ts:cv:: CONFIG proxy.config.diags.output.warning STRING L
+.. ts:cv:: CONFIG proxy.config.diags.output.error STRING SL
+.. ts:cv:: CONFIG proxy.config.diags.output.fatal STRING SL
+.. ts:cv:: CONFIG proxy.config.diags.output.alert STRING L
+.. ts:cv:: CONFIG proxy.config.diags.output.emergency STRING SL
+
+   The diagnosic output configuration variables control where Traffic
+   Server should log diagnostic output. Messages at each diagnostic level
+   can be directed to any combination of diagnostic destinations.
+   Valid diagnostic message destinations are:
 
    * 'O' = Log to standard output
    * 'E' = Log to standard error
@@ -1812,9 +1818,36 @@ Diagnostic Logging Configuration
 
 .. topic:: Example
 
-   To log debug diagnostics to both syslog and diags.log:::
+   To log debug diagnostics to both syslog and `diags.log`::
+
+        CONFIG proxy.config.diags.output.debug STRING SL
+
+.. ts:cv:: CONFIG proxy.config.diags.show_location INT 0
+
+   Annotates diagnostic messages with the source code location.
+
+.. ts:cv:: CONFIG proxy.config.diags.debug.enabled INT 0
+
+   Enables logging for diagnostic messages whose log level is `diag` or `debug`.
+
+.. ts:cv:: CONFIG proxy.config.diags.debug.tags STRING NULL
+
+   Each Traffic Server `diag` and `debug` level message is annotated
+   with a subsytem tag. This configuration contains a regular
+   expression that filters the messages based on the tag. Some
+   commonly used debug tags are::
+
+============  =====================================================
+Tag           Subsytem usage
+============  =====================================================
+ssl           TLS termination and certificate processing
+dns           DNS query resolution
+http_hdrs     Logs the headers for HTTP requests and responses
+============  =====================================================
 
-        proxy.config.diags.output.debug STRING SL
+  Traffic Server plugins will typically log debug messages using
+  the :func:`TSDebug` API, passing the plugin name as the debug
+  tag.
 
 Reverse Proxy
 =============

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/536fb8e0/doc/sdk/troubleshooting-tips/unable-to-debug-tags.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/troubleshooting-tips/unable-to-debug-tags.en.rst b/doc/sdk/troubleshooting-tips/unable-to-debug-tags.en.rst
index 5ed5877..745712a 100644
--- a/doc/sdk/troubleshooting-tips/unable-to-debug-tags.en.rst
+++ b/doc/sdk/troubleshooting-tips/unable-to-debug-tags.en.rst
@@ -43,8 +43,8 @@ Set the following variables in :file:`records.config` (in the Traffic Server
 ::
 
        :::text
-       proxy.config.diags.debug.enabled INT 1
-       proxy.config.diags.debug.tags STRING debug-tag-name
+       CONFIG proxy.config.diags.debug.enabled INT 1
+       CONFIG proxy.config.diags.debug.tags STRING debug-tag-name
 
 In this case, debug output goes to ``traffic.out``.