Providing debug and traceback information
Debug and traceback information is mostly useful for you or other developers, but it can also help your end users share valuable information with you to help debug a potential issue found in your code. There are several diverse ways to provide this information. Debug and traceback information is primarily output to a log file, and often, the addition of a verbose
flag will print this output, which is usually hidden.
Logging data
Since debug data is usually found in log files, let us discuss how to include logging in your command-line application and determine the levels associated with logging—info
, error
, and debug
levels of severity. In this example, let us use a simple log package to demonstrate this example. There are several different popular structured log packages, including the following:
- Zap (https://github.com/uber-go/zap)—Fast structured logger developed by Uber
- ZeroLog (https://github.com/rs/zerolog...