Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Logger framework and trade.go example #88

Merged
merged 10 commits into from
Jan 16, 2019

Conversation

Reidmcc
Copy link
Contributor

@Reidmcc Reidmcc commented Jan 10, 2019

This is a replacement for #71, incorporating requested changes.

@Reidmcc Reidmcc requested a review from nikhilsaraf as a code owner January 10, 2019 22:43
@Reidmcc
Copy link
Contributor Author

Reidmcc commented Jan 10, 2019

I left the logger variable as a top-level declaration in trade.go because if we move it into tradeCmd.Run = func(ccmd *cobra.Command, args []string) the logger is unavailable to the other top level functions, e.g. logPanic(). Alternately we could change the other functions to have them return their messages instead of logging the messages inside the functions but that's a bigger rewrite. Which solution do you prefer?

Copy link
Contributor

@nikhilsaraf nikhilsaraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should pass in the logger.Logger object to the logPanic functions and validateCliParam functions for now. rest of it looks great.

cmd/trade.go Outdated Show resolved Hide resolved
cmd/trade.go Outdated Show resolved Hide resolved
cmd/trade.go Outdated
log.Println()
log.Printf("problem encountered while instantiating the fill tracker: %s\n", e)
l.Info("")
l.Infof("problem encountered while instantiating the fill tracker: %s\n", e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should follow the same pattern as the logging of the monitoring server to keep things consistent. either change both to a new pattern or none.

cmd/trade.go Outdated Show resolved Hide resolved
cmd/trade.go Outdated Show resolved Hide resolved
support/logger/basicLogger.go Outdated Show resolved Hide resolved
support/logger/basicLogger.go Outdated Show resolved Hide resolved
cmd/trade.go Show resolved Hide resolved
cmd/trade.go Outdated Show resolved Hide resolved
@Reidmcc
Copy link
Contributor Author

Reidmcc commented Jan 12, 2019

Changes made

Copy link
Contributor

@nikhilsaraf nikhilsaraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're logging fatally before we delete all offers and exit -- this will cause the app to exit before we get a chance to execute the next line!

cmd/trade.go Outdated Show resolved Hide resolved
cmd/trade.go Outdated
}

if *logPrefix != "" {
t := time.Now().Format("20060102T150405MST")
fileName := fmt.Sprintf("%s_%s_%s_%s_%s_%s.log", *logPrefix, botConfig.AssetCodeA, botConfig.IssuerA, botConfig.AssetCodeB, botConfig.IssuerB, t)
e = setLogFile(fileName)
if e != nil {
log.Println()
log.Fatal(e)
l.Info("")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove the empty line printout here -- logger.Fatal starts off by printing an empty line

cmd/trade.go Outdated Show resolved Hide resolved
cmd/trade.go Outdated Show resolved Hide resolved
cmd/trade.go Outdated Show resolved Hide resolved
cmd/trade.go Outdated Show resolved Hide resolved
cmd/trade.go Outdated Show resolved Hide resolved
@Reidmcc
Copy link
Contributor Author

Reidmcc commented Jan 15, 2019

Updated

log.Printf("unable to start the monitoring server or problem encountered while running server: %s\n", e)
l.Info("")
l.Info("unable to start the monitoring server or problem encountered while running server:")
l.Errorf("%s", e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should typically be in the same line as where we wrap it (i.e. the line above), and should have a newline after (like we do on the left hand side of this diff). ok for now.

// Fatal is a convenience method that can be used with any Logger to log a fatal error
func Fatal(l Logger, e error) {
l.Info("")
l.Errorf("%s", e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should typically include a newline character at the end l.Errorf("%s", e) -> l.Errorf("%s\n", e)

@nikhilsaraf
Copy link
Contributor

@Reidmcc this is really good -- feel free to move forward and convert the remaining files to this new pattern.

@nikhilsaraf
Copy link
Contributor

this PR starts the process of addressing #9

@nikhilsaraf nikhilsaraf merged commit 7366a03 into stellar-deprecated:master Jan 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants