git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v1 02/25] structured-logging: add STRUCTURED_LOGGING=1 to Makefile

From
Ggit@jeffhostetler.com <git@jeffhostetler.com>
Date
Jul 13, 2018, 16:55 UTC
Message-ID
<20180713165621.52017-3-git@jeffhostetler.com>
In-Reply-To
<20180713165621.52017-1-git@jeffhostetler.com>
From: Jeff Hostetler <jeffhost@microsoft.com>

Teach the Makefile to take STRUCTURED_LOGGING=1 variable to compile in/out structured logging feature.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
 Makefile             |  8 ++++++++
 structured-logging.c |  9 +++++++++
 structured-logging.h | 13 +++++++++++++
 3 files changed, 30 insertions(+)
 create mode 100644 structured-logging.c
 create mode 100644 structured-logging.h
diff --git a/Makefile b/Makefile
index 39ca66b..ccc39bf 100644
--- a/Makefile
+++ b/Makefile
@@ -442,6 +442,8 @@ all::
 # When cross-compiling, define HOST_CPU as the canonical name of the CPU on
 # which the built Git will run (for instance "x86_64").
 #
+# Define STRUCTURED_LOGGING if you want structured logging to be available.
+#
 # Define RUNTIME_PREFIX to configure Git to resolve its ancillary tooling and
 # support files relative to the location of the runtime binary, rather than
 # hard-coding them into the binary. Git installations built with RUNTIME_PREFIX
@@ -955,6 +957,7 @@ LIB_OBJS += split-index.o
 LIB_OBJS += strbuf.o
 LIB_OBJS += streaming.o
 LIB_OBJS += string-list.o
+LIB_OBJS += structured-logging.o
 LIB_OBJS += submodule.o
 LIB_OBJS += submodule-config.o
 LIB_OBJS += sub-process.o
@@ -1326,6 +1329,10 @@ ifdef ZLIB_PATH
 endif
 EXTLIBS += -lz
 
+ifdef STRUCTURED_LOGGING
+	BASIC_CFLAGS += -DSTRUCTURED_LOGGING
+endif
+
 ifndef NO_OPENSSL
 	OPENSSL_LIBSSL = -lssl
 	ifdef OPENSSLDIR
@@ -2543,6 +2550,7 @@ GIT-BUILD-OPTIONS: FORCE
 	@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@+
 	@echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@+
 	@echo NO_EXPAT=\''$(subst ','\'',$(subst ','\'',$(NO_EXPAT)))'\' >>$@+
+	@echo STRUCTURED_LOGGING=\''$(subst ','\'',$(subst ','\'',$(STRUCTURED_LOGGING)))'\' >>$@+
 	@echo USE_LIBPCRE1=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE1)))'\' >>$@+
 	@echo USE_LIBPCRE2=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE2)))'\' >>$@+
 	@echo NO_LIBPCRE1_JIT=\''$(subst ','\'',$(subst ','\'',$(NO_LIBPCRE1_JIT)))'\' >>$@+
