mirror of https://github.com/gophish/gophish
Moving logging configuration into its own section of the config
parent
bef52d36f1
commit
10aa98b760
|
@ -15,5 +15,7 @@
|
||||||
"db_path": "gophish.db",
|
"db_path": "gophish.db",
|
||||||
"migrations_prefix": "db/db_",
|
"migrations_prefix": "db/db_",
|
||||||
"contact_address": "",
|
"contact_address": "",
|
||||||
"log_file": ""
|
"logging": {
|
||||||
|
"filename": ""
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -21,6 +21,11 @@ type PhishServer struct {
|
||||||
KeyPath string `json:"key_path"`
|
KeyPath string `json:"key_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoggingConfig represents configuration details for Gophish logging.
|
||||||
|
type LoggingConfig struct {
|
||||||
|
Filename string `json:"filename"`
|
||||||
|
}
|
||||||
|
|
||||||
// Config represents the configuration information.
|
// Config represents the configuration information.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
AdminConf AdminServer `json:"admin_server"`
|
AdminConf AdminServer `json:"admin_server"`
|
||||||
|
@ -30,7 +35,7 @@ type Config struct {
|
||||||
MigrationsPath string `json:"migrations_prefix"`
|
MigrationsPath string `json:"migrations_prefix"`
|
||||||
TestFlag bool `json:"test_flag"`
|
TestFlag bool `json:"test_flag"`
|
||||||
ContactAddress string `json:"contact_address"`
|
ContactAddress string `json:"contact_address"`
|
||||||
LogFile string `json:"log_file"`
|
Logging LoggingConfig `json:"logging"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conf contains the initialized configuration struct
|
// Conf contains the initialized configuration struct
|
||||||
|
|
|
@ -21,7 +21,7 @@ func init() {
|
||||||
func Setup() error {
|
func Setup() error {
|
||||||
Logger.SetLevel(logrus.InfoLevel)
|
Logger.SetLevel(logrus.InfoLevel)
|
||||||
// Set up logging to a file if specified in the config
|
// Set up logging to a file if specified in the config
|
||||||
logFile := config.Conf.LogFile
|
logFile := config.Conf.Logging.Filename
|
||||||
if logFile != "" {
|
if logFile != "" {
|
||||||
f, err := os.OpenFile(logFile, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
|
f, err := os.OpenFile(logFile, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue