Documentation ¶
Overview ¶
Package activity provides tools for recording wash operations to journals stored in the user's cache directory. The cache directory is created at 'wash/activity' in the directory found via https://golang.org/pkg/os/#UserCacheDir. Journals are separated by Journal ID.
Wash plugins should use
activity.Record(ctx context.Context, msg string, a ...interface{})
to record entries, and
activity.Warnf(ctx context.Context, msg string, a ...interface{})
to warn about errors. The context contains the Journal ID.
Index ¶
- func CloseAll()
- func Dir() string
- func Record(ctx context.Context, msg string, a ...interface{})
- func SetDir(dir string)
- func SubmitMethodInvocation(ctx context.Context, plugin string, entryType string, method string)
- func Warnf(ctx context.Context, msg string, a ...interface{})
- type Journal
- type KeyType
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseAll ¶
func CloseAll()
CloseAll ensures open journals are flushed to disk and closed. Use when the application is shutting down.
func Record ¶
Record writes a new entry to the journal identified by the ID at `activity.JournalKey` in the provided context. It also writes to the server logs at the debug level. If no ID is registered, the entry is written to the server logs at the info level. If the ID is an empty string - which can happen when the JournalID header is missing from an API call - it uses the ID 'dead-letter-office'.
func SubmitMethodInvocation ¶
SubmitMethodInvocation submits a method invocation event to Google Analytics. It then records the invocation to the journal identified by the ID at `activity.JournalKey` in the provided context.
Note that entryType will typically be the type ID.
Types ¶
type Journal ¶
type Journal struct {
ID, Description string
// contains filtered or unexported fields
}
Journal is used to describe a log of activity. That activity is associated with a user-generated event by the ID, and can include a description and start time to provide further context when listed in activity history.
func GetJournal ¶
GetJournal returns the Journal stored in the context.
func JournalForPID ¶
JournalForPID creates a journal that can be used to record all wash-related activity induced by the given process ID. Journal ID is formatted as `<pid>-<name>-<createtime>`.
func NewJournal ¶
NewJournal creates a new journal entry with start time set to 'now'.
func (Journal) Open ¶
func (j Journal) Open() (io.ReadCloser, error)
Open returns a reader to read the journal.
func (Journal) Record ¶
Record writes a new entry to the journal. It creates a new file for the journal if needed, then appends the message to that journal. Journals are stored in the user's cache directory under `wash/activity/ID.log`.