From 34fc00d2a314ab0ab6fda7de2bd2695a5a48467f Mon Sep 17 00:00:00 2001 From: yoneyan Date: Wed, 17 Mar 2021 08:46:44 +0900 Subject: [PATCH] =?UTF-8?q?[add]=20log=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=81=AE=E3=83=91=E3=82=B9=E3=82=92=E8=A8=AD=E5=AE=9A=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configs/config.json | 5 ++++- pkg/api/core/tool/config/config.go | 27 ++++++++------------------- pkg/api/core/tool/log/log.go | 3 ++- 3 files changed, 14 insertions(+), 21 deletions(-) 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) }