Question: dear friends and colleges

the following code , is the basic concept of my log file in my bash script

this Code help me to understand each step in my bash script or in case we need to make troubleshooting

but some times I want to disable the Log creation because we not need the log and want to make the script more efficiency ( call to Log function each line in the script take time and make the script more heavy )

so my question my friends:

What the best elegant way to disable the log file?

Until now I disabled the log function by return inside my log function

But this solution not so good because I still call the function

```
 LOG=/tmp/BACKUP_PROCCESS.log
 LOG_DISABLE=FALSE
  MY_LOG ()
  {
   [ $LOG_DISABLE = TRUE ] && return
   echo "[`date +%d"/"%b"/"%G"-"%T`] INFO $1" >> $LOG
   }
   MY_LOG "START TO BACKUP FILES UNDER /VAR/LOG"

```

Answer: 
You can use some file descriptor redirections:

```
#!/bin/sh

log()
{
    echo >&3 $@
}

# Redirect all fd 3 in the file test.log
exec 3>$HOME/test.log

log this should be print

# Redirect all fd 3 in /dev/null
exec 3>/dev/null

log this sould not be print

```

and you will have in the file `test.log`

```
this should be print

```
My way:

```
LOG_DISABLE="FALSE"
if [ $LOG_DISABLE = "TRUE" ]; then
   MY_LOG(){
      true
   }
else
   MY_LOG(){
      echo "[`date +%d"/"%b"/"%G"-"%T`] INFO $1" >> $LOG
   }
fi

```

Just defining the function differently based on the flag.
You will call the function either way but I hope true is a quick builtin ;)