When to use log over fmt for debugging and printing error?

Select between log and fmt using these facts:

  • The log functions print to stderr by default and can directed to an arbitrary writer. The fmt.Printf function prints to stdout.
  • The log functions can print timestamp, source code location and other info.
  • The log functions and fmt.Printf are both thread safe, but concurrent writes by fmt.Printf above an OS dependent size can be interleaved.

The answer to the three sub questions are “it depends”.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)