Skip to content

Commit b9967c7

Browse files
committed
Move last state and logs to separate folder
1 parent c5ce172 commit b9967c7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@
1111

1212
# ignore binary produced by go build
1313
ssl-game-controller
14-
lastState.json
15-
state-history*
14+
logs

refBox.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import (
88
"time"
99
)
1010

11-
const lastStateFileName = "lastState.json"
11+
const logDir = "logs"
12+
const lastStateFileName = logDir + "/lastState.json"
1213
const configFileName = "config.yaml"
1314

1415
type RefBox struct {
@@ -36,6 +37,7 @@ func NewRefBox() (refBox *RefBox) {
3637

3738
func (r *RefBox) Run() (err error) {
3839

40+
os.MkdirAll(logDir, os.ModePerm)
3941
r.openStateFiles()
4042
r.readLastState()
4143
r.loadStages()
@@ -58,7 +60,7 @@ func (r *RefBox) Run() (err error) {
5860
}
5961

6062
func (r *RefBox) openStateFiles() {
61-
stateHistoryLogFileName := "state-history_" + time.Now().Format("2006-01-02_15-04-05") + ".log"
63+
stateHistoryLogFileName := logDir + "/state-history_" + time.Now().Format("2006-01-02_15-04-05") + ".log"
6264
f, err := os.OpenFile(stateHistoryLogFileName, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
6365
if err != nil {
6466
log.Fatal("Can not open state history log file", err)

0 commit comments

Comments
 (0)