mirror of
https://github.com/datarhei/core.git
synced 2025-10-08 09:20:16 +08:00
Allow to log each finished session to filesystem
By providing CORE_SESSIONS_SESSION_LOG_PATH_PATTERN (e.g. "/log/%Y-%m-%d.log") all finished sessions will be logged to a file according to the provided strftime-pattern. The actual value is calculated from when the session closed. CORE_SESSIONS_PERSIST must be set. Default: not set. Set CORE_SESSIONS_SESSION_LOG_BUFFER_SEC to the number of seconds the log should be buffered in memory before persisted to disk. Default 15 seconds.
This commit is contained in:
@@ -339,7 +339,10 @@ func (a *api) start() error {
|
||||
|
||||
if cfg.Sessions.Enable {
|
||||
sessionConfig := session.Config{
|
||||
Logger: a.log.logger.core.WithComponent("Session"),
|
||||
PersistInterval: time.Duration(cfg.Sessions.PersistInterval) * time.Second,
|
||||
LogPattern: cfg.Sessions.SessionLogPathPattern,
|
||||
LogBufferDuration: time.Duration(cfg.Sessions.SessionLogBuffer) * time.Second,
|
||||
Logger: a.log.logger.core.WithComponent("Session"),
|
||||
}
|
||||
|
||||
if cfg.Sessions.Persist {
|
||||
@@ -371,7 +374,6 @@ func (a *api) start() error {
|
||||
MaxSessions: cfg.Sessions.MaxSessions,
|
||||
InactiveTimeout: 5 * time.Second,
|
||||
SessionTimeout: time.Duration(cfg.Sessions.SessionTimeout) * time.Second,
|
||||
PersistInterval: time.Duration(cfg.Sessions.PersistInterval) * time.Second,
|
||||
Limiter: iplimiter,
|
||||
}
|
||||
|
||||
@@ -1823,6 +1825,7 @@ func (a *api) stop() {
|
||||
// Stop the session tracker
|
||||
if a.sessions != nil {
|
||||
a.sessions.UnregisterAll()
|
||||
a.sessions.Close()
|
||||
a.sessions = nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user