2015-02-26 17:29:42 +00:00
|
|
|
package DeviceDatabase
|
|
|
|
|
|
|
|
import (
|
|
|
|
"gopkg.in/mgo.v2/bson"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ReadCustom(timeRange, logLevel, logCategory, logImpact, logSeverity, logMessageName, logSender, logPage string) (events []LogDBEntry) {
|
|
|
|
|
|
|
|
//
|
2015-06-17 15:44:52 +00:00
|
|
|
// TODO => Is currently a stub
|
2015-02-26 17:29:42 +00:00
|
|
|
//
|
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// Define the query:
|
2015-02-26 17:29:42 +00:00
|
|
|
query := logDBCollection.Find(bson.D{}).Sort(`-TimeUTC`).Limit(26)
|
|
|
|
count := 26
|
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// Execute the query and count the results:
|
2015-02-26 17:29:42 +00:00
|
|
|
if n, err := query.Count(); err == nil {
|
|
|
|
count = n
|
|
|
|
}
|
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// The iterator for the results:
|
2015-02-26 17:29:42 +00:00
|
|
|
iter := query.Iter()
|
|
|
|
entry := LogDBEntry{}
|
|
|
|
pos := 0
|
2015-06-17 15:44:52 +00:00
|
|
|
|
|
|
|
// Reserve the memory for the results:
|
2015-02-26 17:29:42 +00:00
|
|
|
events = make([]LogDBEntry, count)
|
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// Loop over all entries and store it:
|
2015-02-26 17:29:42 +00:00
|
|
|
for iter.Next(&entry) {
|
|
|
|
events[pos] = entry
|
|
|
|
pos++
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|