mirror of
https://github.com/go-shiori/shiori.git
synced 2024-11-16 14:16:29 +08:00
43 lines
717 B
Go
43 lines
717 B
Go
package archiver
|
|
|
|
import "github.com/sirupsen/logrus"
|
|
|
|
type logType int
|
|
|
|
const (
|
|
infoLog logType = iota
|
|
errorLog
|
|
warningLog
|
|
)
|
|
|
|
// Log prints the log ended with newline.
|
|
func (arc *Archiver) Log(tp logType, msgs ...interface{}) {
|
|
if !arc.LogEnabled {
|
|
return
|
|
}
|
|
|
|
switch tp {
|
|
case errorLog:
|
|
logrus.Errorln(msgs...)
|
|
case warningLog:
|
|
logrus.Warnln(msgs...)
|
|
default:
|
|
logrus.Infoln(msgs...)
|
|
}
|
|
}
|
|
|
|
// Logf print log with specified format.
|
|
func (arc *Archiver) Logf(tp logType, format string, msgs ...interface{}) {
|
|
if !arc.LogEnabled {
|
|
return
|
|
}
|
|
|
|
switch tp {
|
|
case errorLog:
|
|
logrus.Errorf(format, msgs...)
|
|
case warningLog:
|
|
logrus.Warnf(format, msgs...)
|
|
default:
|
|
logrus.Infof(format, msgs...)
|
|
}
|
|
}
|