Documentation
¶
Index ¶
- Constants
- func GetTablePrefix() string
- func SetTablePrefix(prefix string)
- func Severity(severity int) models.Severity
- type Action
- type ActionManager
- type ActionManagerImpl
- func (a *ActionManagerImpl) AddAction(action Action)
- func (a *ActionManagerImpl) GetActionArgTypes(path string) ([]reflect.Type, error)
- func (a *ActionManagerImpl) GetActionDetails(path string) (Action, bool)
- func (a *ActionManagerImpl) GetActionsMap() Actions
- func (a *ActionManagerImpl) GetAllActions() []string
- func (a *ActionManagerImpl) GetApp() App
- func (a *ActionManagerImpl) InvokeAction(path string, args ...any) ([]any, error)
- func (a *ActionManagerImpl) RemoveAction(path string)
- type Actions
- type Analytics
- type AnalyticsImpl
- type AnalyticsSummary
- type App
- type AppImpl
- func (l *AppImpl) AddContextValue(ctx context.Context, key string, value any) App
- func (l *AppImpl) Close() error
- func (l *AppImpl) DeleteGlobal(key string) error
- func (l *AppImpl) DeleteLogs(q *Query) error
- func (l *AppImpl) GetActionManager() ActionManager
- func (l *AppImpl) GetAllGlobals() ([]models.Global, error)
- func (l *AppImpl) GetAllModels() LogModels
- func (l *AppImpl) GetAnalytics() Analytics
- func (l *AppImpl) GetContextValues(ctx context.Context) (Map, bool)
- func (l *AppImpl) GetFeatureFlags() FeatureFlags
- func (l *AppImpl) GetFromContext(ctx context.Context, key string) (any, bool)
- func (l *AppImpl) GetGlobal(key string) (models.Global, error)
- func (l *AppImpl) GetGlobalBool(key string) (bool, error)
- func (l *AppImpl) GetGlobalFloat(key string) (float64, error)
- func (l *AppImpl) GetGlobalInt(key string) (int64, error)
- func (l *AppImpl) GetGlobalString(key string) (string, error)
- func (l *AppImpl) GetGlobalValue(key string, out any) error
- func (l *AppImpl) GetLogger() Logger
- func (l *AppImpl) GetLogs(q *Query) ([]models.Log, error)
- func (l *AppImpl) GetTypeKind(type_ reflect.Type) (TypeKind, bool)
- func (l *AppImpl) GetTypeKindString(type_ string) (TypeKind, bool)
- func (l *AppImpl) GetWebPanel() WebPanel
- func (l *AppImpl) IsSSEEnabled() bool
- func (l *AppImpl) NewTimer() *Timer
- func (l *AppImpl) PrepareContext(parent context.Context, values Map) context.Context
- func (l *AppImpl) SetGlobal(key string, value any, exported bool) error
- func (l *AppImpl) SetTypeKind(type_ reflect.Type, kind TypeKind)
- func (l *AppImpl) SetTypeKindString(type_ string, kind TypeKind)
- type AuthFunc
- type Common
- type Config
- type ConfigOpt
- func AddModel(displayName string, modelId Model, icon ...string) ConfigOpt
- func AddProxy(proxy proxy.Proxy) ConfigOpt
- func Combine(opts ...ConfigOpt) ConfigOpt
- func If(condition bool, opts ...ConfigOpt) ConfigOpt
- func IfElse(condition bool, ifOpts ConfigOpt, elseOpts ...ConfigOpt) ConfigOpt
- func SetModels(models LogModels) ConfigOpt
- func WithAction(path string, description string, action interface{}) ConfigOpt
- func WithAdminCredentials(username, password string) ConfigOpt
- func WithAppName(appName string) ConfigOpt
- func WithAuth(authFunc AuthFunc) ConfigOpt
- func WithDatabase(database gorm.Dialector) ConfigOpt
- func WithDefaultLanguage(language Language) ConfigOpt
- func WithMainFilter(filter logfilter.Filter) ConfigOpt
- func WithSSEEnabled(enabled bool) ConfigOpt
- func WithWebPanelConfig(opts ...WebPanelConfigOpt) ConfigOpt
- type FeatureFlags
- type FeatureFlagsImpl
- func (f *FeatureFlagsImpl) CreateFeatureFlag(flag *models.FeatureFlag) error
- func (f *FeatureFlagsImpl) DeleteFeatureFlag(id uint) error
- func (f *FeatureFlagsImpl) GetApp() App
- func (f *FeatureFlagsImpl) GetFeatureFlag(id uint) (models.FeatureFlag, error)
- func (f *FeatureFlagsImpl) GetFeatureFlagByName(name string) (models.FeatureFlag, error)
- func (f *FeatureFlagsImpl) GetFeatureFlags() ([]models.FeatureFlag, error)
- func (f *FeatureFlagsImpl) HasFeatureFlag(ctx context.Context, flag string) (bool, error)
- func (f *FeatureFlagsImpl) UpdateFeatureFlag(flag *models.FeatureFlag) error
- type Language
- type LogModel
- type LogModels
- type Logger
- type LoggerImpl
- func (l *LoggerImpl) Error(model Model, message any, category string) error
- func (l *LoggerImpl) Fatal(model Model, message any, category string) error
- func (l *LoggerImpl) GetApp() App
- func (l *LoggerImpl) Info(model Model, message any, category string) error
- func (l *LoggerImpl) Log(model Model, message any, category string) error
- func (l *LoggerImpl) NewTimer() *Timer
- func (l *LoggerImpl) Print(model Model, message any, category string, severity models.Severity) error
- func (l *LoggerImpl) Trace(model Model, message any, category string) error
- func (l *LoggerImpl) Warn(model Model, message any, category string) error
- func (l *LoggerImpl) WithContext(ctx context.Context) Logger
- type Map
- type Model
- type PageStats
- type PaginationStrategy
- type Query
- func (q *Query) After(from time.Time) *Query
- func (q *Query) Before(to time.Time) *Query
- func (q *Query) MessageContaints(text string) *Query
- func (q *Query) WithCategory(category string) *Query
- func (q *Query) WithCursorPagination(cursor int, limit int) *Query
- func (q *Query) WithFilter(filter models.Filter) *Query
- func (q *Query) WithIDGreaterThan(id uint) *Query
- func (q *Query) WithIDs(ids ...uint) *Query
- func (q *Query) WithModel(model string) *Query
- func (q *Query) WithOffsetPagination(offset int, page int) *Query
- func (q *Query) WithSeverity(severity models.Severity) *Query
- func (q *Query) WithTimeRange(from time.Time, to time.Time) *Query
- type QueryOptions
- type Timer
- type TypeKind
- type WebPanel
- type WebPanelConfig
- type WebPanelConfigOpt
- type WebPanelImpl
- func (w *WebPanelImpl) Auth(r *http.Request) bool
- func (w *WebPanelImpl) CreateSession(user models.User, device string) (string, error)
- func (w *WebPanelImpl) CreateUser(username, displayName, password string, isAdmin bool) (models.User, error)
- func (w *WebPanelImpl) DeleteSession(token string) error
- func (w *WebPanelImpl) GetActiveSessions(userID uint) ([]models.Session, error)
- func (w *WebPanelImpl) GetAllUsers() ([]models.User, error)
- func (w *WebPanelImpl) GetApp() App
- func (w *WebPanelImpl) GetDefaultLanguage() Language
- func (w *WebPanelImpl) GetSession(token string) (*models.Session, error)
- func (w *WebPanelImpl) GetUser(id uint) (models.User, error)
- func (w *WebPanelImpl) LoginUser(username, password string) (models.User, error)
- func (w *WebPanelImpl) UpdateUser(user models.User) error
Constants ¶
View Source
const ( Trace models.Severity = models.Severity_Trace Log models.Severity = models.Severity_Log Info models.Severity = models.Severity_Info Warning models.Severity = models.Severity_Warning Error models.Severity = models.Severity_Error Fatal models.Severity = models.Severity_Fatal )
Variables ¶
This section is empty.
Functions ¶
func GetTablePrefix ¶
func GetTablePrefix() string
func SetTablePrefix ¶
func SetTablePrefix(prefix string)
Types ¶
type ActionManager ¶
type ActionManagerImpl ¶
type ActionManagerImpl struct {
// contains filtered or unexported fields
}
func (*ActionManagerImpl) AddAction ¶
func (a *ActionManagerImpl) AddAction(action Action)
func (*ActionManagerImpl) GetActionArgTypes ¶
func (a *ActionManagerImpl) GetActionArgTypes(path string) ([]reflect.Type, error)
func (*ActionManagerImpl) GetActionDetails ¶
func (a *ActionManagerImpl) GetActionDetails(path string) (Action, bool)
func (*ActionManagerImpl) GetActionsMap ¶
func (a *ActionManagerImpl) GetActionsMap() Actions
func (*ActionManagerImpl) GetAllActions ¶
func (a *ActionManagerImpl) GetAllActions() []string
func (*ActionManagerImpl) GetApp ¶
func (a *ActionManagerImpl) GetApp() App
func (*ActionManagerImpl) InvokeAction ¶
func (a *ActionManagerImpl) InvokeAction(path string, args ...any) ([]any, error)
func (*ActionManagerImpl) RemoveAction ¶
func (a *ActionManagerImpl) RemoveAction(path string)
type Analytics ¶
type Analytics interface {
// ID is automatically generated.
RegisterRequest(log models.RequestLog) error
GetStatistics(startTime time.Time, endTime time.Time) (AnalyticsSummary, error)
}
type AnalyticsImpl ¶
type AnalyticsImpl struct {
// contains filtered or unexported fields
}
func (*AnalyticsImpl) GetApp ¶
func (a *AnalyticsImpl) GetApp() App
func (*AnalyticsImpl) GetStatistics ¶
func (a *AnalyticsImpl) GetStatistics(startTime time.Time, endTime time.Time) (AnalyticsSummary, error)
func (*AnalyticsImpl) RegisterRequest ¶
func (a *AnalyticsImpl) RegisterRequest(log models.RequestLog) error
type AnalyticsSummary ¶
type AnalyticsSummary struct {
TotalVisits int64 `json:"total_visits"` // Total number of requests received.
UniqueVisitors int64 `json:"unique_visitors"` // Number of unique visitor IDs.
ActiveVisitors int64 `json:"active_visitors"` // Number of active visitors (last 5 minutes)
ErrorRate float64 `json:"error_rate"` // Rate of requests that are errors (e.g., 0.05 for 5%).
AverageLatencyMs float64 `json:"average_latency_ms"` // Average request latency in milliseconds.
P95LatencyMs int64 `json:"p95_latency_ms"` // 95th percentile request latency in milliseconds.
P99LatencyMs int64 `json:"p99_latency_ms"` // 99th percentile request latency in milliseconds.
TotalBytesSent int64 `json:"total_bytes_sent"` // Total bytes sent
TotalBytesRecv int64 `json:"total_bytes_recv"` // Total bytes received
TopPages []PageStats `json:"top_pages"` // Top 5 most visited pages
OSUsage map[string]float64 `json:"os_usage"` // OS usage distribution
BrowserUsage map[string]float64 `json:"browser_usage"` // Browser usage distribution
RefererUsage map[string]float64 `json:"referer_usage"` // Referer distribution
InstanceStats map[string]float64 `json:"instance_stats"` // Request distribution by instance
}
type App ¶
type App interface {
GetLogger() Logger
GetActionManager() ActionManager
GetWebPanel() WebPanel
GetAnalytics() Analytics
GetFeatureFlags() FeatureFlags
Close() error
GetAllModels() LogModels
SetTypeKind(type_ reflect.Type, kind TypeKind)
SetTypeKindString(type_ string, kind TypeKind)
GetTypeKind(type_ reflect.Type) (TypeKind, bool)
GetTypeKindString(type_ string) (TypeKind, bool)
PrepareContext(parent context.Context, values Map) context.Context
GetContextValues(ctx context.Context) (Map, bool)
GetFromContext(ctx context.Context, key string) (any, bool)
AddContextValue(ctx context.Context, key string, value any) App
IsSSEEnabled() bool
}
App is the main struct that contains library data for things like logging, actions, etc.
type AppImpl ¶
type AppImpl struct {
// contains filtered or unexported fields
}
func (*AppImpl) AddContextValue ¶
func (*AppImpl) DeleteGlobal ¶
func (*AppImpl) DeleteLogs ¶
func (*AppImpl) GetActionManager ¶
func (l *AppImpl) GetActionManager() ActionManager
func (*AppImpl) GetAllModels ¶
func (*AppImpl) GetAnalytics ¶
func (*AppImpl) GetContextValues ¶
func (*AppImpl) GetFeatureFlags ¶
func (l *AppImpl) GetFeatureFlags() FeatureFlags
func (*AppImpl) GetFromContext ¶
func (*AppImpl) GetTypeKindString ¶
func (*AppImpl) GetWebPanel ¶
func (*AppImpl) IsSSEEnabled ¶ added in v1.2.10
func (*AppImpl) PrepareContext ¶
func (*AppImpl) SetTypeKindString ¶
type ConfigOpt ¶
type ConfigOpt func(*Config)
func WithAction ¶
func WithAdminCredentials ¶
func WithAppName ¶
func WithDatabase ¶
func WithDefaultLanguage ¶
func WithMainFilter ¶ added in v1.2.10
func WithSSEEnabled ¶ added in v1.2.10
func WithWebPanelConfig ¶ added in v1.2.4
func WithWebPanelConfig(opts ...WebPanelConfigOpt) ConfigOpt
type FeatureFlags ¶
type FeatureFlags interface {
Common
HasFeatureFlag(ctx context.Context, flag string) (bool, error)
GetFeatureFlags() ([]models.FeatureFlag, error)
GetFeatureFlagByName(name string) (models.FeatureFlag, error)
GetFeatureFlag(id uint) (models.FeatureFlag, error)
CreateFeatureFlag(flag *models.FeatureFlag) error
UpdateFeatureFlag(flag *models.FeatureFlag) error
DeleteFeatureFlag(id uint) error
}
type FeatureFlagsImpl ¶
type FeatureFlagsImpl struct {
// contains filtered or unexported fields
}
func (*FeatureFlagsImpl) CreateFeatureFlag ¶
func (f *FeatureFlagsImpl) CreateFeatureFlag(flag *models.FeatureFlag) error
func (*FeatureFlagsImpl) DeleteFeatureFlag ¶
func (f *FeatureFlagsImpl) DeleteFeatureFlag(id uint) error
func (*FeatureFlagsImpl) GetApp ¶
func (f *FeatureFlagsImpl) GetApp() App
func (*FeatureFlagsImpl) GetFeatureFlag ¶
func (f *FeatureFlagsImpl) GetFeatureFlag(id uint) (models.FeatureFlag, error)
func (*FeatureFlagsImpl) GetFeatureFlagByName ¶
func (f *FeatureFlagsImpl) GetFeatureFlagByName(name string) (models.FeatureFlag, error)
func (*FeatureFlagsImpl) GetFeatureFlags ¶
func (f *FeatureFlagsImpl) GetFeatureFlags() ([]models.FeatureFlag, error)
func (*FeatureFlagsImpl) HasFeatureFlag ¶
func (*FeatureFlagsImpl) UpdateFeatureFlag ¶
func (f *FeatureFlagsImpl) UpdateFeatureFlag(flag *models.FeatureFlag) error
type Logger ¶
type Logger interface {
Common
WithContext(ctx context.Context) Logger
Print(model Model, message any, category string, severity models.Severity) error
Log(model Model, message any, category string) error
Info(model Model, message any, category string) error
Warn(model Model, message any, category string) error
Error(model Model, message any, category string) error
Fatal(model Model, message any, category string) error
Trace(model Model, message any, category string) error
NewTimer() *Timer
}
type LoggerImpl ¶
type LoggerImpl struct {
// contains filtered or unexported fields
}
func (*LoggerImpl) Error ¶
func (l *LoggerImpl) Error(model Model, message any, category string) error
func (*LoggerImpl) Fatal ¶
func (l *LoggerImpl) Fatal(model Model, message any, category string) error
func (*LoggerImpl) GetApp ¶
func (l *LoggerImpl) GetApp() App
func (*LoggerImpl) Info ¶
func (l *LoggerImpl) Info(model Model, message any, category string) error
func (*LoggerImpl) NewTimer ¶
func (l *LoggerImpl) NewTimer() *Timer
func (*LoggerImpl) Trace ¶
func (l *LoggerImpl) Trace(model Model, message any, category string) error
func (*LoggerImpl) Warn ¶
func (l *LoggerImpl) Warn(model Model, message any, category string) error
func (*LoggerImpl) WithContext ¶
func (l *LoggerImpl) WithContext(ctx context.Context) Logger
type PageStats ¶
type PageStats struct {
Path string `json:"path"`
Visits int64 `json:"visits"`
Percentage float64 `json:"percentage"`
}
Statistics for a single page
type PaginationStrategy ¶
type PaginationStrategy int
const ( PaginationStatus_None PaginationStrategy = iota PaginationStatus_Cursor PaginationStatus_Offset )
type Query ¶ added in v1.2.4
type Query struct {
Options *QueryOptions
}
func (*Query) MessageContaints ¶ added in v1.2.4
func (*Query) WithCategory ¶ added in v1.2.4
func (*Query) WithCursorPagination ¶ added in v1.2.4
func (*Query) WithIDGreaterThan ¶ added in v1.2.4
func (*Query) WithOffsetPagination ¶ added in v1.2.4
func (*Query) WithSeverity ¶ added in v1.2.4
type QueryOptions ¶
type WebPanel ¶
type WebPanel interface {
Common
LoginUser(username, password string) (models.User, error)
CreateUser(username, displayName, password string, isAdmin bool) (models.User, error)
GetUser(id uint) (models.User, error)
GetAllUsers() ([]models.User, error)
UpdateUser(user models.User) error
CreateSession(user models.User, device string) (string, error)
DeleteSession(token string) error
GetSession(token string) (*models.Session, error)
GetActiveSessions(userID uint) ([]models.Session, error)
GetDefaultLanguage() Language
Auth(r *http.Request) bool
}
type WebPanelConfig ¶ added in v1.2.4
type WebPanelConfigOpt ¶ added in v1.2.4
type WebPanelConfigOpt func(*WebPanelConfig)
func WithSessionDuration ¶ added in v1.2.4
func WithSessionDuration(duration time.Duration) WebPanelConfigOpt
type WebPanelImpl ¶
type WebPanelImpl struct {
// contains filtered or unexported fields
}
func (*WebPanelImpl) CreateSession ¶
func (*WebPanelImpl) CreateUser ¶
func (*WebPanelImpl) DeleteSession ¶
func (w *WebPanelImpl) DeleteSession(token string) error
func (*WebPanelImpl) GetActiveSessions ¶
func (w *WebPanelImpl) GetActiveSessions(userID uint) ([]models.Session, error)
func (*WebPanelImpl) GetAllUsers ¶
func (w *WebPanelImpl) GetAllUsers() ([]models.User, error)
func (*WebPanelImpl) GetApp ¶
func (w *WebPanelImpl) GetApp() App
func (*WebPanelImpl) GetDefaultLanguage ¶
func (w *WebPanelImpl) GetDefaultLanguage() Language
func (*WebPanelImpl) GetSession ¶
func (w *WebPanelImpl) GetSession(token string) (*models.Session, error)
func (*WebPanelImpl) LoginUser ¶
func (w *WebPanelImpl) LoginUser(username, password string) (models.User, error)
func (*WebPanelImpl) UpdateUser ¶
func (w *WebPanelImpl) UpdateUser(user models.User) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
actions
command
|
|
|
analytics
command
|
|
|
featureflags
command
|
|
|
gormlogger
command
|
|
|
logger
command
|
|
|
main
command
|
|
|
minimal
command
|
|
|
proxy
command
|
|
|
internal
|
|
Click to show internal directories.
Click to hide internal directories.