#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG					#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright Christopher Bratusek			#
#							#
#########################################################

verbose=$(ini_get debug_verbose)

dbg_msg ()
{
	if [[ ${verbose} == True ]]; then
		echo -E "$@" | tee -a "${BSNG_LOGFILE}"
	else	echo -E "$@" >> "${BSNG_LOGFILE}"
	fi
}

dbg_log ()
{
	dbg_msg "$@"
	"$@" > >(tee -a "${BSNG_LOGFILE}") 2>&1
}

dbg_finalize()
{
	sed '$!N; /^\(.*\)\n\1$/!P; D' -i "${BSNG_LOGFILE}"
}

dbg_view ()
{
	less "${BSNG_LOGFILE}"
}

dbg_log rm -f "${BSNG_LOGFILE}"
dbg_log touch "${BSNG_LOGFILE}"
