summaryrefslogtreecommitdiff
path: root/internal/fsm
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-07-20 16:07:13 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-07-20 16:07:13 +0200
commit0c9a300a58d9dacce7b84ff93222eed35eab5721 (patch)
tree423d1f05024f5c050e09f8d239f15b2e8681e640 /internal/fsm
parenta1939a105dc4ddab27489b1bac3b22f674536e41 (diff)
Refactor: Do not log in internal packages
The reason behind this is that we then do not have to pass a lot to each function. Logging inside internal packages is less useful as we want to let them return errors and only log in the 'public' facing API or let the client decide
Diffstat (limited to 'internal/fsm')
-rw-r--r--internal/fsm/fsm.go8
1 files changed, 1 insertions, 7 deletions
diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go
index c87fd4f..b822a72 100644
--- a/internal/fsm/fsm.go
+++ b/internal/fsm/fsm.go
@@ -8,7 +8,6 @@ import (
"path"
"sort"
- "github.com/jwijenbergh/eduvpn-common/internal/log"
"github.com/jwijenbergh/eduvpn-common/internal/types"
)
@@ -126,12 +125,11 @@ type FSM struct {
// Info to be passed from the parent state
Name string
StateCallback func(string, string, string)
- Logger *log.FileLogger
Directory string
Debug bool
}
-func (fsm *FSM) Init(name string, callback func(string, string, string), logger *log.FileLogger, directory string, debug bool) {
+func (fsm *FSM) Init(name string, callback func(string, string, string), directory string, debug bool) {
fsm.States = FSMStates{
DEREGISTERED: FSMState{Transitions: []FSMTransition{{NO_SERVER, "Client registers"}}},
NO_SERVER: FSMState{Transitions: []FSMTransition{{CHOSEN_SERVER, "User chooses a server"}, {SEARCH_SERVER, "The user is trying to choose a Server in the UI"}, {CONNECTED, "The user is already connected"}}},
@@ -150,7 +148,6 @@ func (fsm *FSM) Init(name string, callback func(string, string, string), logger
fsm.Current = DEREGISTERED
fsm.Name = name
fsm.StateCallback = callback
- fsm.Logger = logger
fsm.Directory = directory
fsm.Debug = debug
}
@@ -180,7 +177,6 @@ func (fsm *FSM) writeGraph() {
graphImgFile := fsm.getGraphFilename(".png")
f, err := os.Create(graphFile)
if err != nil {
- fsm.Logger.Log(log.LOG_INFO, fmt.Sprintf("Failed to write debug fsm graph with error %v", err))
return
}
@@ -205,8 +201,6 @@ func (fsm *FSM) GoTransitionWithData(newState FSMStateID, data string, backgroun
fsm.writeGraph()
}
- fsm.Logger.Log(log.LOG_INFO, fmt.Sprintf("State: %s -> State: %s with data %s\n", oldState.String(), newState.String(), data))
-
if background {
go fsm.StateCallback(oldState.String(), newState.String(), data)
} else {