Documentation ¶
Overview ¶
Package event provides a publish-subscribe event hub and a global logger.
Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.
This program is free software: you can redistribute it and/or modify it under Version 3 of the GNU Affero General Public License (the "AGPL"): <https://docs.photoprism.app/license/agpl> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. The AGPL is supplemented by our Trademark and Brand Guidelines, which describe how our Brand Assets may be used: <https://www.photoprism.app/trademark>
Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.
Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>
Index ¶
- Constants
- Variables
- func Audit(level logrus.Level, ev []string, args ...interface{})
- func AuditDebug(ev []string, args ...interface{})
- func AuditErr(ev []string, args ...interface{})
- func AuditInfo(ev []string, args ...interface{})
- func AuditWarn(ev []string, args ...interface{})
- func EntitiesArchived(channel string, entities interface{})
- func EntitiesCreated(channel string, entities interface{})
- func EntitiesDeleted(channel string, entities interface{})
- func EntitiesRestored(channel string, entities interface{})
- func EntitiesUpdated(channel string, entities interface{})
- func Error(msg string)
- func ErrorMsg(id i18n.Message, params ...interface{})
- func Format(ev []string, args ...interface{}) string
- func Info(msg string)
- func InfoMsg(id i18n.Message, params ...interface{})
- func LoginError(ip, realm, name, browser, error string)
- func LoginInfo(ip, realm, name, browser string)
- func Publish(event string, data Data)
- func PublishEntities(channel, ev string, entities interface{})
- func PublishUserEntities(channel, ev string, entities interface{}, userUid string)
- func Seconds(s int) time.Duration
- func Subscribe(topics ...string) hub.Subscription
- func Success(msg string)
- func SuccessMsg(id i18n.Message, params ...interface{})
- func TimePointer() *time.Time
- func TimeStamp() time.Time
- func Topic(topic string) (ch, ev string)
- func Unsubscribe(s hub.Subscription)
- func Warn(msg string)
- func WarnMsg(id i18n.Message, params ...interface{})
- func Yesterday() time.Time
- type Buffer
- type Data
- type Hook
- type Hub
- type LogWriter
- type Logger
- type Message
Constants ¶
const ( EntityUpdated = "updated" EntityCreated = "created" EntityDeleted = "deleted" EntityArchived = "archived" EntityRestored = "restored" )
const Day = time.Hour * 24
const TopicSep = "."
Variables ¶
var AuditMessageSep = " › "
var AuditPrefix = "audit: "
var TextFormatter = &logrus.TextFormatter{ DisableColors: false, FullTimestamp: true, }
TextFormatter for log messages.
Functions ¶
func AuditDebug ¶
func AuditDebug(ev []string, args ...interface{})
func EntitiesArchived ¶
func EntitiesArchived(channel string, entities interface{})
func EntitiesCreated ¶
func EntitiesCreated(channel string, entities interface{})
func EntitiesDeleted ¶
func EntitiesDeleted(channel string, entities interface{})
func EntitiesRestored ¶
func EntitiesRestored(channel string, entities interface{})
func EntitiesUpdated ¶
func EntitiesUpdated(channel string, entities interface{})
func LoginError ¶
func LoginError(ip, realm, name, browser, error string)
LoginError publishes a login error event.
func LoginInfo ¶
func LoginInfo(ip, realm, name, browser string)
LoginInfo publishes a successful login event.
func PublishEntities ¶
func PublishEntities(channel, ev string, entities interface{})
PublishEntities publishes updated entity data.
func PublishUserEntities ¶
PublishUserEntities publishes updated entity data for a user.
func Subscribe ¶
func Subscribe(topics ...string) hub.Subscription
Subscribe creates a topic subscription and returns i
func SuccessMsg ¶
func TimePointer ¶
TimePointer returns a pointer to the current timestamp.
func Unsubscribe ¶
func Unsubscribe(s hub.Subscription)
Unsubscribe deletes the subscription of a topic.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a goroutine safe buffer.
var LogBuffer Buffer
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook represents a log event hook.
type Logger ¶
type Logger interface { WithField(key string, value interface{}) *logrus.Entry WithFields(fields logrus.Fields) *logrus.Entry WithError(err error) *logrus.Entry WithContext(ctx context.Context) *logrus.Entry WithTime(t time.Time) *logrus.Entry Logf(level logrus.Level, format string, args ...interface{}) Tracef(format string, args ...interface{}) Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Printf(format string, args ...interface{}) Warnf(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Panicf(format string, args ...interface{}) Log(level logrus.Level, args ...interface{}) LogFn(level logrus.Level, fn logrus.LogFunction) Trace(args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Print(args ...interface{}) Warn(args ...interface{}) Warning(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) Panic(args ...interface{}) TraceFn(fn logrus.LogFunction) DebugFn(fn logrus.LogFunction) InfoFn(fn logrus.LogFunction) PrintFn(fn logrus.LogFunction) WarnFn(fn logrus.LogFunction) WarningFn(fn logrus.LogFunction) ErrorFn(fn logrus.LogFunction) FatalFn(fn logrus.LogFunction) PanicFn(fn logrus.LogFunction) Logln(level logrus.Level, args ...interface{}) Traceln(args ...interface{}) Debugln(args ...interface{}) Infoln(args ...interface{}) Println(args ...interface{}) Warnln(args ...interface{}) Warningln(args ...interface{}) Errorln(args ...interface{}) Fatalln(args ...interface{}) Panicln(args ...interface{}) Exit(code int) SetNoLock() SetLevel(level logrus.Level) GetLevel() logrus.Level AddHook(hook logrus.Hook) IsLevelEnabled(level logrus.Level) bool SetFormatter(formatter logrus.Formatter) SetOutput(output io.Writer) SetReportCaller(reportCaller bool) ReplaceHooks(hooks logrus.LevelHooks) logrus.LevelHooks SetBufferPool(pool logrus.BufferPool) }
Logger is a logrus compatible logger interface.
var AuditLog Logger
AuditLog optionally logs security events.
var Log Logger
Log is the global default logger.