mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 18:35:51 +02:00
feat: read nginx access logs and error logs
This commit is contained in:
parent
6e3004b0bc
commit
ea3f1cd25e
3 changed files with 44 additions and 11 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
|
||||
type controlStruct struct {
|
||||
Fetch string `json:"fetch"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
func tailNginxLog(ws *websocket.Conn, controlChan chan controlStruct, errChan chan error) {
|
||||
|
@ -33,10 +34,15 @@ func tailNginxLog(ws *websocket.Conn, controlChan chan controlStruct, errChan ch
|
|||
seek.Whence = io.SeekEnd
|
||||
}
|
||||
|
||||
logPath := settings.NginxLogSettings.AccessLogPath
|
||||
|
||||
if control.Type == "error" {
|
||||
logPath = settings.NginxLogSettings.ErrorLogPath
|
||||
}
|
||||
|
||||
// Create a tail
|
||||
t, err := tail.TailFile(
|
||||
settings.NginxLogSettings.AccessLogPath, tail.Config{Follow: true,
|
||||
ReOpen: true, Location: &seek})
|
||||
t, err := tail.TailFile(logPath, tail.Config{Follow: true,
|
||||
ReOpen: true, Location: &seek})
|
||||
|
||||
if err != nil {
|
||||
errChan <- errors.Wrap(err, "error NginxAccessLog Tail")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue