Skip to content

Commit

Permalink
Merge pull request #37 from garsue/remove-logger
Browse files Browse the repository at this point in the history
Remove logger
  • Loading branch information
garsue authored Jan 5, 2019
2 parents 2ab7220 + 23c3f87 commit a8740bd
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 127 deletions.
13 changes: 6 additions & 7 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import (
"context"
"fmt"
"net/http"

"github.com/garsue/sparql/logger"
)

// Client queries to its SPARQL endpoint.
type Client struct {
HTTPClient http.Client
Logger logger.Logger
Endpoint string
prefixes map[string]URI
resultParser ResultParser
Expand Down Expand Up @@ -46,7 +43,6 @@ func WithPrefix(prefix string, uri URI) Option {
// New returns `sparql.Client`.
func New(endpoint string, opts ...Option) (*Client, error) {
client := &Client{
Logger: *logger.New(),
Endpoint: endpoint,
prefixes: make(map[string]URI),
resultParser: NewXMLResultParser(),
Expand All @@ -66,7 +62,7 @@ func (c *Client) Close() error {
}

// Ping sends a HTTP HEAD request to the endpoint.
func (c *Client) Ping(ctx context.Context) error {
func (c *Client) Ping(ctx context.Context) (err error) {
request, err := http.NewRequest(http.MethodHead, c.Endpoint, nil)
if err != nil {
return err
Expand All @@ -76,8 +72,11 @@ func (c *Client) Ping(ctx context.Context) error {
if err != nil {
return err
}
defer c.Logger.LogCloseError(resp.Body)
c.Logger.Debug.Printf("Ping %+v", resp)
defer func() {
if err2 := resp.Body.Close(); err2 != nil {
err = err2
}
}()

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("SPARQL ping error. status code %d", resp.StatusCode)
Expand Down
3 changes: 0 additions & 3 deletions client/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ func (s *Statement) Query(
if err != nil {
return nil, err
}
defer s.c.Logger.LogCloseError(resp.Body)
s.c.Logger.Debug.Printf("%+v\n", resp)

if resp.StatusCode != http.StatusOK {
scanner := bufio.NewScanner(resp.Body)
Expand Down Expand Up @@ -89,7 +87,6 @@ func (s *Statement) request(ctx context.Context, params ...Param) (*http.Request

// Build the query
built := b.String()
s.c.Logger.Debug.Println(built)
url := request.URL.Query()
url.Set("query", built)
url.Set("format", s.c.resultParser.Format())
Expand Down
8 changes: 0 additions & 8 deletions client/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"strings"
"testing"
"time"

"github.com/garsue/sparql/logger"
)

func ExampleClient_Query_simple() {
Expand Down Expand Up @@ -357,7 +355,6 @@ func TestClient_Query(t *testing.T) {

c := &Client{
HTTPClient: *server.Client(),
Logger: *logger.New(),
Endpoint: server.URL,
resultParser: NewXMLResultParser(),
}
Expand All @@ -375,7 +372,6 @@ func TestClient_Query(t *testing.T) {

c := &Client{
HTTPClient: *server.Client(),
Logger: *logger.New(),
Endpoint: server.URL,
resultParser: NewXMLResultParser(),
}
Expand Down Expand Up @@ -403,7 +399,6 @@ func TestClient_Query(t *testing.T) {

c := &Client{
HTTPClient: *server.Client(),
Logger: *logger.New(),
Endpoint: server.URL,
prefixes: map[string]URI{"foo": "bar"},
resultParser: NewXMLResultParser(),
Expand Down Expand Up @@ -480,7 +475,6 @@ func TestStatement_Query(t *testing.T) {

c := &Client{
HTTPClient: *server.Client(),
Logger: *logger.New(),
Endpoint: server.URL,
resultParser: NewXMLResultParser(),
}
Expand All @@ -498,7 +492,6 @@ func TestStatement_Query(t *testing.T) {

c := &Client{
HTTPClient: *server.Client(),
Logger: *logger.New(),
Endpoint: server.URL,
resultParser: NewXMLResultParser(),
}
Expand Down Expand Up @@ -526,7 +519,6 @@ func TestStatement_Query(t *testing.T) {

c := &Client{
HTTPClient: *server.Client(),
Logger: *logger.New(),
Endpoint: server.URL,
prefixes: map[string]URI{"foo": "bar"},
resultParser: NewXMLResultParser(),
Expand Down
5 changes: 0 additions & 5 deletions logger/env.go

This file was deleted.

5 changes: 0 additions & 5 deletions logger/env_debug.go

This file was deleted.

5 changes: 0 additions & 5 deletions logger/env_quiet.go

This file was deleted.

5 changes: 0 additions & 5 deletions logger/env_test.go

This file was deleted.

54 changes: 0 additions & 54 deletions logger/logger.go

This file was deleted.

35 changes: 0 additions & 35 deletions logger/logger_test.go

This file was deleted.

0 comments on commit a8740bd

Please sign in to comment.