...

Source file src/edge-infra.dev/pkg/edge/edgeagent/audit/audit.go

Documentation: edge-infra.dev/pkg/edge/edgeagent/audit

     1  package audit
     2  
     3  import (
     4  	"github.com/go-logr/logr"
     5  
     6  	"edge-infra.dev/pkg/lib/fog"
     7  )
     8  
     9  type Sink struct {
    10  	// log is an instance of the edge fog logger.
    11  	log logr.Logger
    12  	// client name
    13  	clientName string
    14  }
    15  
    16  // New returns a new instance of the audit sink.
    17  // For the first pass actor will default to the component sending the request (syncedobjectctl or chariot),
    18  // until a way is found to pass in the actor that made the api request
    19  func New(actor string) *Sink {
    20  	return &Sink{
    21  		log:        fog.New(),
    22  		clientName: actor,
    23  	}
    24  }
    25  
    26  // Log displays the audit log to stdout.
    27  func (s Sink) Log(eventType string, keysAndValues ...interface{}) {
    28  	s.log.WithName(s.clientName).WithValues("log_class", "audit", "log_type", "edge-agent", "event-type", eventType).Info("edge agent audit logging", keysAndValues...)
    29  }
    30  

View as plain text