chore: add logger.SysLogf function
This commit is contained in:
parent
f74577141c
commit
6ccf3f3cfc
@ -43,11 +43,19 @@ func SysLog(s string) {
|
|||||||
_, _ = fmt.Fprintf(gin.DefaultWriter, "[SYS] %v | %s \n", t.Format("2006/01/02 - 15:04:05"), s)
|
_, _ = fmt.Fprintf(gin.DefaultWriter, "[SYS] %v | %s \n", t.Format("2006/01/02 - 15:04:05"), s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SysLogf(format string, a ...any) {
|
||||||
|
SysLog(fmt.Sprintf(format, a...))
|
||||||
|
}
|
||||||
|
|
||||||
func SysError(s string) {
|
func SysError(s string) {
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
_, _ = fmt.Fprintf(gin.DefaultErrorWriter, "[SYS] %v | %s \n", t.Format("2006/01/02 - 15:04:05"), s)
|
_, _ = fmt.Fprintf(gin.DefaultErrorWriter, "[SYS] %v | %s \n", t.Format("2006/01/02 - 15:04:05"), s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SysErrorf(format string, a ...any) {
|
||||||
|
SysError(fmt.Sprintf(format, a...))
|
||||||
|
}
|
||||||
|
|
||||||
func Debug(ctx context.Context, msg string) {
|
func Debug(ctx context.Context, msg string) {
|
||||||
if config.DebugEnabled {
|
if config.DebugEnabled {
|
||||||
logHelper(ctx, loggerDEBUG, msg)
|
logHelper(ctx, loggerDEBUG, msg)
|
||||||
|
2
main.go
2
main.go
@ -24,7 +24,7 @@ var buildFS embed.FS
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logger.SetupLogger()
|
logger.SetupLogger()
|
||||||
logger.SysLog(fmt.Sprintf("One API %s started", common.Version))
|
logger.SysLogf("One API %s started", common.Version)
|
||||||
if os.Getenv("GIN_MODE") != "debug" {
|
if os.Getenv("GIN_MODE") != "debug" {
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user