-
-
Notifications
You must be signed in to change notification settings - Fork 577
Moving log and fmt PrintX to be logrus Info and Debug #796
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it looks good. Note that the Siruspen
repo was moved a while ago to siruspen
so all of the import statements in this PR are a regression, so that needs to be fixed. There are also a bunch of places where errors are being logged, those should go to the Error logger. I also found at least one place where the output shouldn't go to the logger, but is meant to be printed to the screen as is.
app.go
Outdated
|
||
err := a.Stop(ctx.Err()) | ||
if err != nil { | ||
fmt.Println(err) | ||
logrus.Debug(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be sent to the Error logger.
app.go
Outdated
err = a.Worker.Stop() | ||
if err != nil { | ||
fmt.Println(err) | ||
logrus.Debug(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be sent to the Error logger.
app.go
Outdated
} | ||
} | ||
|
||
err = server.Shutdown(ctx) | ||
if err != nil { | ||
fmt.Println(err) | ||
logrus.Debug(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be sent to the Error logger.
app.go
Outdated
@@ -125,7 +126,7 @@ func (a *App) Serve() error { | |||
func (a *App) Stop(err error) error { | |||
a.cancel() | |||
if err != nil && errors.Cause(err) != context.Canceled { | |||
fmt.Println(err) | |||
logrus.Debug(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be sent to the Error logger.
buffalo/cmd/build/target.go
Outdated
@@ -4,7 +4,7 @@ import ( | |||
"os" | |||
"path/filepath" | |||
|
|||
"github.com/sirupsen/logrus" | |||
"github.com/Sirupsen/logrus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repo is now lower case sirupsen
. Can you please undo these import changes?
plugins/plugins.go
Outdated
@@ -83,12 +83,12 @@ func askBin(path string) Commands { | |||
cmd.Stderr = bb | |||
err := cmd.Run() | |||
if err != nil { | |||
fmt.Printf("[PLUGIN] error loading plugin %s: %s\n%s\n", path, err, bb.String()) | |||
logrus.Infof("[PLUGIN] error loading plugin %s: %s\n%s\n", path, err, bb.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error logger
plugins/plugins.go
Outdated
return commands | ||
} | ||
err = json.NewDecoder(bb).Decode(&commands) | ||
if err != nil { | ||
fmt.Printf("[PLUGIN] error loading plugin %s: %s\n", path, err) | ||
logrus.Infof("[PLUGIN] error loading plugin %s: %s\n", path, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error logger
render/template.go
Outdated
"os" | ||
"path/filepath" | ||
"sort" | ||
"strings" | ||
|
||
"github.com/Sirupsen/logrus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repo is now lower case sirupsen
. Can you please undo these import changes?
request_logger.go
Outdated
@@ -3,10 +3,10 @@ package buffalo | |||
import ( | |||
"time" | |||
|
|||
"github.com/Sirupsen/logrus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repo is now lower case sirupsen
. Can you please undo these import changes?
worker/simple.go
Outdated
@@ -5,8 +5,8 @@ import ( | |||
"sync" | |||
"time" | |||
|
|||
"github.com/Sirupsen/logrus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repo is now lower case sirupsen
. Can you please undo these import changes?
@markbates thanks for the feedback, all these have been implemented, let me know how is it looking when you have the chance, thanks again! |
buffalo/cmd/build.go
Outdated
@@ -57,7 +56,7 @@ var xbuildCmd = &cobra.Command{ | |||
return errors.WithStack(err) | |||
} | |||
|
|||
fmt.Printf("\nYou application was successfully built at %s\n", filepath.Join(b.Root, b.Bin)) | |||
logrus.Info("\nYou application was successfully built at %s\n", filepath.Join(b.Root, b.Bin)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be Infof
buffalo/cmd/build/apkg.go
Outdated
@@ -91,7 +91,7 @@ func (b *Builder) buildADatabase() error { | |||
logrus.Debugf("no sqlite usage in database.yml detected, applying the nosqlite tag") | |||
b.Tags = append(b.Tags, "nosqlite") | |||
} else if !b.Static { | |||
fmt.Println("you are building a SQLite application, please consider using the `--static` flag to compile a static binary") | |||
logrus.Debugf("you are building a SQLite application, please consider using the `--static` flag to compile a static binary") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be just Debug
buffalo/cmd/build/apkg.go
Outdated
@@ -91,7 +91,7 @@ func (b *Builder) buildADatabase() error { | |||
logrus.Debugf("no sqlite usage in database.yml detected, applying the nosqlite tag") | |||
b.Tags = append(b.Tags, "nosqlite") | |||
} else if !b.Static { | |||
fmt.Println("you are building a SQLite application, please consider using the `--static` flag to compile a static binary") | |||
logrus.Debugf("you are building a SQLite application, please consider using the `--static` flag to compile a static binary") | |||
} | |||
} else { | |||
logrus.Debugf("no database.yml detected, applying the nosqlite tag") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be just Debug
buffalo/cmd/destroy/resource.go
Outdated
@@ -51,22 +52,22 @@ func confirm(msg string) bool { | |||
func removeTemplates(fileName string) { | |||
if YesToAll || confirm("Want to remove templates? (Y/n)") { | |||
templatesFolder := fmt.Sprintf(filepath.Join("templates", fileName)) | |||
fmt.Printf("- Deleted %v folder\n", templatesFolder) | |||
logrus.Info("- Deleted %v folder\n", templatesFolder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be Infof
buffalo/cmd/destroy/resource.go
Outdated
os.Remove(filepath.Join("actions", fmt.Sprintf("%v_test.go", fileName))) | ||
|
||
content, err := ioutil.ReadFile(filepath.Join("actions", "app.go")) | ||
if err != nil { | ||
fmt.Println("[WARNING] error reading app.go content") | ||
logrus.Info("[WARNING] error reading app.go content") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Warn
and we can remove the warning
label
generators/action/action.go
Outdated
@@ -121,7 +122,7 @@ func (act Generator) findHandlersToAdd(path string) []meta.Name { | |||
for _, action := range act.Actions { | |||
funcSignature := fmt.Sprintf("app.GET(\"/%s/%s\", %s%s)", act.Name.URL(), action.URL(), act.Name.Camel(), action.Camel()) | |||
if strings.Contains(string(fileContents), funcSignature) { | |||
fmt.Printf("--> [warning] skipping %s from app.go since it already exists\n", funcSignature) | |||
logrus.Infof("--> [warning] skipping %s from app.go since it already exists\n", funcSignature) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Warnf
and we can remove the warning
label
generators/action/action.go
Outdated
@@ -142,7 +143,7 @@ func (act Generator) findTestsToAdd(path string) []meta.Name { | |||
for _, action := range act.Actions { | |||
funcSignature := fmt.Sprintf("func (as *ActionSuite) Test_%v_%v() {", act.Name.Camel(), action.Camel()) | |||
if strings.Contains(string(fileContents), funcSignature) { | |||
fmt.Printf("--> [warning] skipping Test_%v_%v since it already exists\n", act.Name.Camel(), action.Camel()) | |||
logrus.Infof("--> [warning] skipping Test_%v_%v since it already exists\n", act.Name.Camel(), action.Camel()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Warnf
and we can remove the warning
label
generators/assets/webpack/webpack.go
Outdated
@@ -26,7 +26,7 @@ func (w Generator) Run(root string, data makr.Data) error { | |||
|
|||
// if there's no npm, return! | |||
if _, err := exec.LookPath("npm"); err != nil { | |||
fmt.Println("Could not find npm. Skipping webpack generation.") | |||
logrus.Infof("Could not find npm. Skipping webpack generation.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Info
grifts.go
Outdated
@@ -35,7 +36,7 @@ func secretGrift() { | |||
rx := regexp.MustCompile(`(\W+)`) | |||
bb = rx.ReplaceAll(bb, []byte("")) | |||
s := randx.String(6) + string(bb) | |||
fmt.Println(s[:127]) | |||
println(s[:127]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should still be using fmt.Println
options.go
Outdated
@@ -121,7 +122,7 @@ func optionsWithDefaults(opts Options) Options { | |||
secret := envy.Get("SESSION_SECRET", "") | |||
// In production a SESSION_SECRET must be set! | |||
if opts.Env == "production" && secret == "" { | |||
log.Println("WARNING! Unless you set SESSION_SECRET env variable, your session storage is not protected!") | |||
logrus.Warn("WARNING! Unless you set SESSION_SECRET env variable, your session storage is not protected!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can remove the warning
label
…falo into task/moving-logs-to-logrus
@markbates next round of changes applied :) |
grifts.go
Outdated
fmt.Println(fmt.Sprintf("-> %s", a.Name)) | ||
fmt.Println(a.Middleware.String()) | ||
fmt.Println() | ||
logrus.Infof("-> %s", a.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function needs to go back to using Println
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just the one comment and then we're good to go!
…falo into task/moving-logs-to-logrus
@markbates all set :) |
grifts.go
Outdated
fmt.Println(fmt.Sprintf("-> %s", a.Name)) | ||
fmt.Println(a.Middleware.String()) | ||
fmt.Println() | ||
fmt.Printf("-> %s ", a.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for this, but this statement is missing a newline. Last change, I swear! :)
lol, now all set |
Awesome! Thanks. |
Thank you for all the help here! |
This is related with #765