mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 08:27:08 +08:00

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.
69 lines
953 B
Go
69 lines
953 B
Go
package value
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/lestrrat-go/strftime"
|
|
)
|
|
|
|
// time
|
|
|
|
type Time time.Time
|
|
|
|
func NewTime(p *time.Time, val time.Time) *Time {
|
|
*p = val
|
|
|
|
return (*Time)(p)
|
|
}
|
|
|
|
func (u *Time) Set(val string) error {
|
|
v, err := time.Parse(time.RFC3339, val)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
*u = Time(v)
|
|
return nil
|
|
}
|
|
|
|
func (u *Time) String() string {
|
|
v := time.Time(*u)
|
|
return v.Format(time.RFC3339)
|
|
}
|
|
|
|
func (u *Time) Validate() error {
|
|
return nil
|
|
}
|
|
|
|
func (u *Time) IsEmpty() bool {
|
|
v := time.Time(*u)
|
|
return v.IsZero()
|
|
}
|
|
|
|
// strftime
|
|
|
|
type Strftime string
|
|
|
|
func NewStrftime(p *string, val string) *Strftime {
|
|
*p = val
|
|
|
|
return (*Strftime)(p)
|
|
}
|
|
|
|
func (s *Strftime) Set(val string) error {
|
|
*s = Strftime(val)
|
|
return nil
|
|
}
|
|
|
|
func (s *Strftime) String() string {
|
|
return string(*s)
|
|
}
|
|
|
|
func (s *Strftime) Validate() error {
|
|
_, err := strftime.New(string(*s))
|
|
return err
|
|
}
|
|
|
|
func (s *Strftime) IsEmpty() bool {
|
|
return len(string(*s)) == 0
|
|
}
|