logcom

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(config LogComConfiguration, logger *zerolog.Logger)

func IsEnabled

func IsEnabled() bool

func SendAuditLog

func SendAuditLog(ctx context.Context, model logcomapi.CreateAuditLogRequestDto) error

func SendAuditLogGroup

func SendAuditLogGroup(ctx context.Context, auditLogCollector *AuditLogCollector) error

func SendAuditLogWithCreation

func SendAuditLogWithCreation(ctx context.Context, subject, subjectName string, newValue interface{}) error

func SendAuditLogWithDeletion

func SendAuditLogWithDeletion(ctx context.Context, subject, subjectName string, oldValue interface{}) error

func SendAuditLogWithModification

func SendAuditLogWithModification(ctx context.Context, subject, subjectName string, oldValue, newValue interface{}, ignoredProperties ...string) error

func SendAuditLogWithModificationModelChanges

func SendAuditLogWithModificationModelChanges(ctx context.Context, subject, subjectName string, changes []ModelChange) error

func SendConsoleLog

func SendConsoleLog(ctx context.Context, logLevel zerolog.Level, message string) error

func SendConsoleLogWithModel

func SendConsoleLogWithModel(ctx context.Context, model logcomapi.CreateConsoleLogRequestDto) error

func SendNotification

func SendNotification(ctx context.Context, eventCategory string, message string, targets map[string][]string) error

func SendNotificationWithModel

func SendNotificationWithModel(ctx context.Context, model logcomapi.CreateNotificationRequestDto) error

Types

type AuditLogAction

type AuditLogAction interface {
	IgnoreChangeOf(propertyName string) AuditLogAction
	AndNotify() NotificationConfigurer[AuditLogAction]
	AndNotifyRoles(targets ...string) AuditLogAction
	AndNotifySessions(targets ...string) AuditLogAction
	AndNotifyUsers(targets ...string) AuditLogAction
	AndLog(logLevel zerolog.Level, message string) AuditLogAction
	Send() error
}

type AuditLogCollector

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

func NewAuditLogCollector

func NewAuditLogCollector(parentSubject, parentSubjectName string) *AuditLogCollector

func NewAuditLogCollectorWithParent

func NewAuditLogCollectorWithParent(parentAuditLog logcomapi.CreateAuditLogRequestDto) *AuditLogCollector

func (*AuditLogCollector) Add

func (c *AuditLogCollector) Add(model logcomapi.CreateAuditLogRequestDto)

func (*AuditLogCollector) AddCreation

func (c *AuditLogCollector) AddCreation(itemSubject, itemSubjectName string, newValue interface{})

func (*AuditLogCollector) AddDeletion

func (c *AuditLogCollector) AddDeletion(itemSubject, itemSubjectName string, oldValue interface{})

func (*AuditLogCollector) AddModification

func (c *AuditLogCollector) AddModification(itemSubject, itemSubjectName string, oldValue, newValue interface{})

type AuditLogInitializer

type AuditLogInitializer interface {
	WithClientSecret(secret string) AuditLogAction
	WithBearerAuthorization(bearerToken string) AuditLogAction
	WithContext(ctx context.Context) AuditLogAction
	WithTransactionID(transactionID uuid.UUID) AuditLogInitializer
}

func AuditCreation

func AuditCreation(subject, subjectName string, newValue interface{}) AuditLogInitializer

func AuditDeletion

func AuditDeletion(subject, subjectName string, oldValue interface{}) AuditLogInitializer

func AuditModification

func AuditModification(subject, subjectName string, oldValue, newValue interface{}) AuditLogInitializer

type AuditLogModelDiff

type AuditLogModelDiff interface {
	GetChanges(model interface{}, ignoredProperties map[string]interface{}) []ModelChange
}

type AuditLogOperation

type AuditLogOperation interface {
	Create(subject, subjectName string, newValue interface{}) AuditLogInitializer
	Delete(subject, subjectName string, oldValue interface{}) AuditLogInitializer
	Modify(subject, subjectName string, oldValue interface{}, newValue interface{}) AuditLogInitializer
}

func Audit

func Audit() AuditLogOperation

type ConsoleLog

type ConsoleLog interface {
}

type HeaderProviderFunc

type HeaderProviderFunc func(ctx context.Context) http.Header

type LogComConfiguration

type LogComConfiguration struct {
	ServiceName    string
	LogComURL      string
	HeaderProvider HeaderProviderFunc
}

type ModelChange

type ModelChange struct {
	PropertyName string
	OldValue     interface{}
	NewValue     interface{}
}

func GetModelChanges

func GetModelChanges(ctx context.Context, oldModel, newModel interface{}, ignoredProperties ...string) ([]ModelChange, error)

type NotificationAction

type NotificationAction interface {
	AndLog(logLevel zerolog.Level, message string) NotificationAction
	Send() error
	SendMessage(message string) error
}

type NotificationConfigurer

type NotificationConfigurer[T any] interface {
	Message(message string) T
	Roles(targets ...string) NotificationConfigurer[T]
	Sessions(targets ...string) NotificationConfigurer[T]
	Users(targets ...string) NotificationConfigurer[T]
}

type NotificationInitializer

type NotificationInitializer interface {
	WithClientSecret(secret string) NotificationAction
	WithBearerAuthorization(bearerToken string) NotificationAction
	WithContext(ctx context.Context) NotificationAction
	WithTransactionID(transactionID uuid.UUID) NotificationInitializer
}

type NotificationMessage

type NotificationMessage[T any] interface {
	Message(message string) T
}

Jump to

Keyboard shortcuts

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