Skip to content

0x5487/go-audit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-audit

simple audit log package for golang

add log

    //init
    // setup auditer
	mysqlAuditer := mysql.NewMysqlAuditer(db)
	audit.SetAuditer(mysqlAuditer)
    //init event
    event := &audit.Event{
		Namespace: namespace,
		TargetID:  targetid,
		Actor:     actor,
		Action:    action,
	}
    //save log
	audit.Log(event)

read log

    //init option
    Option := audit.NewReadLogOption()
    //set custom option
	Option.Action = "action"
	Option.Actor = "actor"
	Option.Namespace = "namespace"
	Option.Skip = 0
	Option.PerPage = 20
    starttime := time.Date(2017, 10, 10, 0, 0, 0, 0, time.Local)
	Option.StartTime = &starttime
	endtime := time.Date(2017, 10, 17, 0, 0, 0, 0, time.Local)
	Option.EndTime = &endtime
	result, _ := audit.ReadLog(Option)
	for _, row := range result {
		fmt.Println("%v", row)
	}

About

simple audit log package for golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages