logcom

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 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 Configuration, 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

func SetClientCredentialProvider added in v1.2.3

func SetClientCredentialProvider(provider ClientCredentialProvider)

Types

type AuditLogAction

type AuditLogAction interface {
	IgnoreChangeOf(propertyNames ...string) AuditLogAction
	AndNotify() NotificationConfigurer[AuditLogAction]
	AndLog(logLevel zerolog.Level, message string) AuditLogAction
	OnFailure(onErrorCallback func(error)) 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 AuditLogConfiguration added in v1.2.1

type AuditLogConfiguration interface {
	UseService2ServiceAuthorization() AuditLogAction
	WithBearerAuthorization(bearerToken string) AuditLogAction
	WithContext(ctx context.Context) AuditLogAction
	WithTransactionID(transactionID uuid.UUID) AuditLogConfiguration
}

func AuditCreation

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

func AuditDeletion

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

func AuditModification

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

type AuditLogModelDiff

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

type AuditLogOperation

type AuditLogOperation interface {
	BatchCreate(subject string) BatchedAuditLogOperation
	BatchDelete(subject string) BatchedAuditLogOperation
	BatchModify(subject string) BatchedAuditLogOperation
	Create(subject, subjectName string, newValue interface{}) AuditLogConfiguration
	Modify(subject, subjectName string, oldValue, newValue interface{}) AuditLogConfiguration
	Delete(subject, subjectName string, oldValue interface{}) AuditLogConfiguration
	GroupedModify(subject, subjectName string) GroupedModificationAuditLogOperation
}

func Audit

func Audit() AuditLogOperation

type BatchedAuditLogOperation added in v1.2.1

type BatchedAuditLogOperation interface {
	AuditLogConfiguration
	CreateItem(subjectName string, newValue interface{}) BatchedAuditLogOperation
	ModifyItem(subjectName string, oldValue, newValue interface{}) BatchedAuditLogOperation
	DeleteItem(subjectName string, oldValue interface{}) BatchedAuditLogOperation
}

type ClientCredentialProvider added in v1.2.3

type ClientCredentialProvider interface {
	GetClientCredential() (string, error)
}

type Configuration added in v1.2.1

type Configuration struct {
	ServiceName              string
	LogComURL                string
	HeaderProvider           HeaderProviderFunc
	ClientCredentialProvider ClientCredentialProvider
}

type ConsoleLog

type ConsoleLog interface {
}

type GroupedModificationAuditLogOperation added in v1.2.1

type GroupedModificationAuditLogOperation interface {
	AuditLogConfiguration
	AddCreation(subject, subjectName string, newValue interface{}) GroupedModificationAuditLogOperation
	AddModification(subject, subjectName string, oldValue, newValue interface{}) GroupedModificationAuditLogOperation
	AddDeletion(subject, subjectName string, oldValue interface{}) GroupedModificationAuditLogOperation
}

type HeaderProviderFunc

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

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
}

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 {
	UseService2ServiceAuthorization() 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