Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a4c6acf56d | |||
| ce98b833ae | |||
| 4aa5110726 |
@@ -3,28 +3,36 @@ package print
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var logger *log.Logger
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
logger = log.New(os.Stdout, "", 0) // 创建一个新的 Logger 实例,不带任何标志
|
||||||
|
logger.SetFlags(log.Ldate | log.Ltime)
|
||||||
|
}
|
||||||
|
|
||||||
// record INFO message. Color White
|
// record INFO message. Color White
|
||||||
func Info(format string, a ...interface{}) {
|
func Info(format string, a ...interface{}) {
|
||||||
message := fmt.Sprintf("\033[37m[Info] "+format+"\033[0m\n", a...)
|
message := fmt.Sprintf("\033[37m[Info] "+format+"\033[0m\n", a...)
|
||||||
log.Print(message)
|
logger.Print(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// record Warn message. Color Orange
|
// record Warn message. Color Orange
|
||||||
func Warn(format string, a ...interface{}) {
|
func Warn(format string, a ...interface{}) {
|
||||||
message := fmt.Sprintf("\033[33m[Warn] "+format+"\033[0m\n", a...)
|
message := fmt.Sprintf("\033[33m[Warn] "+format+"\033[0m\n", a...)
|
||||||
log.Print(message)
|
logger.Print(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// record Success message. Color Green
|
// record Success message. Color Green
|
||||||
func Success(format string, a ...interface{}) {
|
func Success(format string, a ...interface{}) {
|
||||||
message := fmt.Sprintf("\033[32m[Success] "+format+"\033[0m\n", a...)
|
message := fmt.Sprintf("\033[32m[Success] "+format+"\033[0m\n", a...)
|
||||||
log.Print(message)
|
logger.Print(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// record ERROR message. Color Red
|
// record ERROR message. Color Red
|
||||||
func Error(format string, a ...interface{}) {
|
func Error(format string, a ...interface{}) {
|
||||||
message := fmt.Sprintf("\033[31m[Error] "+format+"\033[0m\n", a...)
|
message := fmt.Sprintf("\033[31m[Error] "+format+"\033[0m\n", a...)
|
||||||
log.Print(message)
|
logger.Print(message)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ type (
|
|||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index;" json:"deleted_at"`
|
DeletedAt gorm.DeletedAt `gorm:"index;" json:"deleted_at"`
|
||||||
Status int8 `gorm:"default:0;index;" json:"status"` // 状态:默认为0,-1禁止,1为正常
|
Status int64 `gorm:"default:0;index;" json:"status"` // 状态:默认为0,-1禁止,1为正常
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard ID,Identity,Created,Updated,Deleted,Status definition.
|
// standard ID,Identity,Created,Updated,Deleted,Status definition.
|
||||||
@@ -66,6 +66,6 @@ type (
|
|||||||
|
|
||||||
// standard Status definition.
|
// standard Status definition.
|
||||||
Std_Status struct {
|
Std_Status struct {
|
||||||
Status int8 `gorm:"default:0;index;" json:"status"` // 状态:默认为0,-1禁止,1为正常
|
Status int64 `gorm:"default:0;index;" json:"status"` // 状态:默认为0,-1禁止,1为正常
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user