api log saved to disk and shown in console

pull/2/head
Nilo Roberto C Paim 2022-08-21 18:10:37 -03:00
parent a3240b1da1
commit 989c56bee0
2 changed files with 14 additions and 2 deletions

5
.gitignore vendored
View File

@ -3,4 +3,7 @@
api
api.exe
pcast.db
pcast.db
api-homolog.log
.gitignore
api.log

11
main.go
View File

@ -4,6 +4,7 @@ import (
"api/database"
"api/globals"
"api/routes"
"io"
"log"
"os"
@ -13,8 +14,16 @@ import (
)
func main() {
logFile, err := os.OpenFile("api.log", os.O_CREATE | os.O_APPEND | os.O_RDWR, 0666)
if err != nil {
panic(err)
}
mw := io.MultiWriter(os.Stdout, logFile)
log.SetOutput(mw)
log.Println("Starting API", globals.API_VERSION)
log.Println("OS:", os.Getenv("OS"))
log.Println("OS:", os.Getenv("OS"))
app := fiber.New(fiber.Config{
StrictRouting: false,