title: Ideas / best practices for controlling verbosity in matlab functions
body: <p>Let's say I have some_fun that does some complicated work.</p>
  
  <pre><code>function foo = some_complicated_fun(x,y,z,verbosity)
  </code></pre>
  
  <p>I've written a good bit of debugging prints into this code, but the avg user may not be interested in seeing all that if it is working. 
  Error statements (not enough args, etc) will print regardless.</p>
  
  <p>My current method for writing a function is:</p>
  
  <pre><code>function foo = some_complicated_fun(x,y,z,verbosity)
  
  (x,y,z,verbosity) = parse_args(x,y,z,verbosity); % parse args, check nargin, etc
  
  for i=1:5, 
  
      % whatever    
      % do some work with x,y,z
      % blah blah
  
      if verbosity 
          fprintf('Now on iteration %i\n',i); % basic print
      end
  
      % or, with mutiple levels:
      if verbosity == 1;
          fprintf('Now on iteration %i\n',i); % basic print
      end
      if verbosity == 2;
          fprintf('x = %f,y = %f,z=%f %i\n',x,y,z); % more information
      end
  
      % do more work
  
  end
  </code></pre>
  
  <p>I don't like doing it with the if statements because it clutters up the code, but I can't think of any other way. 
  A one liner is better and worse:</p>
  
  <pre><code>if verbosity; fprintf('Iteration %i\n',i); end
  </code></pre>
  
  <p>Better because it's smaller, worse because one-liners are less readable than the same thing over 3 lines. </p>
  
  <p>What I want is some simple, more elegant way to control verbosity.</p>
  
  <p>Does that exist?</p>