Documentation
¶
Index ¶
- Constants
- Variables
- func DBPath(override string) string
- func DataDir() string
- func Diagnostic(kind, guard string, err error)
- func DiagnosticLogs() []string
- func Hash(text string) string
- func Since(value string, now time.Time) (string, error)
- func StateDir() string
- func Timestamp(t time.Time) string
- func ValidOutcome(s string) bool
- type Canary
- type DiagnosticEntry
- type Filter
- type Hit
- type Stat
- type Store
- func (s *Store) CanaryHits(ctx context.Context, token string) ([]Hit, error)
- func (s *Store) Close() error
- func (s *Store) Guards(ctx context.Context) ([]string, error)
- func (s *Store) Insert(ctx context.Context, h Hit) error
- func (s *Store) KnownCanary(ctx context.Context, token string) (bool, error)
- func (s *Store) LatestCanary(ctx context.Context) (c Canary, err error)
- func (s *Store) List(ctx context.Context, f Filter) ([]Hit, error)
- func (s *Store) NewCanary(ctx context.Context, token string) error
- func (s *Store) Show(ctx context.Context, id int64) (Hit, error)
- func (s *Store) Stats(ctx context.Context, f Filter, by string) ([]Stat, error)
Constants ¶
const ( KindNotLogged = "not-logged" // a hit could not be written to the database KindBackground = "background" // a guard left a process holding its output KindCapture = "capture" // reading guard output failed KindTruncated = "truncated" // stored output was cut at CaptureCap KindPassthrough = "passthrough" // forwarding guard output failed KindCanary = "canary" // canary lookup failed KindPanic = "panic" // blotter recovered from an internal failure KindOther = "other" // lines written before kinds existed )
Diagnostic kinds let doctor summarize past runtime events.
const CaptureCap = 64 << 10
const DiagnosticLogLimit = 1 << 20
DiagnosticLogLimit is the size at which errors.log rotates to errors.log.1.
const SchemaVersion = 1
Variables ¶
var Outcomes = []string{"block", "error", "ask", "pass", "canary"}
Outcomes are the recorded results of a guard run.
Functions ¶
func Diagnostic ¶
Diagnostic appends "<ts> <kind> <guard|-> <message>" to errors.log.
func DiagnosticLogs ¶ added in v0.2.0
func DiagnosticLogs() []string
func ValidOutcome ¶
Types ¶
type DiagnosticEntry ¶ added in v0.2.0
type DiagnosticEntry struct{ TS, Kind, Guard, Message string }
func ParseDiagnostic ¶ added in v0.2.0
func ParseDiagnostic(line string) (DiagnosticEntry, bool)
ParseDiagnostic reads one errors.log line. Lines without a known kind are reported whole as KindOther.
type Hit ¶
type Hit struct {
ID int64 `json:"id"`
TS string `json:"ts"`
Guard string `json:"guard"`
Harness string `json:"harness"`
Outcome string `json:"outcome"`
RC int `json:"rc"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
Truncated bool `json:"truncated"`
DurationMS int64 `json:"duration_ms"`
Project string `json:"project"`
CWD string `json:"cwd"`
Session string `json:"session"`
Tool string `json:"tool"`
Payload string `json:"payload"`
Event string `json:"event"`
Version string `json:"blotter_version"`
}
func (Hit) MarshalJSON ¶ added in v0.3.0
MarshalJSON writes the stored event as a JSON object when it is one, null when it is empty (hash recording) and a string otherwise, so harness events read as JSON while arbitrary recorded input is still shown as received.