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 2015/12/13 19:41:44 UTC
trafficserver git commit: TS-4073: remove duplicated diagnostics
Repository: trafficserver
Updated Branches:
refs/heads/master 805ba78e4 -> 596512ecf
TS-4073: remove duplicated diagnostics
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/596512ec
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/596512ec
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/596512ec
Branch: refs/heads/master
Commit: 596512ecfae94beb5fca3f761e7230d0d9abf82a
Parents: 805ba78
Author: James Peach <jp...@apache.org>
Authored: Sun Dec 13 10:40:40 2015 -0800
Committer: James Peach <jp...@apache.org>
Committed: Sun Dec 13 10:41:16 2015 -0800
----------------------------------------------------------------------
iocore/aio/test_AIO.cc | 73 +------------------------
iocore/cluster/test_I_Cluster.cc | 96 +--------------------------------
iocore/cluster/test_P_Cluster.cc | 96 +--------------------------------
iocore/dns/test_I_DNS.cc | 95 +--------------------------------
iocore/eventsystem/test_Buffer.cc | 81 +---------------------------
iocore/eventsystem/test_Event.cc | 82 ++--------------------------
iocore/hostdb/test_I_HostDB.cc | 95 +--------------------------------
iocore/net/test_I_Net.cc | 95 +--------------------------------
iocore/net/test_I_UDPNet.cc | 97 +---------------------------------
iocore/net/test_P_UDPNet.cc | 97 +---------------------------------
iocore/utils/diags.i | 41 ++++----------
11 files changed, 22 insertions(+), 926 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/596512ec/iocore/aio/test_AIO.cc
----------------------------------------------------------------------
diff --git a/iocore/aio/test_AIO.cc b/iocore/aio/test_AIO.cc
index 63f1bfb..3e86a0c 100644
--- a/iocore/aio/test_AIO.cc
+++ b/iocore/aio/test_AIO.cc
@@ -30,9 +30,6 @@
using std::cout;
using std::endl;
-Diags *diags;
-#define DIAGS_LOG_FILE "diags.log"
-
// Necessary for AIO
#if defined(solaris)
int net_config_poll_timeout = 30;
@@ -40,75 +37,7 @@ int net_config_poll_timeout = 30;
int net_config_poll_timeout = 10;
#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// void reconfigure_diags()
-//
-// This function extracts the current diags configuration settings from
-// records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void
-reconfigure_diags()
-{
- int i;
- DiagsConfigState c;
-
- // initial value set to 0 or 1 based on command line tags
- c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
- c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
- c.enabled[DiagsTagType_Debug] = 1;
- c.enabled[DiagsTagType_Action] = 1;
- diags->show_location = 1;
-
- // read output routing values
- for (i = 0; i < DiagsLevel_Count; i++) {
- c.outputs[i].to_stdout = 0;
- c.outputs[i].to_stderr = 1;
- c.outputs[i].to_syslog = 1;
- c.outputs[i].to_diagslog = 1;
- }
-
- //////////////////////////////
- // clear out old tag tables //
- //////////////////////////////
-
- diags->deactivate_all(DiagsTagType_Debug);
- diags->deactivate_all(DiagsTagType_Action);
-
- //////////////////////////////////////////////////////////////////////
- // add new tag tables
- //////////////////////////////////////////////////////////////////////
-
- if (diags->base_debug_tags)
- diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
- if (diags->base_action_tags)
- diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-////////////////////////////////////
-// change the diags config values //
-////////////////////////////////////
-#if !defined(__GNUC__) && !defined(hpux)
- diags->config = c;
-#else
- memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
-#endif
-}
-
-static void
-init_diags(const char *bdt, const char *bat)
-{
- char diags_logpath[500];
- strcpy(diags_logpath, DIAGS_LOG_FILE);
-
- BaseLogFile *blf = new BaseLogFile(diags_logpath);
- diags = new Diags(bdt, bat, blf);
-
- reconfigure_diags();
-}
+#include "diags.i"
#define MAX_DISK_THREADS 200
#ifdef DISK_ALIGN
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/596512ec/iocore/cluster/test_I_Cluster.cc
----------------------------------------------------------------------
diff --git a/iocore/cluster/test_I_Cluster.cc b/iocore/cluster/test_I_Cluster.cc
index fb10885..ea75e6b 100644
--- a/iocore/cluster/test_I_Cluster.cc
+++ b/iocore/cluster/test_I_Cluster.cc
@@ -32,101 +32,7 @@
#include <iostream.h>
#include <fstream.h>
-Diags *diags;
-#define DIAGS_LOG_FILE "diags.log"
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// void reconfigure_diags()
-//
-// This function extracts the current diags configuration settings from
-// records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void
-reconfigure_diags()
-{
- int i;
- DiagsConfigState c;
-
-
- // initial value set to 0 or 1 based on command line tags
- c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
- c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
- c.enabled[DiagsTagType_Debug] = 1;
- c.enabled[DiagsTagType_Action] = 1;
- diags->show_location = 1;
-
-
- // read output routing values
- for (i = 0; i < DiagsLevel_Count; i++) {
- c.outputs[i].to_stdout = 0;
- c.outputs[i].to_stderr = 1;
- c.outputs[i].to_syslog = 1;
- c.outputs[i].to_diagslog = 1;
- }
-
- //////////////////////////////
- // clear out old tag tables //
- //////////////////////////////
-
- diags->deactivate_all(DiagsTagType_Debug);
- diags->deactivate_all(DiagsTagType_Action);
-
- //////////////////////////////////////////////////////////////////////
- // add new tag tables
- //////////////////////////////////////////////////////////////////////
-
- if (diags->base_debug_tags)
- diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
- if (diags->base_action_tags)
- diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-////////////////////////////////////
-// change the diags config values //
-////////////////////////////////////
-// XXX: HP-UX ???
-#if !defined(__GNUC__) && !defined(hpux)
- diags->config = c;
-#else
- memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
-#endif
-}
-
-
-static void
-init_diags(char *bdt, char *bat)
-{
- FILE *diags_log_fp;
- char diags_logpath[500];
- ink_strlcpy(diags_logpath, DIAGS_LOG_FILE, sizeof(diags_logpath));
-
- diags_log_fp = fopen(diags_logpath, "w");
- if (diags_log_fp) {
- int status;
- status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
- if (status != 0) {
- fclose(diags_log_fp);
- diags_log_fp = NULL;
- }
- }
-
- diags = new Diags(bdt, bat, diags_log_fp);
-
- if (diags_log_fp == NULL) {
- SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
-
- diags->print(NULL, DL_Warning, NULL, &loc, "couldn't open diags log file '%s', "
- "will not log to this file",
- diags_logpath);
- }
-
- diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
- reconfigure_diags();
-}
-
+#include "diags.i"
int
main(int argc, char *argv[])
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/596512ec/iocore/cluster/test_P_Cluster.cc
----------------------------------------------------------------------
diff --git a/iocore/cluster/test_P_Cluster.cc b/iocore/cluster/test_P_Cluster.cc
index fb10885..ea75e6b 100644
--- a/iocore/cluster/test_P_Cluster.cc
+++ b/iocore/cluster/test_P_Cluster.cc
@@ -32,101 +32,7 @@
#include <iostream.h>
#include <fstream.h>
-Diags *diags;
-#define DIAGS_LOG_FILE "diags.log"
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// void reconfigure_diags()
-//
-// This function extracts the current diags configuration settings from
-// records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void
-reconfigure_diags()
-{
- int i;
- DiagsConfigState c;
-
-
- // initial value set to 0 or 1 based on command line tags
- c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
- c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
- c.enabled[DiagsTagType_Debug] = 1;
- c.enabled[DiagsTagType_Action] = 1;
- diags->show_location = 1;
-
-
- // read output routing values
- for (i = 0; i < DiagsLevel_Count; i++) {
- c.outputs[i].to_stdout = 0;
- c.outputs[i].to_stderr = 1;
- c.outputs[i].to_syslog = 1;
- c.outputs[i].to_diagslog = 1;
- }
-
- //////////////////////////////
- // clear out old tag tables //
- //////////////////////////////
-
- diags->deactivate_all(DiagsTagType_Debug);
- diags->deactivate_all(DiagsTagType_Action);
-
- //////////////////////////////////////////////////////////////////////
- // add new tag tables
- //////////////////////////////////////////////////////////////////////
-
- if (diags->base_debug_tags)
- diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
- if (diags->base_action_tags)
- diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-////////////////////////////////////
-// change the diags config values //
-////////////////////////////////////
-// XXX: HP-UX ???
-#if !defined(__GNUC__) && !defined(hpux)
- diags->config = c;
-#else
- memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
-#endif
-}
-
-
-static void
-init_diags(char *bdt, char *bat)
-{
- FILE *diags_log_fp;
- char diags_logpath[500];
- ink_strlcpy(diags_logpath, DIAGS_LOG_FILE, sizeof(diags_logpath));
-
- diags_log_fp = fopen(diags_logpath, "w");
- if (diags_log_fp) {
- int status;
- status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
- if (status != 0) {
- fclose(diags_log_fp);
- diags_log_fp = NULL;
- }
- }
-
- diags = new Diags(bdt, bat, diags_log_fp);
-
- if (diags_log_fp == NULL) {
- SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
-
- diags->print(NULL, DL_Warning, NULL, &loc, "couldn't open diags log file '%s', "
- "will not log to this file",
- diags_logpath);
- }
-
- diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
- reconfigure_diags();
-}
-
+#include "diags.i"
int
main(int argc, char *argv[])
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/596512ec/iocore/dns/test_I_DNS.cc
----------------------------------------------------------------------
diff --git a/iocore/dns/test_I_DNS.cc b/iocore/dns/test_I_DNS.cc
index 0ddcb8f..be310dd 100644
--- a/iocore/dns/test_I_DNS.cc
+++ b/iocore/dns/test_I_DNS.cc
@@ -23,101 +23,8 @@
#include <stdio.h>
#include "I_DNS.h"
-Diags *diags;
-#define DIAGS_LOG_FILE "diags.log"
-//#define USE_SOCKS
-//////////////////////////////////////////////////////////////////////////////
-//
-// void reconfigure_diags()
-//
-// This function extracts the current diags configuration settings from
-// records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void
-reconfigure_diags()
-{
- int i, e;
- char *p, *dt, *at;
- DiagsConfigState c;
-
-
- // initial value set to 0 or 1 based on command line tags
- c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
- c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
- c.enabled[DiagsTagType_Debug] = 1;
- c.enabled[DiagsTagType_Action] = 1;
- diags->show_location = 1;
-
-
- // read output routing values
- for (i = 0; i < DiagsLevel_Count; i++) {
- c.outputs[i].to_stdout = 0;
- c.outputs[i].to_stderr = 1;
- c.outputs[i].to_syslog = 1;
- c.outputs[i].to_diagslog = 1;
- }
-
- //////////////////////////////
- // clear out old tag tables //
- //////////////////////////////
-
- diags->deactivate_all(DiagsTagType_Debug);
- diags->deactivate_all(DiagsTagType_Action);
-
- //////////////////////////////////////////////////////////////////////
- // add new tag tables
- //////////////////////////////////////////////////////////////////////
-
- if (diags->base_debug_tags)
- diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
- if (diags->base_action_tags)
- diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-////////////////////////////////////
-// change the diags config values //
-////////////////////////////////////
-#if !defined(__GNUC__) && !defined(hpux)
- diags->config = c;
-#else
- memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
-#endif
-}
-
-
-static void
-init_diags(char *bdt, char *bat)
-{
- FILE *diags_log_fp;
- char diags_logpath[500];
- ink_strlcpy(diags_logpath, DIAGS_LOG_FILE, sizeof(diags_logpath));
-
- diags_log_fp = fopen(diags_logpath, "w");
- if (diags_log_fp) {
- int status;
- status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
- if (status != 0) {
- fclose(diags_log_fp);
- diags_log_fp = NULL;
- }
- }
-
- diags = new Diags(bdt, bat, diags_log_fp);
-
- if (diags_log_fp == NULL) {
- SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
-
- diags->print(NULL, DL_Warning, NULL, &loc, "couldn't open diags log file '%s', "
- "will not log to this file",
- diags_logpath);
- }
-
- diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
- reconfigure_diags();
-}
+#include "diags.i"
main()
{
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/596512ec/iocore/eventsystem/test_Buffer.cc
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/test_Buffer.cc b/iocore/eventsystem/test_Buffer.cc
index aabd0ce..775738f 100644
--- a/iocore/eventsystem/test_Buffer.cc
+++ b/iocore/eventsystem/test_Buffer.cc
@@ -25,88 +25,11 @@
#include "ts/I_Layout.h"
#include "ts/ink_string.h"
+#include "diags.i"
+
#define TEST_TIME_SECOND 60
#define TEST_THREADS 2
-Diags *diags;
-#define DIAGS_LOG_FILE "diags.log"
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// void reconfigure_diags()
-//
-// This function extracts the current diags configuration settings from
-// records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void
-reconfigure_diags()
-{
- int i;
- DiagsConfigState c;
-
- // initial value set to 0 or 1 based on command line tags
- c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
- c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
- c.enabled[DiagsTagType_Debug] = 1;
- c.enabled[DiagsTagType_Action] = 1;
- diags->show_location = 1;
-
- // read output routing values
- for (i = 0; i < DiagsLevel_Count; i++) {
- c.outputs[i].to_stdout = 0;
- c.outputs[i].to_stderr = 1;
- c.outputs[i].to_syslog = 1;
- c.outputs[i].to_diagslog = 1;
- }
-
- //////////////////////////////
- // clear out old tag tables //
- //////////////////////////////
-
- diags->deactivate_all(DiagsTagType_Debug);
- diags->deactivate_all(DiagsTagType_Action);
-
- //////////////////////////////////////////////////////////////////////
- // add new tag tables
- //////////////////////////////////////////////////////////////////////
-
- if (diags->base_debug_tags)
- diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
- if (diags->base_action_tags)
- diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-////////////////////////////////////
-// change the diags config values //
-////////////////////////////////////
-#if !defined(__GNUC__) && !defined(hpux)
- diags->config = c;
-#else
- memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
-#endif
-}
-
-static void
-init_diags(const char *bdt, const char *bat)
-{
- char diags_logpath[500];
- ink_strlcpy(diags_logpath, DIAGS_LOG_FILE, sizeof(diags_logpath));
-
- BaseLogFile *blf = new BaseLogFile(diags_logpath);
- diags = new Diags(bdt, bat, blf);
-
- if (blf == NULL || blf->m_fp == NULL) {
- Warning("couldn't open diags log file '%s', "
- "will not log to this file",
- diags_logpath);
- }
-
- Status("opened %s", diags_logpath);
- reconfigure_diags();
-}
-
int
main(int /* argc ATS_UNUSED */, const char * /* argv ATS_UNUSED */ [])
{
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/596512ec/iocore/eventsystem/test_Event.cc
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/test_Event.cc b/iocore/eventsystem/test_Event.cc
index 3f2172e..8185afa 100644
--- a/iocore/eventsystem/test_Event.cc
+++ b/iocore/eventsystem/test_Event.cc
@@ -24,88 +24,12 @@
#include "I_EventSystem.h"
#include "ts/I_Layout.h"
+#include "diags.i"
+
#define TEST_TIME_SECOND 60
#define TEST_THREADS 2
-int count;
-Diags *diags;
-#define DIAGS_LOG_FILE "diags.log"
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// void reconfigure_diags()
-//
-// This function extracts the current diags configuration settings from
-// records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void
-reconfigure_diags()
-{
- int i;
- DiagsConfigState c;
-
- // initial value set to 0 or 1 based on command line tags
- c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
- c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
- c.enabled[DiagsTagType_Debug] = 1;
- c.enabled[DiagsTagType_Action] = 1;
- diags->show_location = 1;
-
- // read output routing values
- for (i = 0; i < DiagsLevel_Count; i++) {
- c.outputs[i].to_stdout = 0;
- c.outputs[i].to_stderr = 1;
- c.outputs[i].to_syslog = 1;
- c.outputs[i].to_diagslog = 1;
- }
-
- //////////////////////////////
- // clear out old tag tables //
- //////////////////////////////
-
- diags->deactivate_all(DiagsTagType_Debug);
- diags->deactivate_all(DiagsTagType_Action);
-
- //////////////////////////////////////////////////////////////////////
- // add new tag tables
- //////////////////////////////////////////////////////////////////////
-
- if (diags->base_debug_tags)
- diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
- if (diags->base_action_tags)
- diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-////////////////////////////////////
-// change the diags config values //
-////////////////////////////////////
-#if !defined(__GNUC__) && !defined(hpux)
- diags->config = c;
-#else
- memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
-#endif
-}
-
-static void
-init_diags(const char *bdt, const char *bat)
-{
- char diags_logpath[500];
- strcpy(diags_logpath, DIAGS_LOG_FILE);
-
- BaseLogFile *blf = new BaseLogFile(diags_logpath);
- diags = new Diags(bdt, bat, blf);
-
- if (blf == NULL || blf->m_fp == NULL) {
- Warning("couldn't open diags log file '%s', "
- "will not log to this file",
- diags_logpath);
- }
-
- Status("opened %s", diags_logpath);
- reconfigure_diags();
-}
+static int count;
struct alarm_printer : public Continuation {
alarm_printer(ProxyMutex *m) : Continuation(m) { SET_HANDLER(&alarm_printer::dummy_function); }
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/596512ec/iocore/hostdb/test_I_HostDB.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/test_I_HostDB.cc b/iocore/hostdb/test_I_HostDB.cc
index 671924d..1559c89 100644
--- a/iocore/hostdb/test_I_HostDB.cc
+++ b/iocore/hostdb/test_I_HostDB.cc
@@ -23,101 +23,8 @@
#include <stdio.h>
#include "I_HostDB.h"
-Diags *diags;
-#define DIAGS_LOG_FILE "diags.log"
-//#define USE_SOCKS
-//////////////////////////////////////////////////////////////////////////////
-//
-// void reconfigure_diags()
-//
-// This function extracts the current diags configuration settings from
-// records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void
-reconfigure_diags()
-{
- int i, e;
- char *p, *dt, *at;
- DiagsConfigState c;
-
-
- // initial value set to 0 or 1 based on command line tags
- c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
- c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
- c.enabled[DiagsTagType_Debug] = 1;
- c.enabled[DiagsTagType_Action] = 1;
- diags->show_location = 1;
-
-
- // read output routing values
- for (i = 0; i < DiagsLevel_Count; i++) {
- c.outputs[i].to_stdout = 0;
- c.outputs[i].to_stderr = 1;
- c.outputs[i].to_syslog = 1;
- c.outputs[i].to_diagslog = 1;
- }
-
- //////////////////////////////
- // clear out old tag tables //
- //////////////////////////////
-
- diags->deactivate_all(DiagsTagType_Debug);
- diags->deactivate_all(DiagsTagType_Action);
-
- //////////////////////////////////////////////////////////////////////
- // add new tag tables
- //////////////////////////////////////////////////////////////////////
-
- if (diags->base_debug_tags)
- diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
- if (diags->base_action_tags)
- diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-////////////////////////////////////
-// change the diags config values //
-////////////////////////////////////
-#if !defined(__GNUC__) && !defined(hpux)
- diags->config = c;
-#else
- memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
-#endif
-}
-
-
-static void
-init_diags(char *bdt, char *bat)
-{
- FILE *diags_log_fp;
- char diags_logpath[500];
- ink_strlcpy(diags_logpath, DIAGS_LOG_FILE, sizeof(diags_logpath));
-
- diags_log_fp = fopen(diags_logpath, "w");
- if (diags_log_fp) {
- int status;
- status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
- if (status != 0) {
- fclose(diags_log_fp);
- diags_log_fp = NULL;
- }
- }
-
- diags = new Diags(bdt, bat, diags_log_fp);
-
- if (diags_log_fp == NULL) {
- SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
-
- diags->print(NULL, DL_Warning, NULL, &loc, "couldn't open diags log file '%s', "
- "will not log to this file",
- diags_logpath);
- }
-
- diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
- reconfigure_diags();
-}
+#include "diags.i"
class HostDBTest : Continuation
{
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/596512ec/iocore/net/test_I_Net.cc
----------------------------------------------------------------------
diff --git a/iocore/net/test_I_Net.cc b/iocore/net/test_I_Net.cc
index 70d314d..75ef7bf 100644
--- a/iocore/net/test_I_Net.cc
+++ b/iocore/net/test_I_Net.cc
@@ -24,100 +24,7 @@
#include "P_Net.h"
#include <netdb.h>
-Diags *diags;
-#define DIAGS_LOG_FILE "diags.log"
-//#define USE_SOCKS
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// void reconfigure_diags()
-//
-// This function extracts the current diags configuration settings from
-// records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void
-reconfigure_diags()
-{
- int i;
- DiagsConfigState c;
-
-
- // initial value set to 0 or 1 based on command line tags
- c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
- c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
- c.enabled[DiagsTagType_Debug] = 1;
- c.enabled[DiagsTagType_Action] = 1;
- diags->show_location = 1;
-
-
- // read output routing values
- for (i = 0; i < DiagsLevel_Count; i++) {
- c.outputs[i].to_stdout = 0;
- c.outputs[i].to_stderr = 1;
- c.outputs[i].to_syslog = 1;
- c.outputs[i].to_diagslog = 1;
- }
-
- //////////////////////////////
- // clear out old tag tables //
- //////////////////////////////
-
- diags->deactivate_all(DiagsTagType_Debug);
- diags->deactivate_all(DiagsTagType_Action);
-
- //////////////////////////////////////////////////////////////////////
- // add new tag tables
- //////////////////////////////////////////////////////////////////////
-
- if (diags->base_debug_tags)
- diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
- if (diags->base_action_tags)
- diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-////////////////////////////////////
-// change the diags config values //
-////////////////////////////////////
-#if !defined(__GNUC__) && !defined(hpux)
- diags->config = c;
-#else
- memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
-#endif
-}
-
-
-static void
-init_diags(char *bdt, char *bat)
-{
- FILE *diags_log_fp;
- char diags_logpath[500];
- ink_strlcpy(diags_logpath, DIAGS_LOG_FILE, sizeof(diags_logpath));
-
- diags_log_fp = fopen(diags_logpath, "w");
- if (diags_log_fp) {
- int status;
- status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
- if (status != 0) {
- fclose(diags_log_fp);
- diags_log_fp = NULL;
- }
- }
-
- diags = new Diags(bdt, bat, diags_log_fp);
-
- if (diags_log_fp == NULL) {
- SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
-
- diags->print(NULL, DL_Warning, NULL, &loc, "couldn't open diags log file '%s', "
- "will not log to this file",
- diags_logpath);
- }
-
- diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
- reconfigure_diags();
-}
+#include "diags.i"
/*
* Choose a net test application
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/596512ec/iocore/net/test_I_UDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/test_I_UDPNet.cc b/iocore/net/test_I_UDPNet.cc
index 81d4a77..b71a9ac 100644
--- a/iocore/net/test_I_UDPNet.cc
+++ b/iocore/net/test_I_UDPNet.cc
@@ -27,102 +27,7 @@
#include "I_Net.h"
#include "ts/List.h"
-// Diags stuff from test_I_Net.cc:
-Diags *diags;
-#define DIAGS_LOG_FILE "diags.log"
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// void reconfigure_diags()
-//
-// This function extracts the current diags configuration settings from
-// records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void
-reconfigure_diags()
-{
- int i, e;
- char *p, *dt, *at;
- DiagsConfigState c;
-
-
- // initial value set to 0 or 1 based on command line tags
- c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
- c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
- c.enabled[DiagsTagType_Debug] = 1;
- c.enabled[DiagsTagType_Action] = 1;
- diags->show_location = 1;
-
-
- // read output routing values
- for (i = 0; i < DiagsLevel_Count; i++) {
- c.outputs[i].to_stdout = 0;
- c.outputs[i].to_stderr = 1;
- c.outputs[i].to_syslog = 1;
- c.outputs[i].to_diagslog = 1;
- }
-
- //////////////////////////////
- // clear out old tag tables //
- //////////////////////////////
-
- diags->deactivate_all(DiagsTagType_Debug);
- diags->deactivate_all(DiagsTagType_Action);
-
- //////////////////////////////////////////////////////////////////////
- // add new tag tables
- //////////////////////////////////////////////////////////////////////
-
- if (diags->base_debug_tags)
- diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
- if (diags->base_action_tags)
- diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-////////////////////////////////////
-// change the diags config values //
-////////////////////////////////////
-#if !defined(__GNUC__) && !defined(hpux)
- diags->config = c;
-#else
- memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
-#endif
-}
-
-
-static void
-init_diags(char *bdt, char *bat)
-{
- FILE *diags_log_fp;
- char diags_logpath[500];
- ink_strlcpy(diags_logpath, DIAGS_LOG_FILE, sizeof(diags_logpath));
-
- diags_log_fp = fopen(diags_logpath, "a+");
- if (diags_log_fp) {
- int status;
- status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
- if (status != 0) {
- fclose(diags_log_fp);
- diags_log_fp = NULL;
- }
- }
-
- diags = new Diags(bdt, bat, diags_log_fp);
-
- if (diags_log_fp == NULL) {
- SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
-
- diags->print(NULL, DL_Warning, NULL, &loc, "couldn't open diags log file '%s', "
- "will not log to this file",
- diags_logpath);
- }
-
- diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
- reconfigure_diags();
-}
-
+#include "diags.i"
/*This implements a standard Unix echo server: just send every udp packet you
get back to where it came from*/
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/596512ec/iocore/net/test_P_UDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/test_P_UDPNet.cc b/iocore/net/test_P_UDPNet.cc
index a0dff55..58e9882 100644
--- a/iocore/net/test_P_UDPNet.cc
+++ b/iocore/net/test_P_UDPNet.cc
@@ -27,102 +27,7 @@
#include "P_Net.h"
#include "ts/ink_platform.h"
-// Diags stuff from test_I_Net.cc:
-Diags *diags;
-#define DIAGS_LOG_FILE "diags.log"
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// void reconfigure_diags()
-//
-// This function extracts the current diags configuration settings from
-// records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void
-reconfigure_diags()
-{
- int i, e;
- char *p, *dt, *at;
- DiagsConfigState c;
-
-
- // initial value set to 0 or 1 based on command line tags
- c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
- c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
- c.enabled[DiagsTagType_Debug] = 1;
- c.enabled[DiagsTagType_Action] = 1;
- diags->show_location = 1;
-
-
- // read output routing values
- for (i = 0; i < DiagsLevel_Count; i++) {
- c.outputs[i].to_stdout = 0;
- c.outputs[i].to_stderr = 1;
- c.outputs[i].to_syslog = 1;
- c.outputs[i].to_diagslog = 1;
- }
-
- //////////////////////////////
- // clear out old tag tables //
- //////////////////////////////
-
- diags->deactivate_all(DiagsTagType_Debug);
- diags->deactivate_all(DiagsTagType_Action);
-
- //////////////////////////////////////////////////////////////////////
- // add new tag tables
- //////////////////////////////////////////////////////////////////////
-
- if (diags->base_debug_tags)
- diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
- if (diags->base_action_tags)
- diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-////////////////////////////////////
-// change the diags config values //
-////////////////////////////////////
-#if !defined(__GNUC__) && !defined(hpux)
- diags->config = c;
-#else
- memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
-#endif
-}
-
-
-static void
-init_diags(char *bdt, char *bat)
-{
- FILE *diags_log_fp;
- char diags_logpath[500];
- ink_strlcpy(diags_logpath, DIAGS_LOG_FILE, sizeof(diags_logpath));
-
- diags_log_fp = fopen(diags_logpath, "a+");
- if (diags_log_fp) {
- int status;
- status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
- if (status != 0) {
- fclose(diags_log_fp);
- diags_log_fp = NULL;
- }
- }
-
- diags = new Diags(bdt, bat, diags_log_fp);
-
- if (diags_log_fp == NULL) {
- SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
-
- diags->print(NULL, DL_Warning, NULL, &loc, "couldn't open diags log file '%s', "
- "will not log to this file",
- diags_logpath);
- }
-
- diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
- reconfigure_diags();
-}
-
+#include "diags.i"
/*This implements a standard Unix echo server: just send every udp packet you
get back to where it came from*/
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/596512ec/iocore/utils/diags.i
----------------------------------------------------------------------
diff --git a/iocore/utils/diags.i b/iocore/utils/diags.i
index a6e72e8..f5a863f 100644
--- a/iocore/utils/diags.i
+++ b/iocore/utils/diags.i
@@ -22,8 +22,7 @@
*/
-
-//Diags *diags;
+// Diags *diags;
#define DIAGS_LOG_FILE "diags.log"
//////////////////////////////////////////////////////////////////////////////
@@ -53,7 +52,6 @@ reconfigure_diags()
// read output routing values
for (i = 0; i < DiagsLevel_Count; i++) {
-
c.outputs[i].to_stdout = 0;
c.outputs[i].to_stderr = 1;
c.outputs[i].to_syslog = 1;
@@ -68,7 +66,7 @@ reconfigure_diags()
diags->deactivate_all(DiagsTagType_Action);
//////////////////////////////////////////////////////////////////////
- // add new tag tables
+ // add new tag tables
//////////////////////////////////////////////////////////////////////
if (diags->base_debug_tags)
@@ -76,46 +74,25 @@ reconfigure_diags()
if (diags->base_action_tags)
diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
- ////////////////////////////////////
- // change the diags config values //
- ////////////////////////////////////
+////////////////////////////////////
+// change the diags config values //
+////////////////////////////////////
#if !defined(__GNUC__) && !defined(hpux)
diags->config = c;
#else
- memcpy(((void *) &diags->config), ((void *) &c), sizeof(DiagsConfigState));
+ memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
#endif
-
}
-
static void
-init_diags(char *bdt, char *bat)
+init_diags(const char *bdt, const char *bat)
{
- FILE *diags_log_fp;
char diags_logpath[500];
strcpy(diags_logpath, DIAGS_LOG_FILE);
- diags_log_fp = fopen(diags_logpath, "w");
- if (diags_log_fp) {
- int status;
- status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
- if (status != 0) {
- fclose(diags_log_fp);
- diags_log_fp = NULL;
- }
- }
-
- diags = new Diags(bdt, bat, diags_log_fp);
-
- if (diags_log_fp == NULL) {
- SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
+ diags = new Diags(bdt, bat, new BaseLogFile(diags_logpath));
+ Status("opened %s", diags_logpath);
- diags->print(NULL, DL_Warning, NULL, &loc,
- "couldn't open diags log file '%s', " "will not log to this file", diags_logpath);
- }
-
- diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
reconfigure_diags();
-
}