/** * @Author: zou.yingbin * @Create : 2021/10/15 16:28 * @Modify : 2021/10/15 16:28 */ package other import ( "fmt" "github.com/gin-gonic/gin" "html/template" "io/ioutil" "mtp2_if/config" "net/http" "strings" ) var ( VERSION string GITHASH string ) // LogList 列出日志文件 func LogList(c *gin.Context) { host := c.Request.Host if !strings.Contains(host, "http://") { host = "http://" + host } const templateText = `
===========================
version : {{.version}}------------------------
{{.data}}------------------------
` sFile := make([]string, 0) path := config.SerCfg.LogCfg.LogPath db := fmt.Sprintf("%s/***@%s:%s/%s", config.SerCfg.DbCfg.DbUser, config.SerCfg.DbCfg.DbAddress, config.SerCfg.DbCfg.DbPort, config.SerCfg.DbCfg.DbName) mysql := fmt.Sprintf("%s/***@%s:%v/%s", config.SerCfg.MySQLCfg.Username, config.SerCfg.MySQLCfg.Host, config.SerCfg.MySQLCfg.Port, config.SerCfg.MySQLCfg.DBName) redis := fmt.Sprintf("%s:%v", config.SerCfg.RedisCfg.Address, config.SerCfg.RedisCfg.Port) if d, err := ioutil.ReadDir(path); err == nil { for _, v := range d { if !v.IsDir() { lk := fmt.Sprintf(`%v size:%.2f k`, host, v.Name(), v.Name(), float64(v.Size())/1024.0) lk2 := fmt.Sprintf(`查看`, host, v.Name()) lk = lk + " " + lk2 sFile = append(sFile, lk) } } str := strings.Join(sFile, "\n