Skip to content
Snippets Groups Projects
Commit 6e7dfa0d authored by Niall Sheridan's avatar Niall Sheridan
Browse files

Configurable logfile location

parent e9d53ad6
Branches
Tags
No related merge requests found
...@@ -81,6 +81,7 @@ Configuration is divided into different sections: `server`, `auth`, `ssh`, and ` ...@@ -81,6 +81,7 @@ Configuration is divided into different sections: `server`, `auth`, `ssh`, and `
- `tls_cert` : string. Path to the TLS cert. - `tls_cert` : string. Path to the TLS cert.
- `port` : int. Port to listen on. - `port` : int. Port to listen on.
- `cookie_secret`: string. Authentication key for the session cookie. - `cookie_secret`: string. Authentication key for the session cookie.
- `http_logfile`: string. Path to the HTTP request log. Logs are written in the [Common Log Format](https://en.wikipedia.org/wiki/Common_Log_Format). If not set logs are written to stderr.
### auth ### auth
- `provider` : string. Name of the oauth provider. At present the only valid value is "google". - `provider` : string. Name of the oauth provider. At present the only valid value is "google".
... ...
......
...@@ -256,7 +256,14 @@ func main() { ...@@ -256,7 +256,14 @@ func main() {
r.Handle("/auth/login", appHandler{ctx, loginHandler}) r.Handle("/auth/login", appHandler{ctx, loginHandler})
r.Handle("/auth/callback", appHandler{ctx, callbackHandler}) r.Handle("/auth/callback", appHandler{ctx, callbackHandler})
r.Handle("/sign", appHandler{ctx, signHandler}) r.Handle("/sign", appHandler{ctx, signHandler})
h := handlers.LoggingHandler(os.Stdout, r) logfile := os.Stderr
if config.Server.HTTPLogFile != "" {
logfile, err = os.OpenFile(config.Server.HTTPLogFile, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0660)
if err != nil {
log.Fatal(err)
}
}
h := handlers.LoggingHandler(logfile, r)
fmt.Println("Starting server...") fmt.Println("Starting server...")
l := fmt.Sprintf(":%d", config.Server.Port) l := fmt.Sprintf(":%d", config.Server.Port)
... ...
......
...@@ -5,6 +5,7 @@ server { ...@@ -5,6 +5,7 @@ server {
tls_cert = "server.crt" # Path to TLS certificate tls_cert = "server.crt" # Path to TLS certificate
port = 443 # Port to listen on port = 443 # Port to listen on
cookie_secret = "supersecret" # Authentication key for the client cookie cookie_secret = "supersecret" # Authentication key for the client cookie
http_logfile = "http.log" # Logfile for HTTP requests
} }
# Oauth2 configuration # Oauth2 configuration
... ...
......
...@@ -10,10 +10,10 @@ import ( ...@@ -10,10 +10,10 @@ import (
// Config holds the server configuration. // Config holds the server configuration.
type Config struct { type Config struct {
Server `mapstructure:"server"` Server Server `mapstructure:"server"`
Auth `mapstructure:"auth"` Auth Auth `mapstructure:"auth"`
SSH `mapstructure:"ssh"` SSH SSH `mapstructure:"ssh"`
AWS `mapstructure:"aws"` AWS AWS `mapstructure:"aws"`
} }
// unmarshalled holds the raw config. // unmarshalled holds the raw config.
...@@ -31,6 +31,7 @@ type Server struct { ...@@ -31,6 +31,7 @@ type Server struct {
TLSCert string `mapstructure:"tls_cert"` TLSCert string `mapstructure:"tls_cert"`
Port int `mapstructure:"port"` Port int `mapstructure:"port"`
CookieSecret string `mapstructure:"cookie_secret"` CookieSecret string `mapstructure:"cookie_secret"`
HTTPLogFile string `mapstructure:"http_logfile"`
} }
// Auth holds the configuration specific to the OAuth provider. // Auth holds the configuration specific to the OAuth provider.
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment