[Groonga-commit] groonga/groonga at 76ff367 [master] logger: add GRN_LOG_THREAD_ID

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jul 30 16:38:50 JST 2018


Kouhei Sutou	2018-07-30 16:38:50 +0900 (Mon, 30 Jul 2018)

  New Revision: 76ff3678903111df5447ddb34fe8d70f5d1728e2
  https://github.com/groonga/groonga/commit/76ff3678903111df5447ddb34fe8d70f5d1728e2

  Message:
    logger: add GRN_LOG_THREAD_ID

  Modified files:
    include/groonga/groonga.h
    lib/logger.c

  Modified: include/groonga/groonga.h (+1 -0)
===================================================================
--- include/groonga/groonga.h    2018-07-30 16:07:33 +0900 (1af9c3a11)
+++ include/groonga/groonga.h    2018-07-30 16:38:50 +0900 (4621a24d6)
@@ -1014,6 +1014,7 @@ GRN_API grn_rc grn_snip_get_result(grn_ctx *ctx, grn_obj *snip, const unsigned i
 #define GRN_LOG_MESSAGE                (0x01<<2)
 #define GRN_LOG_LOCATION               (0x01<<3)
 #define GRN_LOG_PID                    (0x01<<4)
+#define GRN_LOG_THREAD_ID              (0x01<<5)
 
 /* Deprecated since 2.1.2. Use grn_logger instead. */
 typedef struct _grn_logger_info grn_logger_info;

  Modified: lib/logger.c (+6 -0)
===================================================================
--- lib/logger.c    2018-07-30 16:07:33 +0900 (d86b0b925)
+++ lib/logger.c    2018-07-30 16:38:50 +0900 (60ae721d1)
@@ -429,6 +429,12 @@ grn_logger_putv(grn_ctx *ctx,
     } else if (current_logger.flags & GRN_LOG_PID) {
       grn_snprintf(lbuf, LBUFSIZE, LBUFSIZE,
                    "%d", grn_getpid());
+    } else if (current_logger.flags & GRN_LOG_THREAD_ID) {
+#ifdef HAVE_PTHREAD_H
+      grn_snprintf(lbuf, LBUFSIZE, LBUFSIZE, "%08x", (uint32_t)pthread_self());
+#elif defined(WIN32) /* HAVE_PTHREAD_H */
+      grn_snprintf(lbuf, LBUFSIZE, LBUFSIZE, "%08x", (uint32_t)GetCurrentThread());
+#endif /* HAVE_PTHREAD_H */
     } else {
       lbuf[0] = '\0';
     }
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180730/27cc34e8/attachment.htm 



More information about the Groonga-commit mailing list
Back to archive index