Skip to content

Commit

Permalink
[add] logファイルのパスを設定できるようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
yoneyan committed Mar 16, 2021
1 parent 71e31fb commit 34fc00d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
5 changes: 4 additions & 1 deletion configs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@
"channel": "xxxx",
"name": "xxxxx"
}
]
],
"log": {
"path": ""
}
}
27 changes: 8 additions & 19 deletions pkg/api/core/tool/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/core/tool/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 34fc00d

Please sign in to comment.