diff --git a/config.json b/config.json index 5b81b68c..9abaf1d1 100644 --- a/config.json +++ b/config.json @@ -15,5 +15,7 @@ "db_path": "gophish.db", "migrations_prefix": "db/db_", "contact_address": "", - "log_file": "" + "logging": { + "filename": "" + } } \ No newline at end of file diff --git a/config/config.go b/config/config.go index efac36c1..c1589837 100644 --- a/config/config.go +++ b/config/config.go @@ -21,16 +21,21 @@ type PhishServer struct { KeyPath string `json:"key_path"` } +// LoggingConfig represents configuration details for Gophish logging. +type LoggingConfig struct { + Filename string `json:"filename"` +} + // Config represents the configuration information. type Config struct { - AdminConf AdminServer `json:"admin_server"` - PhishConf PhishServer `json:"phish_server"` - DBName string `json:"db_name"` - DBPath string `json:"db_path"` - MigrationsPath string `json:"migrations_prefix"` - TestFlag bool `json:"test_flag"` - ContactAddress string `json:"contact_address"` - LogFile string `json:"log_file"` + AdminConf AdminServer `json:"admin_server"` + PhishConf PhishServer `json:"phish_server"` + DBName string `json:"db_name"` + DBPath string `json:"db_path"` + MigrationsPath string `json:"migrations_prefix"` + TestFlag bool `json:"test_flag"` + ContactAddress string `json:"contact_address"` + Logging LoggingConfig `json:"logging"` } // Conf contains the initialized configuration struct diff --git a/logger/logger.go b/logger/logger.go index 4fe9c262..feb7a167 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -21,7 +21,7 @@ func init() { func Setup() error { Logger.SetLevel(logrus.InfoLevel) // Set up logging to a file if specified in the config - logFile := config.Conf.LogFile + logFile := config.Conf.Logging.Filename if logFile != "" { f, err := os.OpenFile(logFile, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) if err != nil {