镜像自地址
https://github.com/tuna/tunasync.git
已同步 2025-12-07 23:16:47 +00:00
style: better logging
这个提交包含在:
@@ -12,7 +12,11 @@ func InitLogger(verbose, debug, withSystemd bool) {
|
||||
if withSystemd {
|
||||
fmtString = "[%{level:.6s}] %{message}"
|
||||
} else {
|
||||
fmtString = "%{color}[%{time:06-01-02 15:04:05}][%{level:.6s}][%{shortfile}]%{color:reset} %{message}"
|
||||
if debug {
|
||||
fmtString = "%{color}[%{time:06-01-02 15:04:05}][%{level:.6s}][%{shortfile}]%{color:reset} %{message}"
|
||||
} else {
|
||||
fmtString = "%{color}[%{time:06-01-02 15:04:05}][%{level:.6s}]%{color:reset} %{message}"
|
||||
}
|
||||
}
|
||||
format := logging.MustStringFormatter(fmtString)
|
||||
logging.SetFormatter(format)
|
||||
|
||||
@@ -18,24 +18,30 @@ const (
|
||||
Disabled
|
||||
)
|
||||
|
||||
func (s SyncStatus) MarshalJSON() ([]byte, error) {
|
||||
var strStatus string
|
||||
func (s SyncStatus) String() string {
|
||||
switch s {
|
||||
case None:
|
||||
strStatus = "none"
|
||||
return "none"
|
||||
case Failed:
|
||||
strStatus = "failed"
|
||||
return "failed"
|
||||
case Success:
|
||||
strStatus = "success"
|
||||
return "success"
|
||||
case Syncing:
|
||||
strStatus = "syncing"
|
||||
return "syncing"
|
||||
case PreSyncing:
|
||||
strStatus = "pre-syncing"
|
||||
return "pre-syncing"
|
||||
case Paused:
|
||||
strStatus = "paused"
|
||||
return "paused"
|
||||
case Disabled:
|
||||
strStatus = "disabled"
|
||||
return "disabled"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (s SyncStatus) MarshalJSON() ([]byte, error) {
|
||||
strStatus := s.String()
|
||||
if strStatus == "" {
|
||||
return []byte{}, errors.New("Invalid status value")
|
||||
}
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户