#!/bin/bash

# turn on tracing if MRS_DEBUG environment variable is defined
if [ ! -z "${MRS_DEBUG}" ]; then

  LOG_DIR=/tmp/spark-log
  mkdir -p "${LOG_DIR}"
  chmod 777 "${LOG_DIR}"

  TRACE_FILE="/tmp/spark-log/`basename $0`.$$.log"
  touch "${TRACE_FILE}"

  function trace {
    echo "$*" >> "${TRACE_FILE}"
  }

# if MRS_DEBUG is not defined tracing is off and we just need an empty
# stub for the trace function
else

  function trace {
    true
  }

fi
