rec

package
v0.0.0-...-4eaaba6 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2014 License: BSD-3-Clause Imports: 3 Imported by: 0

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

func Log(user string, action string, extra ...interface{}) <-chan error

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.

Jump to

Keyboard shortcuts

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