-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加日志文件下载功能,可查看每日日志文件,零点切割日志,重新写入新的日志文件
- Loading branch information
1 parent
26c06b7
commit c7261fc
Showing
6 changed files
with
101 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,6 @@ type GoBat interface { | |
Read() | ||
// 监听全局错误 | ||
Err() | ||
//日志文件 | ||
Log() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package api | ||
|
||
import ( | ||
"Go-Bat/config" | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"log" | ||
"net/http" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
type File struct { | ||
UserId int64 `json:"user_id"` | ||
File string `json:"file"` | ||
Name string `json:"name"` | ||
} | ||
|
||
func (f *File) Upload() { | ||
f.UserId = config.K.Bat.QQ | ||
f.Name = time.Now().Format(time.DateOnly) + ".log" | ||
f.File = "/root/GoBatRoot/log/" + time.Now().Format(time.DateOnly) + ".log" | ||
marshal, err := json.Marshal(f) | ||
if err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
resp, err := http.Post("http://127.0.0.1:"+strconv.Itoa(config.K.Server.Port)+"/upload_private_file", "application/json", bytes.NewReader(marshal)) | ||
if err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
defer resp.Body.Close() | ||
all, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
return | ||
} | ||
fmt.Println(string(all)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters