From 0c9a300a58d9dacce7b84ff93222eed35eab5721 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Wed, 20 Jul 2022 16:07:13 +0200 Subject: 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 --- internal/fsm/fsm.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'internal/fsm') 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 { -- cgit v1.2.3