Initial commit: mod_reqin_log Apache module
Features: - JSON logging of HTTP requests to Unix domain socket - Configurable HTTP headers logging (flat JSON structure) - Header value truncation and count limits - Automatic reconnect on socket disconnection - Error reporting with throttling Configuration directives: - JsonSockLogEnabled: Enable/disable logging - JsonSockLogSocket: Unix socket path - JsonSockLogHeaders: List of headers to log - JsonSockLogMaxHeaders: Maximum headers to log - JsonSockLogMaxHeaderValueLen: Max header value length - JsonSockLogReconnectInterval: Reconnect delay - JsonSockLogErrorReportInterval: Error log throttle Includes: - Module source code (src/) - Unit and integration tests (tests/, scripts/) - Documentation (README.md, architecture.yml) - Build configuration (CMakeLists.txt, Makefile) - Packaging (deb/rpm) Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
86
Makefile
Normal file
86
Makefile
Normal file
@ -0,0 +1,86 @@
|
||||
# Makefile for mod_reqin_log
|
||||
# Apache HTTPD module for logging HTTP requests as JSON to Unix socket
|
||||
|
||||
# APXS tool path (can be overridden)
|
||||
APXS ?= apxs
|
||||
|
||||
# Compiler settings
|
||||
CC ?= gcc
|
||||
CFLAGS ?= -Wall -Wextra -O2
|
||||
|
||||
# Directories
|
||||
SRC_DIR = src
|
||||
BUILD_DIR = build
|
||||
INSTALL_DIR = modules
|
||||
|
||||
# Source files
|
||||
SRCS = $(SRC_DIR)/mod_reqin_log.c
|
||||
|
||||
# Module name
|
||||
MODULE_NAME = mod_reqin_log
|
||||
|
||||
.PHONY: all clean install uninstall test
|
||||
|
||||
all: $(MODULE_NAME).so
|
||||
|
||||
# Build the module using apxs
|
||||
# Note: Use -Wc to pass flags to the C compiler through apxs
|
||||
$(MODULE_NAME).so: $(SRCS)
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
$(APXS) -c -Wc,"$(CFLAGS)" -o $(BUILD_DIR)/$(MODULE_NAME).so $(SRCS)
|
||||
@mkdir -p $(INSTALL_DIR)
|
||||
@if [ -f $(BUILD_DIR)/.libs/$(MODULE_NAME).so ]; then \
|
||||
cp $(BUILD_DIR)/.libs/$(MODULE_NAME).so $(INSTALL_DIR)/; \
|
||||
elif [ -f $(BUILD_DIR)/$(MODULE_NAME).so ]; then \
|
||||
cp $(BUILD_DIR)/$(MODULE_NAME).so $(INSTALL_DIR)/; \
|
||||
fi
|
||||
|
||||
# Install the module
|
||||
install: $(MODULE_NAME).so
|
||||
@echo "Installing $(MODULE_NAME).so..."
|
||||
@mkdir -p $(DESTDIR)/usr/lib/apache2/modules
|
||||
cp $(BUILD_DIR)/$(MODULE_NAME).so $(DESTDIR)/usr/lib/apache2/modules/
|
||||
@echo "Installation complete."
|
||||
@echo "Enable the module by adding to your httpd.conf:"
|
||||
@echo " LoadModule reqin_log_module modules/mod_reqin_log.so"
|
||||
|
||||
# Uninstall the module
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)/usr/lib/apache2/modules/$(MODULE_NAME).so
|
||||
@echo "Uninstallation complete."
|
||||
|
||||
# Clean build artifacts
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR) $(INSTALL_DIR)
|
||||
rm -f .libs/*.o .libs/*.la .libs/*.so
|
||||
rm -f *.o *.la *.lo
|
||||
rm -rf .libs
|
||||
|
||||
# Run unit tests (requires cmocka)
|
||||
test:
|
||||
@mkdir -p build/tests
|
||||
cd build/tests && cmake ../../ -DCMAKE_BUILD_TYPE=Debug
|
||||
$(MAKE) -C build/tests run_tests
|
||||
|
||||
# Build with debug symbols
|
||||
debug: CFLAGS += -g -DDEBUG
|
||||
debug: clean all
|
||||
|
||||
# Help target
|
||||
help:
|
||||
@echo "mod_reqin_log Makefile"
|
||||
@echo ""
|
||||
@echo "Targets:"
|
||||
@echo " all - Build the module (default)"
|
||||
@echo " install - Install the module to DESTDIR"
|
||||
@echo " uninstall- Remove the module from DESTDIR"
|
||||
@echo " clean - Remove build artifacts"
|
||||
@echo " test - Run unit tests"
|
||||
@echo " debug - Build with debug symbols"
|
||||
@echo " help - Show this help message"
|
||||
@echo ""
|
||||
@echo "Variables:"
|
||||
@echo " APXS - Path to apxs tool (default: apxs)"
|
||||
@echo " CC - C compiler (default: gcc)"
|
||||
@echo " CFLAGS - Compiler flags (default: -Wall -Wextra -O2)"
|
||||
@echo " DESTDIR - Installation destination (default: /)"
|
||||
Reference in New Issue
Block a user