diff --git a/structured-logging.c b/structured-logging.c
new file mode 100644
index 0000000..702fd84
--- /dev/null
+++ b/structured-logging.c
@@ -0,0 +1,9 @@
+#if !defined(STRUCTURED_LOGGING)
+/*
+ * Structured logging is not available.
+ * Stub out all API routines.
+ */
+
+#else
+
+#endif
diff --git a/structured-logging.h b/structured-logging.h
new file mode 100644
index 0000000..c9e8c1d
--- /dev/null
+++ b/structured-logging.h
@@ -0,0 +1,13 @@
+#ifndef STRUCTURED_LOGGING_H
+#define STRUCTURED_LOGGING_H
+
+#if !defined(STRUCTURED_LOGGING)
+/*
+ * Structured logging is not available.
+ * Stub out all API routines.
+ */
+
+#else
+
+#endif /* STRUCTURED_LOGGING */
+#endif /* STRUCTURED_LOGGING_H */
-- 
2.9.3
Previous: Jonathan NiederNext: Jonathan Nieder
Message 33 of 38 in “RFC: structured logging”
  1. 00/25 RFC: structured logginggit@jeffhostetler.com, Jul 13, 2018
  2. 01/25 structured-logging: design documentgit@jeffhostetler.com, Jul 13, 2018
  3. Simon RuderichJul 14, 2018
  4. Ben PeartAug 3, 2018
  5. Jeff HostetlerAug 9, 2018
  6. Jonathan NiederAug 21, 2018
  7. 04/25 structured-logging: add session-id to log eventsgit@jeffhostetler.com, Jul 13, 2018
  8. 06/25 structured-logging: set sub_command field for checkout commandgit@jeffhostetler.com, Jul 13, 2018
  9. 08/25 structured-logging: add detail-event facilitygit@jeffhostetler.com, Jul 13, 2018
  10. 07/25 structured-logging: t0420 basic testsgit@jeffhostetler.com, Jul 13, 2018
  11. 10/25 structured-logging: add timer facilitygit@jeffhostetler.com, Jul 13, 2018
  12. 12/25 structured-logging: add timer around do_write_indexgit@jeffhostetler.com, Jul 13, 2018
  13. 14/25 structured-logging: add timer around preload_indexgit@jeffhostetler.com, Jul 13, 2018
  14. 16/25 structured-logging: add aux-data facilitygit@jeffhostetler.com, Jul 13, 2018
  15. 17/25 structured-logging: add aux-data for index sizegit@jeffhostetler.com, Jul 13, 2018
  16. 19/25 structured-logging: t0420 tests for aux-datagit@jeffhostetler.com, Jul 13, 2018
  17. 18/25 structured-logging: add aux-data for size of sparse-checkout filegit@jeffhostetler.com, Jul 13, 2018
  18. 20/25 structured-logging: add structured logging to remote-curlgit@jeffhostetler.com, Jul 13, 2018
  19. 23/25 structured-logging: t0420 tests for child process detail eventsgit@jeffhostetler.com, Jul 13, 2018
  20. 21/25 structured-logging: add detail-events for child processesgit@jeffhostetler.com, Jul 13, 2018
  21. 25/25 structured-logging: add config data facilitygit@jeffhostetler.com, Jul 13, 2018
  22. 22/25 structured-logging: add child process classificationgit@jeffhostetler.com, Jul 13, 2018
  23. 24/25 structured-logging: t0420 tests for interacitve child_summarygit@jeffhostetler.com, Jul 13, 2018
  24. 15/25 structured-logging: t0420 tests for timersgit@jeffhostetler.com, Jul 13, 2018
  25. 13/25 structured-logging: add timer around wt-status functionsgit@jeffhostetler.com, Jul 13, 2018
  26. 11/25 structured-logging: add timer around do_read_indexgit@jeffhostetler.com, Jul 13, 2018
  27. 09/25 structured-logging: add detail-event for lazy_init_name_hashgit@jeffhostetler.com, Jul 13, 2018
  28. 05/25 structured-logging: set sub_command field for branch commandgit@jeffhostetler.com, Jul 13, 2018
  29. 03/25 structured-logging: add structured logging frameworkgit@jeffhostetler.com, Jul 13, 2018
  30. SZEDER GáborJul 26, 2018
  31. Jeff HostetlerJul 27, 2018
  32. Jonathan NiederAug 21, 2018
  33. 02/25 structured-logging: add STRUCTURED_LOGGING=1 to Makefilegit@jeffhostetler.com, Jul 13, 2018
  34. Jonathan NiederAug 21, 2018
  35. David LangJul 13, 2018
  36. Jeff HostetlerJul 16, 2018
  37. Junio C HamanoAug 28, 2018
  38. Jeff HostetlerAug 28, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.