axis-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billblo...@apache.org
Subject [axis-axis2-c-core] 11/14: Enabling service level log messages
Date Sat, 04 Apr 2020 15:07:43 GMT
This is an automated email from the ASF dual-hosted git repository.

billblough pushed a commit to branch 29092007
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git

commit 79cb0d5fc49355c2298ab59a58b4e37a8aee8139
Author: Damitha N.M. Kumarage <damitha@apache.org>
AuthorDate: Thu Oct 25 05:11:40 2007 +0000

    Enabling service level log messages
---
 .../server/simple_axis2_server/http_server_main.c  |  4 +-
 util/include/axutil_log.h                          | 15 +++++-
 util/src/log.c                                     | 55 ++++++++++++++++++++--
 3 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/src/core/transport/http/server/simple_axis2_server/http_server_main.c b/src/core/transport/http/server/simple_axis2_server/http_server_main.c
index 2faefd3..53fce58 100644
--- a/src/core/transport/http/server/simple_axis2_server/http_server_main.c
+++ b/src/core/transport/http/server/simple_axis2_server/http_server_main.c
@@ -127,7 +127,7 @@ main(
             log_level = AXIS2_ATOI(optarg);
             if (log_level < AXIS2_LOG_LEVEL_CRITICAL)
                 log_level = AXIS2_LOG_LEVEL_CRITICAL;
-            if (log_level > AXIS2_LOG_LEVEL_TRACE)
+            if (log_level > AXIS2_LOG_LEVEL_SERVICE)
                 log_level = AXIS2_LOG_LEVEL_TRACE;
             break;
         case 'f':
@@ -214,7 +214,7 @@ usage(
     fprintf(stdout,
             "\t-l LOG_LEVEL\t log level, available log levels:"
             "\n\t\t\t 0 - critical    1 - errors 2 - warnings"
-            "\n\t\t\t 3 - information 4 - debug  5- trace"
+            "\n\t\t\t 3 - information 4 - debug  5- trace 6- service"
             "\n\t\t\t Default log level is 4(debug).\n");
     fprintf(stdout,
             "\t-f LOG_FILE\t log file, default is $AXIS2C_HOME/logs/axis2.log"
diff --git a/util/include/axutil_log.h b/util/include/axutil_log.h
index ca0bba4..730ac65 100644
--- a/util/include/axutil_log.h
+++ b/util/include/axutil_log.h
@@ -45,6 +45,7 @@ extern "C"
       *"log this test 123" into the log file
       *
       *similar macros are defined for different log levels: CRITICAL,ERROR,WARNING and INFO
+      * and SERVICE
       *
       *CRITICAL and ERROR logs are always written to file and other logs are written 
       *depending on the log level set (log->level)
@@ -72,7 +73,10 @@ extern "C"
         AXIS2_LOG_LEVEL_DEBUG,
 
         /** Trace level, Enable with compiler time option AXIS2_TRACE */
-        AXIS2_LOG_LEVEL_TRACE
+        AXIS2_LOG_LEVEL_TRACE,
+        
+        /** Service level, logs only service level debug messages */
+        AXIS2_LOG_LEVEL_SERVICE
     } axutil_log_levels_t;
 
     /**
@@ -160,6 +164,14 @@ extern "C"
         ...);
 
     AXIS2_EXTERN void AXIS2_CALL
+    axutil_log_impl_log_service(
+        axutil_log_t * log,
+        const axis2_char_t * filename,
+        const int linenumber,
+        const axis2_char_t * format,
+        ...);
+
+    AXIS2_EXTERN void AXIS2_CALL
     axutil_log_impl_log_debug(
         axutil_log_t * log,
         const axis2_char_t * filename,
@@ -195,6 +207,7 @@ extern "C"
 #define AXIS2_LOG_WRITE(log, buffer, level, file) \
       axutil_log_write(log, buffer, level, file, AXIS2_LOG_SI)
 
+#define AXIS2_LOG_SERVICE axutil_log_impl_log_service
 #define AXIS2_LOG_DEBUG axutil_log_impl_log_debug
 #define AXIS2_LOG_INFO axutil_log_impl_log_info
 #define AXIS2_LOG_WARNING axutil_log_impl_log_warning
diff --git a/util/src/log.c b/util/src/log.c
index 9d4e4c8..c526550 100644
--- a/util/src/log.c
+++ b/util/src/log.c
@@ -231,6 +231,8 @@ axutil_log_impl_write(
             case AXIS2_LOG_LEVEL_TRACE:
                 level_str = "[...TRACE...] ";
                 break;
+            case AXIS2_LOG_LEVEL_SERVICE:
+                break;
             }
             fprintf(stderr, "%s %s(%d) %s\n", level_str, file, line, buffer);
         }
@@ -276,6 +278,8 @@ axutil_log_impl_write_to_file(
     case AXIS2_LOG_LEVEL_TRACE:
         level_str = "[...TRACE...] ";
         break;
+    case AXIS2_LOG_LEVEL_SERVICE:
+        break;
     }
     axutil_thread_mutex_lock(mutex);
 
@@ -332,6 +336,45 @@ axutil_log_impl_rotate(
 }
 
 AXIS2_EXTERN void AXIS2_CALL
+axutil_log_impl_log_service(
+    axutil_log_t * log,
+    const axis2_char_t * filename,
+    const int linenumber,
+    const axis2_char_t * format,
+    ...)
+{
+    FILE *fd = NULL;
+    axutil_thread_mutex_t *mutex = NULL;
+
+    if (log && format)
+    {
+
+        if (!(fd = AXIS2_INTF_TO_IMPL(log)->stream))
+        {
+            fprintf(stderr, "Stream is not found\n");
+        }
+
+        if (!(mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
+        {
+            fprintf(stderr, "Log mutex is not found\n");
+
+        }
+        if (AXIS2_LOG_LEVEL_DEBUG <= log->level)
+        {
+            char value[AXIS2_LEN_VALUE + 1];
+            va_list ap;
+            va_start(ap, format);
+            AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
+            va_end(ap);
+            axutil_log_impl_write_to_file(log, mutex, AXIS2_LOG_LEVEL_DEBUG,
+                filename, linenumber, value);
+        }
+    }
+    else
+        fprintf(stderr, "please check your log and buffer");
+}
+
+AXIS2_EXTERN void AXIS2_CALL
 axutil_log_impl_log_debug(
     axutil_log_t * log,
     const axis2_char_t * filename,
@@ -356,7 +399,8 @@ axutil_log_impl_log_debug(
 
         }
 
-        if (AXIS2_LOG_LEVEL_DEBUG <= log->level)
+        if (AXIS2_LOG_LEVEL_DEBUG <= log->level && 
+            log->level != AXIS2_LOG_LEVEL_SERVICE)
         {
             char value[AXIS2_LEN_VALUE + 1];
             va_list ap;
@@ -394,7 +438,8 @@ axutil_log_impl_log_info(
 
         }
 
-        if (AXIS2_LOG_LEVEL_INFO <= log->level)
+        if (AXIS2_LOG_LEVEL_INFO <= log->level &&
+            log->level != AXIS2_LOG_LEVEL_SERVICE)
         {
             char value[AXIS2_LEN_VALUE + 1];
             va_list ap;
@@ -435,7 +480,8 @@ axutil_log_impl_log_warning(
 
         }
 
-        if (AXIS2_LOG_LEVEL_WARNING <= log->level)
+        if (AXIS2_LOG_LEVEL_WARNING <= log->level &&
+            log->level != AXIS2_LOG_LEVEL_SERVICE)
         {
             char value[AXIS2_LEN_VALUE + 1];
             va_list ap;
@@ -612,7 +658,8 @@ axutil_log_impl_log_trace(
 
         }
 
-        if (AXIS2_LOG_LEVEL_TRACE <= log->level)
+        if (AXIS2_LOG_LEVEL_TRACE <= log->level &&
+            log->level != AXIS2_LOG_LEVEL_SERVICE)
         {
             char value[AXIS2_LEN_VALUE + 1];
             va_list ap;


Mime
View raw message