Get rid of logrus, it's TTY output is not friendly or human parseable if we will want users to send us logs.

This commit is contained in:
Eugene Bujak 2018-12-29 14:55:35 +03:00
parent a7e0f66492
commit 55a7ff7447
7 changed files with 9 additions and 13 deletions

4
app.go
View File

@ -3,6 +3,7 @@ package main
import (
"bufio"
"fmt"
"log"
"net"
"net/http"
"os"
@ -13,7 +14,6 @@ import (
"time"
"github.com/gobuffalo/packr"
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh/terminal"
)
@ -64,7 +64,7 @@ func main() {
}
bindPort = &v
}, nil},
{"verbose", "v", "enable verbose output", nil, func() { log.SetLevel(log.TraceLevel) }},
// {"verbose", "v", "enable verbose output", nil, func() { log.SetLevel(log.TraceLevel) }},
{"help", "h", "print this help", nil, func() { printHelp(); os.Exit(64) }},
}
printHelp = func() {

View File

@ -3,6 +3,7 @@ package dnsforward
import (
"errors"
"fmt"
"log"
"net"
"strings"
"sync"
@ -13,7 +14,6 @@ import (
"github.com/AdguardTeam/dnsproxy/upstream"
"github.com/joomcode/errorx"
"github.com/miekg/dns"
log "github.com/sirupsen/logrus"
)
// DefaultTimeout is the default upstream timeout
@ -283,7 +283,7 @@ func (s *Server) filterDNSRequest(d *proxy.DNSContext) (*dnsfilter.Result, error
// Return immediately if there's an error
return nil, errorx.Decorate(err, "dnsfilter failed to check host '%s'", host)
} else if res.IsFiltered {
log.Debugf("Host %s is filtered, reason - '%s', matched rule: '%s'", host, res.Reason, res.Rule)
// trace("Host %s is filtered, reason - '%s', matched rule: '%s'", host, res.Reason, res.Rule)
d.Res = s.genDNSFilterMessage(d, &res)
}
@ -324,7 +324,7 @@ func (s *Server) genARecord(request *dns.Msg, ip net.IP) *dns.Msg {
resp.SetReply(request)
answer, err := dns.NewRR(fmt.Sprintf("%s %d A %s", request.Question[0].Name, s.BlockedResponseTTL, ip.String()))
if err != nil {
log.Warnf("Couldn't generate A record for up replacement host '%s': %s", ip.String(), err)
log.Printf("Couldn't generate A record for replacement host '%s': %s", ip.String(), err)
return s.genServerFailure(request)
}
resp.Answer = append(resp.Answer, answer)

View File

@ -3,6 +3,7 @@ package dnsforward
import (
"encoding/json"
"fmt"
"log"
"net"
"net/http"
"strconv"
@ -12,7 +13,6 @@ import (
"github.com/AdguardTeam/AdGuardHome/dnsfilter"
"github.com/miekg/dns"
log "github.com/sirupsen/logrus"
)
const (

View File

@ -5,12 +5,11 @@ import (
"compress/gzip"
"encoding/json"
"fmt"
"log"
"os"
"sync"
"time"
log "github.com/sirupsen/logrus"
"github.com/go-test/deep"
)

View File

@ -3,6 +3,7 @@ package dnsforward
import (
"bytes"
"fmt"
"log"
"net/http"
"os"
"path"
@ -13,8 +14,6 @@ import (
"sync"
"time"
log "github.com/sirupsen/logrus"
"github.com/bluele/gcache"
"github.com/miekg/dns"
)

View File

@ -3,12 +3,11 @@ package dnsforward
import (
"encoding/json"
"fmt"
"log"
"net/http"
"sync"
"time"
log "github.com/sirupsen/logrus"
"github.com/AdguardTeam/AdGuardHome/dnsfilter"
)

1
go.mod
View File

@ -18,7 +18,6 @@ require (
github.com/pkg/errors v0.8.0
github.com/shirou/gopsutil v2.18.10+incompatible
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/sirupsen/logrus v1.2.0
go.uber.org/goleak v0.10.0
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9
golang.org/x/net v0.0.0-20181220203305-927f97764cc3