Skip to content

Commit

Permalink
fix log location
Browse files Browse the repository at this point in the history
Signed-off-by: Rajiv Harlalka <[email protected]>
  • Loading branch information
rajivharlalka committed Sep 9, 2024
1 parent 7345972 commit 0cdc9c1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion backend/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ GH_PRIVATE_ID= # Private token of the oauth app
JWT_SECRET= # JWT encryption secret
GH_ORG_NAME= # name of the org
GH_ORG_TEAM_SLUG= #URL friendly team Name
GH_ORG_ADMIN_TOKEN= #GH TOKEN OF AN ORG ADMIN
GH_ORG_ADMIN_TOKEN= #GH TOKEN OF AN ORG ADMIN
IQPS_LOG_LOCATION=./log/application.log
2 changes: 1 addition & 1 deletion backend/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- iqps-backend
metaploy-private-network:
volumes:
- ./logs:~/iqps/logs
- ./logs:/var/log/iqps/logs
- ./db:/db
- nginx-config-volume:/etc/nginx/sites-enabled
- odins-vault:/srv/static
Expand Down
8 changes: 7 additions & 1 deletion backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log/slog"
"net/http"
"os"

"github.com/joho/godotenv"
"github.com/metakgp/iqps/backend/pkg/config"
Expand All @@ -31,7 +32,12 @@ func main() {
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"},
AllowedOrigins: []string{"https://qp.metakgp.org", "http://localhost:3000", "http://localhost:5173"},
})
fmt.Print("Logs are in ~/iqps/logs/ \n")

logLocation := os.Getenv("IQPS_LOG_LOCATION")
if logLocation == "" {
logLocation = "/var/log/iqps/logs/application.log"
}
fmt.Print("Logs are in ", logLocation, "\n")
logger.Info("Main: Starting server on port 5000")
err := http.ListenAndServe(":5000", c.Handler(http.DefaultServeMux))
if errors.Is(err, http.ErrServerClosed) {
Expand Down
6 changes: 5 additions & 1 deletion backend/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ func Get() *Config {
}

log := logrus.New()
logLocation := os.Getenv("IQPS_LOG_LOCATION")
if logLocation == "" {
logLocation = "/var/log/iqps/logs/application.log"
}
log.SetOutput(&lumberjack.Logger{
Filename: "~/iqps/logs/application.log",
Filename: logLocation,
MaxSize: 10, // Max size in MB
})

Expand Down

0 comments on commit 0cdc9c1

Please sign in to comment.