-
Notifications
You must be signed in to change notification settings - Fork 34
/
logs.go
31 lines (27 loc) · 680 Bytes
/
logs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"fmt"
"io"
"os"
"mydocker/container"
log "github.com/sirupsen/logrus"
)
func logContainer(containerId string) {
logFileLocation := fmt.Sprintf(container.InfoLocFormat, containerId) + container.GetLogfile(containerId)
file, err := os.Open(logFileLocation)
defer file.Close()
if err != nil {
log.Errorf("Log container open file %s error %v", logFileLocation, err)
return
}
content, err := io.ReadAll(file)
if err != nil {
log.Errorf("Log container read file %s error %v", logFileLocation, err)
return
}
_, err = fmt.Fprint(os.Stdout, string(content))
if err != nil {
log.Errorf("Log container Fprint error %v", err)
return
}
}