fix: полный production-фикс fix40 (layout, sidebar, journald, логирование)
This commit is contained in:
+13
-20
@@ -7,6 +7,7 @@ import (
|
||||
"hy2xs-admin/model/constant"
|
||||
"hy2xs-admin/model/dto"
|
||||
"hy2xs-admin/model/vo"
|
||||
"hy2xs-admin/service"
|
||||
"hy2xs-admin/util"
|
||||
"time"
|
||||
)
|
||||
@@ -55,34 +56,17 @@ func LogHysteria2(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
exists := util.Exists(constant.Hysteria2LogPath)
|
||||
logHysteria2Vos := make([]vo.LogHysteria2Vo, 0)
|
||||
if !exists {
|
||||
vo.Success(logHysteria2Vos, c)
|
||||
return
|
||||
}
|
||||
numLine := 0
|
||||
if logSystemDto.NumLine != nil && *logSystemDto.NumLine > 0 {
|
||||
numLine = *logSystemDto.NumLine
|
||||
}
|
||||
logLines, total, err := util.ReadLinesFromBottom(constant.Hysteria2LogPath, numLine)
|
||||
logHysteria2Vos, total, err := service.ReadHysteriaJournalLogs(numLine)
|
||||
if err != nil {
|
||||
vo.Fail("Unable to read log file", c)
|
||||
vo.Fail("Unable to read hysteria journal logs", c)
|
||||
return
|
||||
}
|
||||
|
||||
for _, line := range logLines {
|
||||
if line == "" {
|
||||
continue
|
||||
}
|
||||
logHysteria2Vo := vo.LogHysteria2Vo{}
|
||||
err := json.Unmarshal([]byte(line), &logHysteria2Vo)
|
||||
if err != nil {
|
||||
vo.Fail("Unable to unmarshal log data", c)
|
||||
continue
|
||||
}
|
||||
logHysteria2Vos = append(logHysteria2Vos, logHysteria2Vo)
|
||||
}
|
||||
vo.Success(vo.LogSystemPage[vo.LogHysteria2Vo]{
|
||||
LogSystemVos: logHysteria2Vos,
|
||||
Total: int64(total),
|
||||
@@ -102,7 +86,16 @@ func ExportLog(c *gin.Context) {
|
||||
filePath = constant.SystemLogPath
|
||||
} else if *logExportDto.Option == 1 {
|
||||
fileName = fmt.Sprintf("hysteria2-%s.log", time.Now().Format("20060102150405"))
|
||||
filePath = constant.Hysteria2LogPath
|
||||
output, exportErr := service.ExportHysteriaJournalLogs(5000)
|
||||
if exportErr != nil {
|
||||
vo.Fail("failed to export hysteria journal logs", c)
|
||||
return
|
||||
}
|
||||
c.Header("Content-Type", "text/plain; charset=utf-8")
|
||||
c.Header("Content-Transfer-Encoding", "binary")
|
||||
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", fileName))
|
||||
c.Data(200, "text/plain; charset=utf-8", []byte(output))
|
||||
return
|
||||
}
|
||||
|
||||
if !util.Exists(filePath) {
|
||||
|
||||
Reference in New Issue
Block a user