logcom

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(config Configuration)

func IsEnabled

func IsEnabled() bool

func SendAuditLog

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

func SendAuditLogBatch added in v1.3.7

func SendAuditLogBatch(ctx context.Context, models []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 logcomapi.LogLevel, message string) error

func SendConsoleLogWithModel

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

func SendNotification

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

func SendNotificationWithModel

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

func SetClientCredentialProvider

func SetClientCredentialProvider(provider ClientCredentialProvider)

Types

type AuditLogAction

type AuditLogAction interface {
	IgnoreChangeOf(propertyNames ...string) AuditLogAction
	AndNotify() NotificationOperation[AuditLogAction]
	AndLog(logLevel logcomapi.LogLevel, message string) AuditLogAction
	OnComplete(onCompleteCallback 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{})

func (*AuditLogCollector) AddModificationWithModelChanges

func (c *AuditLogCollector) AddModificationWithModelChanges(itemSubject, itemSubjectName string, changes []ModelChange)

type AuditLogConfiguration

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

type BatchedAuditLogOperation interface {
	AuditLogConfiguration
	CreateItem(subjectName string, newValue interface{}) BatchedAuditLogOperation
	ModifyItem(subjectName string, oldValue, newValue interface{}) BatchedAuditLogOperation
	ModifyItemWithModelChanges(subjectName string, changes []ModelChange) BatchedAuditLogOperation
	DeleteItem(subjectName string, oldValue interface{}) BatchedAuditLogOperation
}

type ClientCredentialProvider

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

type Configuration

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

type ConsoleLogAction

type ConsoleLogAction interface {
	OnComplete(onCompleteCallback func(error)) ConsoleLogAction
	Send() error
}

type ConsoleLogConfiguration

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

type ConsoleLogOperation

type ConsoleLogOperation interface {
	Level(level logcomapi.LogLevel) ConsoleLogOperation
	Message(message string) ConsoleLogConfiguration
	MessageF(format string, params ...any) ConsoleLogConfiguration
}

func Log

func Log() ConsoleLogOperation

type GroupedModificationAuditLogOperation

type GroupedModificationAuditLogOperation interface {
	AuditLogConfiguration
	AddCreation(subject, subjectName string, newValue interface{}) GroupedModificationAuditLogOperation
	AddModification(subject, subjectName string, oldValue, newValue interface{}) GroupedModificationAuditLogOperation
	AddModificationWithModelChanges(subject, subjectName string, changes []ModelChange) 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(oldModel, newModel interface{}, ignoredProperties ...string) ([]ModelChange, error)

type NotificationAction

type NotificationAction interface {
	AndLog(logLevel logcomapi.LogLevel, message string) NotificationAction
	OnComplete(onCompleteCallback func(error)) NotificationAction
	Send() error
}

type NotificationConfiguration

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

type NotificationMessage

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

type NotificationOperation

type NotificationOperation[T any] interface {
	Roles(targets ...string) NotificationMessage[T]
	Sessions(targets ...string) NotificationMessage[T]
	Users(targets ...string) NotificationMessage[T]
}

Jump to

Keyboard shortcuts

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