-
Notifications
You must be signed in to change notification settings - Fork 10
DGit Tracing
DGit has tracing capabilities that can be helpful in problem diagnosis and development. It is somewhat aligned with the way that tracing works in the standard git implementation but has some subtle differences.
Using standard git you can set an environment variable GIT_TRACE to a value of 1 or 2 and tracing is then sent to stderr. You can set GIT_TRACE to the name of a file where the tracing information will be appended. DGit supports this environment variable in these modes.
In cases where you are using standard git and DGit you can set tracing for just DGit by using the DGIT_TRACE environment variable instead and it will not interfere with your standard git client. This environment variable works the same way as described above with the GIT_TRACE.
If you are developing DGit you can add tracing by using the log package. The entry point in main.go checks the environment variable and configures the package to redirect the output to the correct place. All you need to do is to call log.Printf
, log.Println
with your tracing information. Information for the user should be presented with either fmt.Printf
or fmt.Fprintf(os.Stderr, ...)
and not with the log package since there is no guarantee that the user will see it.