Skip to content

Commit

Permalink
Replacing deprecated io/ioutil functions (#1871)
Browse files Browse the repository at this point in the history
  • Loading branch information
LimJiAn authored Aug 21, 2023
1 parent 50a16fc commit 56b5408
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package bleve

import (
"expvar"
"io/ioutil"
"io"
"log"
"time"

Expand Down Expand Up @@ -86,10 +86,10 @@ func init() {
initDisk()
}

var logger = log.New(ioutil.Discard, "bleve", log.LstdFlags)
var logger = log.New(io.Discard, "bleve", log.LstdFlags)

// SetLog sets the logger used for logging
// by default log messages are sent to ioutil.Discard
// by default log messages are sent to io.Discard
func SetLog(l *log.Logger) {
logger = l
}
5 changes: 2 additions & 3 deletions http/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package http
import (
"encoding/json"
"io"
"io/ioutil"
"log"
"net/http"
)
Expand All @@ -42,10 +41,10 @@ func mustEncode(w io.Writer, i interface{}) {

type varLookupFunc func(req *http.Request) string

var logger = log.New(ioutil.Discard, "bleve.http", log.LstdFlags)
var logger = log.New(io.Discard, "bleve.http", log.LstdFlags)

// SetLog sets the logger used for logging
// by default log messages are sent to ioutil.Discard
// by default log messages are sent to io.Discard
func SetLog(l *log.Logger) {
logger = l
}
4 changes: 2 additions & 2 deletions index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"math"
"os"
Expand Down Expand Up @@ -828,7 +828,7 @@ func TestSlowSearch(t *testing.T) {

defer func() {
// reset logger back to normal
SetLog(log.New(ioutil.Discard, "bleve", log.LstdFlags))
SetLog(log.New(io.Discard, "bleve", log.LstdFlags))
}()
// set custom logger
var sdw sawDataWriter
Expand Down
6 changes: 3 additions & 3 deletions mapping/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package mapping

import (
"io/ioutil"
"io"
"log"

"github.com/blevesearch/bleve/v2/analysis"
Expand All @@ -37,10 +37,10 @@ type bleveClassifier interface {
BleveType() string
}

var logger = log.New(ioutil.Discard, "bleve mapping ", log.LstdFlags)
var logger = log.New(io.Discard, "bleve mapping ", log.LstdFlags)

// SetLog sets the logger used for logging
// by default log messages are sent to ioutil.Discard
// by default log messages are sent to io.Discard
func SetLog(l *log.Logger) {
logger = l
}
Expand Down
6 changes: 3 additions & 3 deletions search/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"

"github.com/blevesearch/bleve/v2/mapping"
"github.com/blevesearch/bleve/v2/search"
index "github.com/blevesearch/bleve_index_api"
)

var logger = log.New(ioutil.Discard, "bleve mapping ", log.LstdFlags)
var logger = log.New(io.Discard, "bleve mapping ", log.LstdFlags)

// SetLog sets the logger used for logging
// by default log messages are sent to ioutil.Discard
// by default log messages are sent to io.Discard
func SetLog(l *log.Logger) {
logger = l
}
Expand Down

0 comments on commit 56b5408

Please sign in to comment.