Documentation ¶
Overview ¶
Package rec provides types and functions for logging user actions, for auditing and statistics.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Error returned when a user is not provided to the Log function. ErrMissingUser = errors.New("Missing user") // Error returned when an action is not provided to the Log function. ErrMissingAction = errors.New("Missing action") )
Functions ¶
func Log ¶
Log stores an action in the database. It launches a goroutine, and may return an error in a channel.
Example ¶
package main import ( "github.com/tsuru/tsuru/rec" ) func main() { // logging and waiting ch := rec.Log("user@email.com", "action", "arg1", 10, true) <-ch // logging without blocking rec.Log("user@email.com", "action-2", "arg1", 10, true) // logging and checking for errors ch = rec.Log("user@email.com", "action-3", "arg1", 10, true) if err, ok := <-ch; ok { panic(err) } }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.