2020-04-29 17:38:04 +02:00
|
|
|
// Copyright (C) 2020 Opsmate, Inc.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
// Public License, v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
//
|
|
|
|
// This software is distributed WITHOUT A WARRANTY OF ANY KIND.
|
|
|
|
// See the Mozilla Public License for details.
|
|
|
|
|
|
|
|
package loglist
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2024-11-25 14:09:57 +01:00
|
|
|
// Return all tiled and non-tiled logs from all operators
|
2020-04-29 17:38:04 +02:00
|
|
|
func (list *List) AllLogs() []*Log {
|
|
|
|
logs := []*Log{}
|
|
|
|
for operator := range list.Operators {
|
|
|
|
for log := range list.Operators[operator].Logs {
|
|
|
|
logs = append(logs, &list.Operators[operator].Logs[log])
|
|
|
|
}
|
2024-11-25 14:09:57 +01:00
|
|
|
for log := range list.Operators[operator].TiledLogs {
|
|
|
|
logs = append(logs, &list.Operators[operator].TiledLogs[log])
|
|
|
|
}
|
2020-04-29 17:38:04 +02:00
|
|
|
}
|
|
|
|
return logs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (log *Log) LogIDString() string {
|
2021-04-30 23:04:16 +02:00
|
|
|
return log.LogID.Base64String()
|
2020-04-29 17:38:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (log *Log) AcceptsExpiration(expiration time.Time) bool {
|
|
|
|
return log.TemporalInterval == nil || withinInterval(expiration, log.TemporalInterval.StartInclusive, log.TemporalInterval.EndExclusive)
|
|
|
|
}
|
|
|
|
|
|
|
|
func withinInterval(expiration, startInclusive, endExclusive time.Time) bool {
|
|
|
|
return !expiration.Before(startInclusive) && expiration.Before(endExclusive)
|
|
|
|
}
|