pjebs / restgate

Secure Authentication for REST API endpoints.
MIT License
247 stars 23 forks source link

Logger can be overridden from external sources #5

Closed Ruxton closed 7 years ago

Ruxton commented 7 years ago

Adds a log interface so the log can be integrated with external sources (Like negroni's logger or a logstash logger)

  logger := negroni.NewLogger()
  n := negroni.New(negroni.NewRecovery(), logger, negroni.NewStatic(http.Dir("public")))
  n.Use(restgate.New("X-Auth-Key", "X-Auth-Secret", restgate.Static, restgate.Config{Key: []string{"test"}, Secret: []string{"abcdefg"}, Logger:logger}))
pjebs commented 7 years ago

Can you simplify ALogger to only include Printf?

Ruxton commented 7 years ago

I built it to line up with the std log package, which is capable of all the above, but I guess cutting it down to whatever you use is the smart thing to do.

Ruxton commented 7 years ago

@pjebs have cleaned it up now

pjebs commented 7 years ago

For backwards compatibility one more change to L68:

var std = New(os.Stderr, "", LstdFlags)

This was from the standard library source code: https://golang.org/src/log/log.go#L73

Then I will merge.

Thank you for your contribution.

Ruxton commented 7 years ago

@pjebs should all be resolved now

pjebs commented 7 years ago

Awesome work. Fixed up log.LstdFlags afterwards.