mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-27 12:46:03 +01:00
39 lines
834 B
Go
39 lines
834 B
Go
package job
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/vmware/harbor/dao"
|
|
"github.com/vmware/harbor/utils/log"
|
|
)
|
|
|
|
const (
|
|
INFO = "info"
|
|
WARN = "warning"
|
|
ERR = "error"
|
|
)
|
|
|
|
type Logger struct {
|
|
ID int64
|
|
}
|
|
|
|
func (l *Logger) Infof(format string, v ...interface{}) {
|
|
err := dao.AddJobLog(l.ID, INFO, fmt.Sprintf(format, v...))
|
|
if err != nil {
|
|
log.Warningf("Failed to add job log, id: %d, error: %v", l.ID, err)
|
|
}
|
|
}
|
|
|
|
func (l *Logger) Warningf(format string, v ...interface{}) {
|
|
err := dao.AddJobLog(l.ID, WARN, fmt.Sprintf(format, v...))
|
|
if err != nil {
|
|
log.Warningf("Failed to add job log, id: %d, error: %v", l.ID, err)
|
|
}
|
|
}
|
|
|
|
func (l *Logger) Errorf(format string, v ...interface{}) {
|
|
err := dao.AddJobLog(l.ID, ERR, fmt.Sprintf(format, v...))
|
|
if err != nil {
|
|
log.Warningf("Failed to add job log, id: %d, error: %v", l.ID, err)
|
|
}
|
|
}
|