trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject [trafficserver] branch 9.0.x updated: TS_API for Note, Status, Warning, Alert, Fatal (#7181)
Date Thu, 15 Jul 2021 18:51:26 GMT
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 1687ace  TS_API for Note,Status,Warning,Alert,Fatal (#7181)
1687ace is described below

commit 1687aced7461a787b7be7034271d1a687d2e0181
Author: a-a-ron <acanary@verizonmedia.com>
AuthorDate: Fri Sep 11 14:17:48 2020 -0500

    TS_API for Note,Status,Warning,Alert,Fatal (#7181)
    
    Adding API calls for each level of syslog
    
    (cherry picked from commit eac3ba5a22116771f586fbbc1d6b81b5df7854f9)
---
 doc/developer-guide/api/functions/TSDebug.en.rst | 39 ++++++++++-------
 include/ts/ts.h                                  | 15 +++++--
 include/tscore/Diags.h                           | 14 +++----
 src/traffic_server/InkAPI.cc                     | 53 +++++++++++++++++++++---
 4 files changed, 89 insertions(+), 32 deletions(-)

diff --git a/doc/developer-guide/api/functions/TSDebug.en.rst b/doc/developer-guide/api/functions/TSDebug.en.rst
index 3273dbd..d788bba 100644
--- a/doc/developer-guide/api/functions/TSDebug.en.rst
+++ b/doc/developer-guide/api/functions/TSDebug.en.rst
@@ -30,8 +30,12 @@ Synopsis
 
     #include <ts/ts.h>
 
+.. function:: void TSStatus(const char * format, ...)
+.. function:: void TSNote(const char * format, ...)
+.. function:: void TSWarning(const char * format, ...)
 .. function:: void TSError(const char * format, ...)
 .. function:: void TSFatal(const char * format, ...)
+.. function:: void TSAlert(const char * format, ...)
 .. function:: void TSEmergency(const char * format, ...)
 .. function:: void TSDebug(const char * tag, const char * format, ...)
 .. function:: int TSIsDebugTagSet(const char * tag)
@@ -46,29 +50,34 @@ Synopsis
 .. macro:: void TSAssert( ... )
 .. macro:: void TSReleaseAssert( ... )
 
-Description
-===========
+diags.log
+=========
 
-:func:`TSError` is similar to ``printf`` except that instead
-of writing the output to the C standard output, it writes output
-to the Traffic Server error log.
+The following methods print to diags.log with expected reactions as a coordinated outcome
of
+Traffic Server, Traffic Manager, AuTest, CI, and your log monitoring service/dashboard (e.g.
Splunk)
 
-:func:`TSFatal` is used to shutdown Traffic Server in hopes that a clean
-restart will be able to fix the problem. It will also log a message to the
-Traffic Server error log just like :func:`TSError`.
+.. csv-table::
+   :header: "API", "Purpose", "TrafficManager", "AuTest+CI",  "LogMonitor"
+   :widths: 15, 20, 10, 10, 10
 
-:func:`TSEmergency` is used to shutdown Traffic Server when restarting
-isn't sufficient to fix the problem, e.g. missing or corrupted files. It will
-also log a message to the Traffic Server error log just like :func:`TSError`.
+   ":func:`TSStatus`","basic information"
+   ":func:`TSNote`","significant information"
+   ":func:`TSWarning`","concerning information","","","track"
+   ":func:`TSError`","operational failure","","FAIL","review"
+   ":func:`TSFatal`","recoverable crash","restart","FAIL","review"
+   ":func:`TSAlert`","significant crash","restart","FAIL","ALERT"
+   ":func:`TSEmergency`","unrecoverable,misconfigured","EXIT","FAIL","ALERT"
 
 .. note::
-    Both :func:`TSFatal` and :func:`TSEmergency` can be called within
+    :func:`TSFatal`, :func:`TSAlert`, and :func:`TSEmergency` can be called within
     :func:`TSPluginInit`, such that Traffic Server can be shutdown promptly when
     the plugin fails to initialize properly.
 
-:func:`TSDebug` is the same as :func:`TSError` except that it only
-logs the debug message if the given debug :arg:`tag` is enabled. It writes
-output to the Traffic Server debug log.
+trafficserver.out
+=================
+
+:func:`TSDebug` logs the debug message only if the given debug :arg:`tag` is enabled.
+It writes output to the Traffic Server debug log through stderr.
 
 :func:`TSIsDebugTagSet` returns non-zero if the given debug :arg:`tag` is
 enabled.
diff --git a/include/ts/ts.h b/include/ts/ts.h
index a44827c..bbe2631 100644
--- a/include/ts/ts.h
+++ b/include/ts/ts.h
@@ -272,11 +272,18 @@ tsapi char *TSfgets(TSFile filep, char *buf, size_t length);
     @param fmt printf format description.
     @param ... argument for the printf format description.
 
-*/
-tsapi void TSError(const char *fmt, ...) TS_PRINTFLIKE(1, 2);
+    Note: Your log monitoring (e.g. Splunk) needs to alert Ops of log
+    messages that contain ' ALERT: ' or ' EMERGENCY: ', these require
+    immediate attention.
 
-tsapi void TSEmergency(const char *fmt, ...) TS_PRINTFLIKE(1, 2);
-tsapi void TSFatal(const char *fmt, ...) TS_PRINTFLIKE(1, 2);
+*/
+tsapi void TSStatus(const char *fmt, ...) TS_PRINTFLIKE(1, 2);    // Log information
+tsapi void TSNote(const char *fmt, ...) TS_PRINTFLIKE(1, 2);      // Log significant information
+tsapi void TSWarning(const char *fmt, ...) TS_PRINTFLIKE(1, 2);   // Log concerning information
+tsapi void TSError(const char *fmt, ...) TS_PRINTFLIKE(1, 2);     // Log operational failure,
fail CI
+tsapi void TSFatal(const char *fmt, ...) TS_PRINTFLIKE(1, 2);     // Log recoverable crash,
fail CI, exit & restart
+tsapi void TSAlert(const char *fmt, ...) TS_PRINTFLIKE(1, 2);     // Log recoverable crash,
fail CI, exit & restart, Ops attention
+tsapi void TSEmergency(const char *fmt, ...) TS_PRINTFLIKE(1, 2); // Log unrecoverable crash,
fail CI, exit, Ops attention
 
 /* --------------------------------------------------------------------------
    Assertions */
diff --git a/include/tscore/Diags.h b/include/tscore/Diags.h
index 23c6696..3c5c1b7 100644
--- a/include/tscore/Diags.h
+++ b/include/tscore/Diags.h
@@ -290,13 +290,13 @@ extern inkcoreapi Diags *diags;
     diags->error(level, &loc, fmt, ##__VA_ARGS__); \
   } while (0)
 
-#define Status(...) DiagsError(DL_Status, __VA_ARGS__)
-#define Note(...) DiagsError(DL_Note, __VA_ARGS__)
-#define Warning(...) DiagsError(DL_Warning, __VA_ARGS__)
-#define Error(...) DiagsError(DL_Error, __VA_ARGS__)
-#define Fatal(...) DiagsError(DL_Fatal, __VA_ARGS__)
-#define Alert(...) DiagsError(DL_Alert, __VA_ARGS__)
-#define Emergency(...) DiagsError(DL_Emergency, __VA_ARGS__)
+#define Status(...) DiagsError(DL_Status, __VA_ARGS__)       // Log information
+#define Note(...) DiagsError(DL_Note, __VA_ARGS__)           // Log significant information
+#define Warning(...) DiagsError(DL_Warning, __VA_ARGS__)     // Log concerning information
+#define Error(...) DiagsError(DL_Error, __VA_ARGS__)         // Log operational failure,
fail CI
+#define Fatal(...) DiagsError(DL_Fatal, __VA_ARGS__)         // Log recoverable crash, fail
CI, exit & allow restart
+#define Alert(...) DiagsError(DL_Alert, __VA_ARGS__)         // Log recoverable crash, fail
CI, exit & restart, Ops attention
+#define Emergency(...) DiagsError(DL_Emergency, __VA_ARGS__) // Log unrecoverable crash,
fail CI, exit, Ops attention
 
 #define DiagsErrorV(level, fmt, ap)                  \
   do {                                               \
diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc
index ec65c22..a356dba 100644
--- a/src/traffic_server/InkAPI.cc
+++ b/src/traffic_server/InkAPI.cc
@@ -398,27 +398,48 @@ static ClassAllocator<MIMEFieldSDKHandle> mHandleAllocator("MIMEFieldSDKHandle")
 // API error logging
 //
 ////////////////////////////////////////////////////////////////////
+
 void
-TSError(const char *fmt, ...)
+TSStatus(const char *fmt, ...)
 {
   va_list args;
 
   va_start(args, fmt);
-  ErrorV(fmt, args);
+  StatusV(fmt, args);
   va_end(args);
 }
 
-tsapi void
-TSEmergency(const char *fmt, ...)
+void
+TSNote(const char *fmt, ...)
 {
   va_list args;
 
   va_start(args, fmt);
-  EmergencyV(fmt, args);
+  NoteV(fmt, args);
   va_end(args);
 }
 
-tsapi void
+void
+TSWarning(const char *fmt, ...)
+{
+  va_list args;
+
+  va_start(args, fmt);
+  WarningV(fmt, args);
+  va_end(args);
+}
+
+void
+TSError(const char *fmt, ...)
+{
+  va_list args;
+
+  va_start(args, fmt);
+  ErrorV(fmt, args);
+  va_end(args);
+}
+
+void
 TSFatal(const char *fmt, ...)
 {
   va_list args;
@@ -428,6 +449,26 @@ TSFatal(const char *fmt, ...)
   va_end(args);
 }
 
+void
+TSAlert(const char *fmt, ...)
+{
+  va_list args;
+
+  va_start(args, fmt);
+  AlertV(fmt, args);
+  va_end(args);
+}
+
+void
+TSEmergency(const char *fmt, ...)
+{
+  va_list args;
+
+  va_start(args, fmt);
+  EmergencyV(fmt, args);
+  va_end(args);
+}
+
 // Assert in debug AND optim
 void
 _TSReleaseAssert(const char *text, const char *file, int line)

Mime
View raw message