Documentation
¶
Index ¶
Constants ¶
View Source
const ( MaxLogSize = 10 * 1024 * 1024 // 10MB MaxLogFiles = 5 LogFilePermission = 0600 LogDirPermission = 0700 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessLogEntry ¶
type AccessLogEntry struct {
Timestamp time.Time `json:"timestamp"`
Path string `json:"path"`
AccessType AccessType `json:"access_type"`
User string `json:"user"`
IP string `json:"ip"`
UserAgent string `json:"user_agent"`
Method string `json:"method"`
StatusCode int `json:"status_code"`
Allowed bool `json:"allowed"`
DeniedReason string `json:"denied_reason,omitempty"`
}
func (AccessLogEntry) MarshalJSON ¶
func (e AccessLogEntry) MarshalJSON() ([]byte, error)
MarshalJSON customizes the JSON output for AccessLogEntry
func (*AccessLogEntry) UnmarshalJSON ¶
func (e *AccessLogEntry) UnmarshalJSON(data []byte) error
UnmarshalJSON customizes the JSON parsing for AccessLogEntry
type AccessLogMiddleware ¶
type AccessLogMiddleware struct {
// contains filtered or unexported fields
}
func NewMiddleware ¶
func NewMiddleware(logger *AccessLogger) *AccessLogMiddleware
func (*AccessLogMiddleware) Handler ¶
func (m *AccessLogMiddleware) Handler() gin.HandlerFunc
type AccessLogger ¶
type AccessLogger struct {
// contains filtered or unexported fields
}
func GetAccessLogger ¶
func GetAccessLogger(ctx *gin.Context) *AccessLogger
func (*AccessLogger) Close ¶
func (al *AccessLogger) Close() error
func (*AccessLogger) GetUserLogs ¶
func (al *AccessLogger) GetUserLogs(user string, limit int) ([]AccessLogEntry, error)
GetUserLogs gets the logs for a user It reads the log files for the user and returns the logs It also limits the number of logs returned
func (*AccessLogger) LogAccess ¶
func (al *AccessLogger) LogAccess(ctx *gin.Context, path string, accessType AccessType, accessLevel acl.AccessLevel, allowed bool, deniedReason string)
type AccessLoggerInterface ¶
type AccessLoggerInterface interface {
LogAccess(ctx *gin.Context, path string, accessType AccessType, accessLevel acl.AccessLevel, allowed bool, deniedReason string)
GetUserLogs(user string, limit int) ([]AccessLogEntry, error)
Close() error
}
AccessLoggerInterface defines the interface for access logging operations
type AccessType ¶
type AccessType string
const ( AccessTypeAdmin AccessType = "admin" AccessTypeRead AccessType = "read" AccessTypeWrite AccessType = "write" AccessTypeDeny AccessType = "deny" )
func ConvertACLLevel ¶
func ConvertACLLevel(level acl.AccessLevel) AccessType
ConvertACLLevel converts an ACL access level to an AccessType
type LogWriter ¶
type LogWriter interface {
WriteEntry(entry AccessLogEntry) error
Close() error
}
LogWriter defines the interface for writing log entries
Click to show internal directories.
Click to hide internal directories.