diff --git a/configs/config.json b/configs/config.json index 50979a37..9de5c16e 100644 --- a/configs/config.json +++ b/configs/config.json @@ -41,5 +41,8 @@ "channel": "xxxx", "name": "xxxxx" } - ] + ], + "log": { + "path": "" + } } \ No newline at end of file diff --git a/pkg/api/core/tool/config/config.go b/pkg/api/core/tool/config/config.go index 6d0f8abe..e0ab97aa 100644 --- a/pkg/api/core/tool/config/config.go +++ b/pkg/api/core/tool/config/config.go @@ -6,13 +6,12 @@ import ( ) type Config struct { - Controller Controller `json:"controller"` - DB DB `json:"db"` - Mail Mail `json:"mail"` - Radius Radius `json:"radius"` - Slack []Slack `json:"slack"` - Network []Network `json:"network"` - Connection []Connection `json:"connection"` + Controller Controller `json:"controller"` + DB DB `json:"db"` + Mail Mail `json:"mail"` + Radius Radius `json:"radius"` + Slack []Slack `json:"slack"` + Log Log `json:"log"` } type Controller struct { @@ -76,18 +75,8 @@ type Slack struct { Name string `json:"name"` } -type Network struct { - ID string `json:"id"` - Hidden bool `json:"hidden"` - Name string `json:"name"` - Comment string `json:"comment"` -} - -type Connection struct { - ID string `json:"id"` - Hidden bool `json:"hidden"` - Name string `json:"name"` - Comment string `json:"comment"` +type Log struct { + Path string `json:"path"` } var Conf Config diff --git a/pkg/api/core/tool/log/log.go b/pkg/api/core/tool/log/log.go index c2e5081f..6d82ba3e 100644 --- a/pkg/api/core/tool/log/log.go +++ b/pkg/api/core/tool/log/log.go @@ -2,13 +2,14 @@ package log import ( "fmt" + "github.com/homenoc/dsbd-backend/pkg/api/core/tool/config" "os" "time" ) //#2 Issue func WriteLog(data string) { - file, err := os.OpenFile("backend.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) + file, err := os.OpenFile(config.Conf.Log.Path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if err != nil { fmt.Println(err) }