git » dnss » commit dab7f50

Adjust to the new logconfig

author Alberto Bertogli
2015-09-07 00:24:45 UTC
committer Alberto Bertogli
2015-09-07 00:24:45 UTC
parent a775eaa778da285159df4558cffcad4ddda8e8f7

Adjust to the new logconfig

dnss.go +4 -3
dnstogrpc/dnstogrpc.go +9 -9
grpctodns/grpctodns.go +8 -8

diff --git a/dnss.go b/dnss.go
index ba9427d..b18819a 100644
--- a/dnss.go
+++ b/dnss.go
@@ -2,11 +2,12 @@ package main
 
 import (
 	"flag"
+	"log"
 	"sync"
 
 	"blitiri.com.ar/go/dnss/dnstogrpc"
 	"blitiri.com.ar/go/dnss/grpctodns"
-	"blitiri.com.ar/go/l"
+	"blitiri.com.ar/go/logconfig"
 	"blitiri.com.ar/go/profile"
 )
 
@@ -29,11 +30,11 @@ var (
 func main() {
 	flag.Parse()
 
+	logconfig.Init("dnss")
 	profile.Init()
-	l.Init("dnss")
 
 	if !*enableDNStoGRPC && !*enableGRPCtoDNS {
-		l.Fatalf(
+		log.Fatalf(
 			"ERROR: pass --enable_dns_to_grpc or --enable_grpc_to_dns\n")
 	}
 
diff --git a/dnstogrpc/dnstogrpc.go b/dnstogrpc/dnstogrpc.go
index 94dd9e0..4df7f26 100644
--- a/dnstogrpc/dnstogrpc.go
+++ b/dnstogrpc/dnstogrpc.go
@@ -4,12 +4,12 @@ package dnstogrpc
 
 import (
 	"fmt"
+	"log"
 	"sync"
 	"time"
 
 	pb "blitiri.com.ar/go/dnss/proto"
 	"blitiri.com.ar/go/dnss/util"
-	"blitiri.com.ar/go/l"
 	"github.com/miekg/dns"
 	"golang.org/x/net/context"
 	"google.golang.org/grpc"
@@ -70,23 +70,23 @@ func p(w dns.ResponseWriter, r *dns.Msg) string {
 }
 
 func (s *Server) Handler(w dns.ResponseWriter, r *dns.Msg) {
-	l.Printf("DNS  %v %v\n", p(w, r), util.QuestionsToString(r.Question))
+	log.Printf("DNS  %v %v\n", p(w, r), util.QuestionsToString(r.Question))
 
 	// TODO: we should create our own IDs, in case different users pick the
 	// same id and we pass that upstream.
 
 	from_up, err := s.client.Query(r)
 	if err != nil {
-		l.Printf("DNS  %v  ERR: %v\n", p(w, r), err)
+		log.Printf("DNS  %v  ERR: %v\n", p(w, r), err)
 	}
 
 	if from_up != nil {
 		if from_up.Rcode != dns.RcodeSuccess {
 			rcode := dns.RcodeToString[from_up.Rcode]
-			l.Printf("DNS  %v  !->  %v\n", p(w, r), rcode)
+			log.Printf("DNS  %v  !->  %v\n", p(w, r), rcode)
 		}
 		for _, rr := range from_up.Answer {
-			l.Printf("DNS  %v  ->  %v\n", p(w, r), rr)
+			log.Printf("DNS  %v  ->  %v\n", p(w, r), rr)
 		}
 		w.WriteMsg(from_up)
 	}
@@ -96,25 +96,25 @@ func (s *Server) ListenAndServe() {
 	err := s.client.Connect()
 	if err != nil {
 		// TODO: handle errors and reconnect.
-		l.Printf("Error creating GRPC client: %v\n", err)
+		log.Printf("Error creating GRPC client: %v\n", err)
 		return
 	}
 
-	l.Printf("DNS listening on %s\n", s.Addr)
+	log.Printf("DNS listening on %s\n", s.Addr)
 
 	var wg sync.WaitGroup
 	wg.Add(1)
 	go func() {
 		defer wg.Done()
 		err := dns.ListenAndServe(s.Addr, "udp", dns.HandlerFunc(s.Handler))
-		l.Printf("Exiting UDP: %v\n", err)
+		log.Printf("Exiting UDP: %v\n", err)
 	}()
 
 	wg.Add(1)
 	go func() {
 		defer wg.Done()
 		err := dns.ListenAndServe(s.Addr, "tcp", dns.HandlerFunc(s.Handler))
-		l.Printf("Exiting TCP: %v\n", err)
+		log.Printf("Exiting TCP: %v\n", err)
 	}()
 
 	wg.Wait()
diff --git a/grpctodns/grpctodns.go b/grpctodns/grpctodns.go
index b2ba44c..871f24b 100644
--- a/grpctodns/grpctodns.go
+++ b/grpctodns/grpctodns.go
@@ -4,12 +4,12 @@ package grpctodns
 
 import (
 	"fmt"
+	"log"
 	"net"
 	"strings"
 
 	pb "blitiri.com.ar/go/dnss/proto"
 	"blitiri.com.ar/go/dnss/util"
-	"blitiri.com.ar/go/l"
 	"github.com/miekg/dns"
 	"golang.org/x/net/context"
 	"google.golang.org/grpc"
@@ -45,13 +45,13 @@ func (s *Server) Query(ctx context.Context, in *pb.RawMsg) (*pb.RawMsg, error) {
 		return nil, err
 	}
 
-	l.Printf("GRPC %v\n", util.QuestionsToString(r.Question))
+	log.Printf("GRPC %v\n", util.QuestionsToString(r.Question))
 
 	// TODO: we should create our own IDs, in case different users pick the
 	// same id and we pass that upstream.
 	from_up, err := dns.Exchange(r, s.Upstream)
 	if err != nil {
-		l.Printf("GRPC   ERR: %v\n", err)
+		log.Printf("GRPC   ERR: %v\n", err)
 		return nil, err
 	}
 
@@ -61,15 +61,15 @@ func (s *Server) Query(ctx context.Context, in *pb.RawMsg) (*pb.RawMsg, error) {
 
 	if from_up.Rcode != dns.RcodeSuccess {
 		rcode := dns.RcodeToString[from_up.Rcode]
-		l.Printf("GPRC   !->  %v\n", rcode)
+		log.Printf("GPRC   !->  %v\n", rcode)
 	}
 	for _, rr := range from_up.Answer {
-		l.Printf("GRPC   ->  %v\n", rr)
+		log.Printf("GRPC   ->  %v\n", rr)
 	}
 
 	buf, err := from_up.Pack()
 	if err != nil {
-		l.Printf("GRPC   ERR: %v\n", err)
+		log.Printf("GRPC   ERR: %v\n", err)
 		return nil, err
 	}
 
@@ -79,7 +79,7 @@ func (s *Server) Query(ctx context.Context, in *pb.RawMsg) (*pb.RawMsg, error) {
 func (s *Server) ListenAndServe() {
 	lis, err := net.Listen("tcp", s.Addr)
 	if err != nil {
-		l.Printf("failed to listen: %v", err)
+		log.Printf("failed to listen: %v", err)
 		return
 	}
 
@@ -88,6 +88,6 @@ func (s *Server) ListenAndServe() {
 	grpcServer := grpc.NewServer()
 	pb.RegisterDNSServiceServer(grpcServer, s)
 
-	l.Printf("GRPC listening on %s\n", s.Addr)
+	log.Printf("GRPC listening on %s\n", s.Addr)
 	grpcServer.Serve(lis)
 }