Skip to content

Commit

Permalink
add access log file configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
negrel committed Jan 9, 2024
1 parent 95d39cd commit 272a75c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ it's not until recently that I decided to open source it.
There will be a lot of changes in the following weeks, be sure to watch and star
the repository to get informed of the progress.

## Configuration

Configuration of the go server is done through environment variables:

| Variable name | Default value | Description |
|:-------------:|:-------------:| :---------: |
| `PRISME_DEBUG`| `false` | Sets log level to debug. |
| `PRISME_TRUST_PROXY`| `false` | Whether `X-Forwarded-For`, `X-Request-Id` and other proxy related headers should be trusted. |
| `PRISME_ACCESS_LOG`| `/dev/stdout` | Path to access log file. |
| `PRISME_POSTGRES_URL`| **required** | Postgres connection string. |

## Contributing

If you want to contribute to `prismeanalytics` to add a feature or improve the
Expand Down
3 changes: 3 additions & 0 deletions internal/config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ type Server struct {
Debug bool
// Trust proxy headers.
TrustProxy bool
// Access log file path.
AccessLog string
}

func ServerFromEnv() Server {
return Server{
Debug: getEnvOrDefault("PRISME_DEBUG", "false") != "false",
TrustProxy: getEnvOrDefault("PRISME_TRUST_PROXY", "false") != "false",
AccessLog: getEnvOrDefault("PRISME_ACCESS_LOG", "/dev/stdout"),
}
}

0 comments on commit 272a75c

Please sign in to comment.