added backend logs

This commit is contained in:
2026-01-18 10:34:31 +00:00
parent 282a286958
commit e384223f13
3 changed files with 13 additions and 3 deletions

1
.gitignore vendored
View File

@@ -4,7 +4,6 @@ backend/token/
# Logs
logs
nginx-log
*.log
npm-debug.log*
yarn-debug.log*

View File

@@ -2,6 +2,7 @@ package main
import (
"fmt"
"io"
"log"
"os"
"time"
@@ -13,6 +14,16 @@ import (
)
func main() {
r := gin.Default()
logsDir := "/backend/logs"
logFile, err := os.OpenFile(logsDir+"/go.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
panic(err)
}
gin.DefaultWriter = io.MultiWriter(os.Stdout, logFile)
r.Use(gin.Logger(), gin.Recovery())
dbUser := os.Getenv("POSTGRES_USER")
dbPassword := os.Getenv("POSTGRES_PASSWORD")
dbName := os.Getenv("POSTGRES_DB")
@@ -45,7 +56,6 @@ func main() {
store := handlers.Store{DB: db, SpotifyAuth: spotifyAuth, SpotifyClient: client, Auth: auth, Notes: notes}
r := gin.Default()
protected := r.Group("/", store.AuthMiddlewear)
r.GET("/posts", store.GetPosts)

View File

@@ -24,7 +24,7 @@ services:
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
- ./nginx-log:/var/log/nginx
- ./logs:/var/log/nginx
certbot:
image: certbot/certbot
@@ -61,6 +61,7 @@ services:
volumes:
- ./backend/token/:/backend/token
- ${OBSIDIAN_DIR}:/backend/notes
- ./logs:/backend/logs
db:
image: postgres:16