scholl-lab / vcf-filtering

A collection of scripts for filtering annotated variant call format files
MIT License
2 stars 1 forks source link

Bug: Improve Debug Level Implementation for Clarity and Consistency #52

Open berntpopp opened 1 month ago

berntpopp commented 1 month ago

Description

The current implementation of the debug level in filter_variants.sh is not clearly defined. There are inconsistencies in how and when messages are shown, particularly with ERROR messages not being logged to the console as expected. The debug levels need to be clearly defined to ensure that appropriate messages are displayed based on the selected level.

Steps to Reproduce

  1. Set the debug level to any available option (INFO, WARN, ERROR, DEBUG).
  2. Run the script with conditions that should trigger various log levels (e.g., errors, warnings, info messages).
  3. Observe that ERROR messages are not logged to the console.

Expected Behavior

Actual Behavior

Proposed Changes

Impact

Improving the debug level implementation will enhance the script’s usability and maintainability, making it easier to diagnose and resolve issues.

Additional Notes

Relevant Code Snippet

# Example of the current debug level implementation
log_message() {
    local message="$1"
    local level="$2"
    case $level in
        "INFO")
            [ "$DEBUG_LEVEL" == "INFO" ] && echo "[INFO] $message"
            ;;
        "WARN")
            [ "$DEBUG_LEVEL" == "INFO" ] || [ "$DEBUG_LEVEL" == "WARN" ] && echo "[WARN] $message"
            ;;
        "ERROR")
            [ "$DEBUG_LEVEL" == "INFO" ] || [ "$DEBUG_LEVEL" == "WARN" ] || [ "$DEBUG_LEVEL" == "ERROR" ] && echo "[ERROR] $message"
            ;;
        "DEBUG")
            [ "$DEBUG_LEVEL" == "DEBUG" ] && echo "[DEBUG] $message"
            ;;
    esac
}

# Example issue: ERROR messages are not shown when DEBUG_LEVEL is set to ERROR