debug

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2018 License: MIT Imports: 7 Imported by: 0

README

go-debug

a colorful debug tool like debug in golang.

Install

$ dep ensure -add github.com/jjeffcaii/go-debug

Example

screen_shot

package main

import (
	"time"

	"github.com/jjeffcaii/go-debug"
)

func main() {
	// Set global flags
	debug.SetFlags(debug.UpperCase | debug.TimeUTC)
	// Env settings:
	// show all: DEBUG=*
	// show service only: DEBUG=service:*
	// show http and redis: DEBUG=http,redis
	debug.Debug("http").Printf("this is a test debug info: %s\n", "hello world")
	debug.Debug("service:user").Println("this is a test debug info")
	debug.Debug("service:bill").Println("this is a test debug info")
	debug.Debug("mysql").Println("this is a test debug info")
	debug.Debug("redis").Println("this is a test debug info")
	// print cost mills
	debug.Debug("foobar", debug.Mills).Println("this is a test debug info")
	time.Sleep(127 * time.Millisecond)
	debug.Debug("foobar", debug.Mills).Println("this is a test debug info")
	time.Sleep(234 * time.Millisecond)
	debug.Debug("foobar", debug.Mills).Println("this is a test debug info")
}

Thanks

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetFlags

func SetFlags(first Flag, others ...Flag)

Types

type Flag

type Flag int
const (
	TimeLocal Flag = 1 << iota
	TimeUTC   Flag = 1 << iota
	LowerCase Flag = 1 << iota
	UpperCase Flag = 1 << iota
	Mills     Flag = 1 << iota
)

type IDebug

type IDebug interface {
	Print(a ...interface{})
	Println(a ...interface{})
	Printf(format string, a ...interface{})
}

func Debug

func Debug(namespace string, flags ...Flag) IDebug

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL