Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#Improve: Use more preferable way to specify logger - Interface #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/alexandrevicenzi/go-sse

go 1.11
go 1.18
10 changes: 8 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package sse

import (
"log"
"net/http"
)

// Logger Interface with all necessary functions to log.
type LogPrinter interface {
Print(v ...any)
Println(v ...any)
Printf(format string, v ...any)
}

// Options holds server configurations.
type Options struct {
// RetryInterval change EventSource default retry interval (milliseconds).
Expand All @@ -15,7 +21,7 @@ type Options struct {
// Default channel name is the request path.
ChannelNameFunc func(*http.Request) string
// All usage logs end up in Logger
Logger *log.Logger
Logger LogPrinter
}

func (opt *Options) hasHeaders() bool {
Expand Down