Documentation
¶
Index ¶
Constants ¶
const ( // Level is the log level at which audit logs are written. Level = zerolog.Level(20) )
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
Middleware is an HTTP middleware that creates a new audit log entry for the current request and enriches it with information about the request. The log entry is written to the log when the request is complete.
A panic during the request will be recovered and logged as an error in the audit entry. The HTTP status code of the response is also logged in the audit entry; further details may be added by the application.
Types ¶
type Entry ¶
type Entry struct { Method string Path string Status int SourceIP string UserAgent string RequestedProfile string Authorized bool AuthSubject string AuthIssuer string AuthAudience []string AuthExpirySecs int64 Error string Repositories []string Permissions []string ExpirySecs int64 }
Entry is an audit log entry for the current request.
func Context ¶
Context returns the Entry for the current request, creating one if it does not exist. If the returned context is kept, the returned entry can be further enriched. If not, information written to the entry will be lost.
func Log ¶
Get the log entry for the current request. This is safe to use even if the context does not create an entry.
func (*Entry) Begin ¶
Begin sets up the audit log entry for the current request with details from the request.
func (*Entry) End ¶
End writes the audit log entry. If the returned func is deferred, any panic will be recovered so the log entry can be written before the panic is re-raised.
func (*Entry) MarshalZerologObject ¶
MarshalZerologObject implements zerolog.LogObjectMarshaler. This avoids the need for reflection when logging, at the cost of requiring maintenance when the Entry struct changes.