Go Trace Utility

A small utility to enable tracing in go. It prints information about current source file, line number and input variable after formatting it according to a format specifier.

go get github.com/dizitart/trace
                                

Usage

                                    
package main

import (
	"fmt"
	"github.com/dizitart/trace"
	"time"
)

func main() {
	fmt.Println("Hello World")

	// Set up tracing
	trace.ENABLE_TRACE = true
	trace.SetOut(trace.OUT_ALL)
	trace.TRACE_FILE_PATH = "/temp/trace.log"
	trace.SetMessageFormat(trace.PRINT_FILE | trace.PRINT_LINE | trace.PRINT_PROC)

	someString := "Hello World"
	// assert
	trace.Assert(someString == "hello world")
	// formatted assertion
	trace.Assertf(someString == "hello world", "Assertion Failed! at %v", time.Now())

	// write
	trace.Write(someString)
	// formatted write
	trace.Writef("Tracing at %v for value %s", time.Now(), someString)
}
                                    
                                
GIT SHA DOCUMENTATION
1dc5130 Current API