MySQL Proxy, in addition to dealing with the packets sent between
client and server, can optionally send text messages to the
terminal window where it was launched. These messages, using the
built-in function print(), can be very useful when
you develop an application, because can give you information on
what is going on. However, when the script is well tuned, all
these messages can be distracting and even annoying.
OTOH, if you plan to extend the development of the script,
leaving the telling messages in place can be very useful. One
handy solution is to include conditional print messages,
controlled by an environment variable.
- Change all occurrences of print to print_debug;
- Create a function print_debug that will print the message depending on the value of a local variable DEBUG;
- At the start of the script, initialize the DEBUG variable from the …