Skip to content

Commit

Permalink
Update - add log
Browse files Browse the repository at this point in the history
  • Loading branch information
nicojwzhang committed Jul 26, 2021
1 parent 7180827 commit 854273f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions job_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func GetJobLogById(id bson.ObjectId) (l *JobLog, err error) {
var selectForJobLogList = bson.M{"command": 0, "output": 0}

func GetJobLogList(query bson.M, page, size int, sort string) (list []*JobLog, total int, err error) {
log.Debugf("query:%+v, page:%d, size:%d, sort:%s", query, page, size, sort)
err = mgoDB.WithC(Coll_JobLog, func(c *mgo.Collection) error {
total, err = c.Find(query).Count()
if err != nil {
Expand All @@ -59,6 +60,7 @@ func GetJobLogList(query bson.M, page, size int, sort string) (list []*JobLog, t
}

func GetJobLatestLogList(query bson.M, page, size int, sort string) (list []*JobLatestLog, total int, err error) {
log.Debugf("query:%+v, page:%d, size:%d, sort:%s", query, page, size, sort)
err = mgoDB.WithC(Coll_JobLatestLog, func(c *mgo.Collection) error {
total, err = c.Find(query).Count()
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions web/log_cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

func RunLogCleaner(cleanPeriod, expiration time.Duration) (close chan struct{}) {
log.Debugf("cleanPeriod:%s, expiration:%s", cleanPeriod.String(), expiration.String())
t := time.NewTicker(cleanPeriod)
close = make(chan struct{})
go func() {
Expand All @@ -27,6 +28,7 @@ func RunLogCleaner(cleanPeriod, expiration time.Duration) (close chan struct{})
}

func cleanupLogs(expiration time.Duration) {
log.Debugf("expiration:%s", expiration.String())
err := cronsun.GetDb().WithC(cronsun.Coll_JobLog, func(c *mgo.Collection) error {
_, err := c.RemoveAll(bson.M{"$or": []bson.M{
bson.M{"$and": []bson.M{
Expand Down

0 comments on commit 854273f

Please sign in to comment.