-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds new log impls and renames files for consistency
- Loading branch information
Showing
20 changed files
with
789 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,15 @@ | |
// Contact [email protected] if any conditions of this licensing | ||
// are not clear to you. | ||
|
||
package quickfix | ||
package file | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"path" | ||
|
||
"github.com/quickfixgo/quickfix" | ||
"github.com/quickfixgo/quickfix/config" | ||
) | ||
|
||
|
@@ -47,20 +48,20 @@ func (l fileLog) OnEventf(format string, v ...interface{}) { | |
|
||
type fileLogFactory struct { | ||
globalLogPath string | ||
sessionLogPaths map[SessionID]string | ||
sessionLogPaths map[quickfix.SessionID]string | ||
} | ||
|
||
// NewFileLogFactory creates an instance of LogFactory that writes messages and events to file. | ||
// NewLogFactory creates an instance of LogFactory that writes messages and events to file. | ||
// The location of global and session log files is configured via FileLogPath. | ||
func NewFileLogFactory(settings *Settings) (LogFactory, error) { | ||
func NewLogFactory(settings *quickfix.Settings) (quickfix.LogFactory, error) { | ||
logFactory := fileLogFactory{} | ||
|
||
var err error | ||
if logFactory.globalLogPath, err = settings.GlobalSettings().Setting(config.FileLogPath); err != nil { | ||
return logFactory, err | ||
} | ||
|
||
logFactory.sessionLogPaths = make(map[SessionID]string) | ||
logFactory.sessionLogPaths = make(map[quickfix.SessionID]string) | ||
|
||
for sid, sessionSettings := range settings.SessionSettings() { | ||
logPath, err := sessionSettings.Setting(config.FileLogPath) | ||
|
@@ -101,11 +102,11 @@ func newFileLog(prefix string, logPath string) (fileLog, error) { | |
return l, nil | ||
} | ||
|
||
func (f fileLogFactory) Create() (Log, error) { | ||
func (f fileLogFactory) Create() (quickfix.Log, error) { | ||
return newFileLog("GLOBAL", f.globalLogPath) | ||
} | ||
|
||
func (f fileLogFactory) CreateSessionLog(sessionID SessionID) (Log, error) { | ||
func (f fileLogFactory) CreateSessionLog(sessionID quickfix.SessionID) (quickfix.Log, error) { | ||
logPath, ok := f.sessionLogPaths[sessionID] | ||
|
||
if !ok { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
// Contact [email protected] if any conditions of this licensing | ||
// are not clear to you. | ||
|
||
package quickfix | ||
package file | ||
|
||
import ( | ||
"bufio" | ||
|
@@ -22,11 +22,13 @@ import ( | |
"path" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/quickfixgo/quickfix" | ||
) | ||
|
||
func TestFileLog_NewFileLogFactory(t *testing.T) { | ||
|
||
_, err := NewFileLogFactory(NewSettings()) | ||
_, err := NewLogFactory(quickfix.NewSettings()) | ||
|
||
if err == nil { | ||
t.Error("Should expect error when settings have no file log path") | ||
|
@@ -52,9 +54,9 @@ TargetCompID=ARCA | |
SessionQualifier=BS | ||
` | ||
stringReader := strings.NewReader(cfg) | ||
settings, _ := ParseSettings(stringReader) | ||
settings, _ := quickfix.ParseSettings(stringReader) | ||
|
||
factory, err := NewFileLogFactory(settings) | ||
factory, err := NewLogFactory(settings) | ||
|
||
if err != nil { | ||
t.Error("Did not expect error", err) | ||
|
@@ -68,7 +70,7 @@ SessionQualifier=BS | |
type fileLogHelper struct { | ||
LogPath string | ||
Prefix string | ||
Log Log | ||
Log quickfix.Log | ||
} | ||
|
||
func newFileLogHelper(t *testing.T) *fileLogHelper { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,15 +13,17 @@ | |
// Contact [email protected] if any conditions of this licensing | ||
// are not clear to you. | ||
|
||
package quickfix | ||
package file | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/quickfixgo/quickfix" | ||
) | ||
|
||
func sessionIDFilenamePrefix(s SessionID) string { | ||
func sessionIDFilenamePrefix(s quickfix.SessionID) string { | ||
sender := []string{s.SenderCompID} | ||
if s.SenderSubID != "" { | ||
sender = append(sender, s.SenderSubID) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,15 @@ | |
// Contact [email protected] if any conditions of this licensing | ||
// are not clear to you. | ||
|
||
package quickfix | ||
package file | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
"testing" | ||
|
||
"github.com/quickfixgo/quickfix" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
|
@@ -37,15 +38,15 @@ func requireFileExists(t *testing.T, fname string) { | |
|
||
func TestSessionIDFilename_MinimallyQualifiedSessionID(t *testing.T) { | ||
// When the session ID is | ||
sessionID := SessionID{BeginString: "FIX.4.4", SenderCompID: "SENDER", TargetCompID: "TARGET"} | ||
sessionID := quickfix.SessionID{BeginString: "FIX.4.4", SenderCompID: "SENDER", TargetCompID: "TARGET"} | ||
|
||
// Then the filename should be | ||
require.Equal(t, "FIX.4.4-SENDER-TARGET", sessionIDFilenamePrefix(sessionID)) | ||
} | ||
|
||
func TestSessionIDFilename_FullyQualifiedSessionID(t *testing.T) { | ||
// When the session ID is | ||
sessionID := SessionID{ | ||
sessionID := quickfix.SessionID{ | ||
BeginString: "FIX.4.4", | ||
SenderCompID: "A", | ||
SenderSubID: "B", | ||
|
Oops, something went wrong.