import cycle not allowed
This commit is contained in:
@@ -3,6 +3,7 @@ package logger
|
||||
import (
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/config"
|
||||
"cutego/pkg/logging"
|
||||
"fmt"
|
||||
"github.com/druidcaesa/gotool"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -16,18 +17,18 @@ import (
|
||||
|
||||
// LoggerToFile 日志记录到文件
|
||||
func LoggerToFile() gin.HandlerFunc {
|
||||
dirPath := common.GetDirPath("log")
|
||||
fileName := path.Join(dirPath, "application.log")
|
||||
dirPath := common.GetDirPath("logging")
|
||||
fileName := path.Join(dirPath, "application.logging")
|
||||
if !common.IsFileOrDirExist(dirPath) {
|
||||
err := common.CreateAllDir(dirPath)
|
||||
if err != nil {
|
||||
common.ErrorLog(err)
|
||||
logging.ErrorLog(err)
|
||||
}
|
||||
}
|
||||
if !gotool.FileUtils.Exists(fileName) {
|
||||
create, err := os.Create(fileName)
|
||||
if err != nil {
|
||||
common.ErrorLog(err)
|
||||
logging.ErrorLog(err)
|
||||
}
|
||||
defer create.Close()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/logging"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"runtime/debug"
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
func Recover(c *gin.Context) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
common.ErrorLog("panic: %v\n", r)
|
||||
logging.ErrorLog("panic: %v\n", r)
|
||||
debug.PrintStack()
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": http.StatusInternalServerError,
|
||||
|
||||
Reference in New Issue
Block a user