Skip to content

Commit 4763a1f

Browse files
gearnoders
authored andcommitted
Allow to use custom logger (#82)
1 parent 76f58f3 commit 4763a1f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cors.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,15 @@ type Options struct {
6969
Debug bool
7070
}
7171

72+
// Logger generic interface for logger
73+
type Logger interface {
74+
Printf(string, ...interface{})
75+
}
76+
7277
// Cors http handler
7378
type Cors struct {
7479
// Debug logger
75-
Log *log.Logger
80+
Log Logger
7681
// Normalized list of plain allowed origins
7782
allowedOrigins []string
7883
// List of allowed origins containing wildcards
@@ -349,7 +354,7 @@ func (c *Cors) handleActualRequest(w http.ResponseWriter, r *http.Request) {
349354
c.logf(" Actual response added headers: %v", headers)
350355
}
351356

352-
// convenience method. checks if debugging is turned on before printing
357+
// convenience method. checks if a logger is set.
353358
func (c *Cors) logf(format string, a ...interface{}) {
354359
if c.Log != nil {
355360
c.Log.Printf(format, a...)

0 commit comments

Comments
 (0)