Documentation ¶
Overview ¶
Package logger contains different methods to log.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallerPrefix ¶
CallerPrefix returns the file and line number information about the methods that called this method, based on the current goroutine's stack. The argument callDepth is the number of stack frames to ascend, with 0 identifying the method that called CallerPrefix, 1 identifying the method that called that method, and so on.
This code is adapted from testing.go, where it is in a private method called decorate.
func DoLog ¶
DoLog logs the given arguments to the given writer, along with a timestamp and information about what test and file is doing the logging.
func Log ¶
Log logs the given arguments to stdout, along with a timestamp and information about what test and file is doing the logging. This is an alternative to t.Logf that logs to stdout immediately, rather than buffering all log output and only displaying it at the very end of the test. See the Logf method for more info.
func Logf ¶
Logf logs the given format and arguments, formatted using fmt.Sprintf, to stdout, along with a timestamp and information about what test and file is doing the logging. This is an alternative to t.Logf that logs to stdout immediately, rather than buffering all log output and only displaying it at the very end of the test. This is useful because:
- It allows you to iterate faster locally, as you get feedback on whether your code changes are working as expected right away, rather than at the very end of the test run.
- If you have a bug in your code that causes a test to never complete or if the test code crashes,, t.Logf would show you no log output whatsoever, making debugging very hard, where as this method will show you all the log output available.
- If you have a test that takes a long time to complete, some CI systems will kill the test suite prematurely because there is no log output with t.Logf (e.g., CircleCI kills tests after 10 minutes of no log output). With this log method, you get log output continuously.
Note that there is a proposal to improve t.Logf (https://github.com/golang/go/issues/24929), but until that's implemented, this method is our best bet.
Types ¶
This section is empty.