title: golang gorm Access the underlying mysql query
body: <p>Is there a way to get the sql query log from <a href="https://github.com/jinzhu/gorm" rel="noreferrer">https://github.com/jinzhu/gorm</a>?</p>
  
  <p>e.g. in dev environment, it would be useful to be able to log to the console the mysql queries that have been called.</p>
  
  <p>e.g. how to get the underlying sql query log for the following queries:</p>
  
  <pre><code>gorm.Find(&amp;todos)
  gorm.Preload("User").Find(&amp;todos)
  </code></pre>
  
  <p>I am aware that I can call:</p>
  
  <pre><code>gorm.Debug().Find(&amp;todos)
  gorm.Debug().Preload("User").Find(&amp;todos)
  </code></pre>
  
  <p>but I would like to only call <code>Debug()</code> if in dev envrionment and not in production</p>