activitylogger

package
v2.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityLogger

type ActivityLogger struct {
	// contains filtered or unexported fields
}

ActivityLogger write command and request information to file for auditing purposes. Safe to call concurrently

func NewActivityLogger

func NewActivityLogger(options Options) (*ActivityLogger, error)

NewActivityLogger creates a new activity logger using given options

func (*ActivityLogger) GetLogEntries

func (l *ActivityLogger) GetLogEntries(filter Filter, onValue func(line []byte) error) error

GetLogEntries get log entries

func (*ActivityLogger) GetPath

func (l *ActivityLogger) GetPath() string

GetPath returns the path to the activity log

func (*ActivityLogger) LogCommand

func (l *ActivityLogger) LogCommand(cmd *cobra.Command, args []string, cmdStr string, messages ...string)

LogCommand writes the c8y cli command used to the activity log

func (*ActivityLogger) LogCustom

func (l *ActivityLogger) LogCustom(message string)

LogCustom writes a custom entry to the activity log

func (*ActivityLogger) LogRequest

func (l *ActivityLogger) LogRequest(resp *http.Response, body gjson.Result, responseTime int64)

LogRequest writes a http response to the activity log

type CommandEntry

type CommandEntry struct {
	Time      string   `json:"time,omitempty"`
	Context   string   `json:"ctx,omitempty"`
	Type      string   `json:"type,omitempty"`
	Arguments []string `json:"arguments,omitempty"`
	Message   string   `json:"message,omitempty"`
}

type Filter

type Filter struct {
	Host     string `json:"host"`
	Type     string `json:"type"`
	DateFrom string `json:"dateFrom"`
	DateTo   string `json:"dateTo"`
}

type Options

type Options struct {
	Methods      string
	Disabled     bool
	OutputFolder string
}

Options activity log options to control path, filters etc.

type RequestEntry

type RequestEntry struct {
	Time           string `json:"time,omitempty"`
	Context        string `json:"ctx,omitempty"`
	Type           string `json:"type,omitempty"`
	Method         string `json:"method,omitempty"`
	Host           string `json:"host,omitempty"`
	Path           string `json:"path,omitempty"`
	Query          string `json:"query,omitempty"`
	Accept         string `json:"accept,omitempty"`
	ProcessingMode string `json:"processingMode,omitempty"`
	StatusCode     int    `json:"statusCode,omitempty"`
	ResponseTimeMS int    `json:"responseTimeMS,omitempty"`
	ResponseSelf   string `json:"responseSelf,omitempty"`
}

Jump to

Keyboard shortcuts

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