Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

XRSec/checkerr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Go Check Error

  • Collecting Error Logs
  • Printing error logs
    • Print error log location

init

import "github.com/XRSec/checkerr"

0x01

checkerr.Notice("打印通知", "结果")
checkerr.Notice("Print Notice", "Result")

0x02

func main() {
	var err error
	if err := errors.New(Error Message); err != nil {
		checkerr.Log("main", err) // AppName main
	}
}

Damo

func main() {
	ErrorsData = make(map[string]string)
	for i := 0; i < 2; i++ {
		checkerr.Notice("Notice "+time.Now().Format("15:04:05.00000"), "Result "+strconv.Itoa(i))
		checkerr.Error("Error "+time.Now().Format("15:04:05.00000")+" ", "Result "+strconv.Itoa(i))
		checkerr.Warning("Warning "+time.Now().Format("15:04:05.00000")+" ", "Result "+strconv.Itoa(i))
		fmt.Println("----------------------")
		if i == 0 {
			if err := errors.New(strconv.Itoa(i)); err != nil {
				checkerr.Log("main", err)
				fmt.Println("The ErrorsData = ", ErrorsData)
			}
		} else {
			//ErrorsData = make(map[string]string)
			if err := errors.New(strconv.Itoa(i)); err != nil {
				checkerr.Log("main", err)
				fmt.Println("The ErrorsData = ", ErrorsData)
			}
		}
	}
	fmt.Println("----------------------")
	for i, v := range ErrorsData {
		checkerr.Warning(i, v)
	}
}