#!/bin/bash # Script to run Gramps with debug logging enabled and monitor log file set -e # Colors for output GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color LOG_DIR="$HOME/snap/gramps/11/.config/gramps/gramps60/logs" LOG_FILE="$LOG_DIR/Gramps60.log" echo "=== Running Gramps with Debug Logging ===" echo "" echo "Log file will be created at: $LOG_FILE" echo "" # Create logs directory if it doesn't exist mkdir -p "$LOG_DIR" # Clear any existing log file to start fresh if [ -f "$LOG_FILE" ]; then echo -e "${YELLOW}Backing up existing log file...${NC}" mv "$LOG_FILE" "${LOG_FILE}.backup.$(date +%Y%m%d_%H%M%S)" fi echo -e "${GREEN}Starting Gramps with debug logging enabled...${NC}" echo "" echo "Debug loggers enabled:" echo " - gramps.gen.lib.media (media objects)" echo " - gramps.plugins.import.importxml (XML import)" echo " - gramps.gen.db (database operations)" echo "" echo "After you import the demo_family.gramps file, close Gramps and" echo "run './check_gramps_logs.sh' to analyze the log file." echo "" echo "Press Ctrl+C to stop monitoring (Gramps will continue running)" echo "" # Create a log file in the current directory (snap confinement may prevent writing to ~/.gramps) LOCAL_LOG="gramps_debug.log" echo "Debug output will also be saved to: $PWD/$LOCAL_LOG" echo "" # Run Gramps with debug logging and redirect output gramps --debug=gramps.gen.lib.media \ --debug=gramps.plugins.import.importxml \ --debug=gramps.gen.db \ --debug=gramps.gen.lib \ "$@" > "$LOCAL_LOG" 2>&1 & GRAMPS_PID=$! echo "Gramps started with PID: $GRAMPS_PID" echo "" # Monitor log file creation echo "Waiting for log file to be created..." while [ ! -f "$LOG_FILE" ] && kill -0 "$GRAMPS_PID" 2>/dev/null; do sleep 1 done if [ -f "$LOG_FILE" ]; then echo -e "${GREEN}Log file created!${NC}" echo "" echo "Monitoring log file. Press Ctrl+C to stop monitoring." echo "(Gramps will continue running)" echo "" # Monitor log file for new entries tail -f "$LOG_FILE" 2>/dev/null || { echo "Waiting for log entries..." sleep 2 if [ -f "$LOG_FILE" ]; then echo "" echo "Current log contents:" cat "$LOG_FILE" fi } else echo "Log file not created yet. Gramps may not have started logging." echo "Check if Gramps is running: ps aux | grep gramps" fi