From 368e2d1ebd51bbb48a6df208299630666853f985 Mon Sep 17 00:00:00 2001
From: Eugene Bujak <hmage@hmage.net>
Date: Sat, 29 Dec 2018 19:12:22 +0300
Subject: [PATCH] move log wrapper library outside into hmage/golibs/log

---
 app.go                      |  2 +-
 config.go                   |  2 +-
 control.go                  |  2 +-
 dhcp.go                     |  2 +-
 dhcpd/check_other_dhcp.go   |  2 +-
 dhcpd/dhcpd.go              |  2 +-
 dhcpd/helpers.go            |  2 +-
 dhcpd/standalone/main.go    |  2 +-
 dns.go                      |  2 +-
 dnsfilter/dnsfilter.go      |  2 +-
 dnsfilter/dnsfilter_test.go |  2 +-
 dnsforward/dnsforward.go    |  2 +-
 dnsforward/querylog.go      |  2 +-
 dnsforward/querylog_file.go |  2 +-
 dnsforward/querylog_top.go  |  2 +-
 dnsforward/stats.go         |  2 +-
 filter.go                   |  2 +-
 go.mod                      |  1 +
 go.sum                      |  2 ++
 i18n.go                     |  2 +-
 log/log.go                  | 57 -------------------------------------
 upgrade.go                  |  2 +-
 22 files changed, 22 insertions(+), 76 deletions(-)
 delete mode 100644 log/log.go

diff --git a/app.go b/app.go
index 4d5e53a9..9439eb8a 100644
--- a/app.go
+++ b/app.go
@@ -12,8 +12,8 @@ import (
 	"syscall"
 	"time"
 
-	"github.com/AdguardTeam/AdGuardHome/log"
 	"github.com/gobuffalo/packr"
+	"github.com/hmage/golibs/log"
 	"golang.org/x/crypto/ssh/terminal"
 )
 
diff --git a/config.go b/config.go
index 8fc7255d..f759ff4a 100644
--- a/config.go
+++ b/config.go
@@ -9,7 +9,7 @@ import (
 	"github.com/AdguardTeam/AdGuardHome/dhcpd"
 	"github.com/AdguardTeam/AdGuardHome/dnsfilter"
 	"github.com/AdguardTeam/AdGuardHome/dnsforward"
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 	"gopkg.in/yaml.v2"
 )
 
diff --git a/control.go b/control.go
index b15e2a25..e35c2529 100644
--- a/control.go
+++ b/control.go
@@ -12,8 +12,8 @@ import (
 	"time"
 
 	"github.com/AdguardTeam/AdGuardHome/dnsforward"
-	"github.com/AdguardTeam/AdGuardHome/log"
 	"github.com/AdguardTeam/dnsproxy/upstream"
+	"github.com/hmage/golibs/log"
 	"github.com/miekg/dns"
 	"gopkg.in/asaskevich/govalidator.v4"
 )
diff --git a/dhcp.go b/dhcp.go
index 983f755a..4a54e82f 100644
--- a/dhcp.go
+++ b/dhcp.go
@@ -10,7 +10,7 @@ import (
 	"time"
 
 	"github.com/AdguardTeam/AdGuardHome/dhcpd"
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 	"github.com/joomcode/errorx"
 )
 
diff --git a/dhcpd/check_other_dhcp.go b/dhcpd/check_other_dhcp.go
index 5d81953c..661b2daa 100644
--- a/dhcpd/check_other_dhcp.go
+++ b/dhcpd/check_other_dhcp.go
@@ -9,7 +9,7 @@ import (
 	"os"
 	"time"
 
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 	"github.com/krolaw/dhcp4"
 )
 
diff --git a/dhcpd/dhcpd.go b/dhcpd/dhcpd.go
index d663121a..2b1198e4 100644
--- a/dhcpd/dhcpd.go
+++ b/dhcpd/dhcpd.go
@@ -6,7 +6,7 @@ import (
 	"net"
 	"time"
 
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 	"github.com/krolaw/dhcp4"
 )
 
diff --git a/dhcpd/helpers.go b/dhcpd/helpers.go
index b47015fd..20793f52 100644
--- a/dhcpd/helpers.go
+++ b/dhcpd/helpers.go
@@ -5,7 +5,7 @@ import (
 	"net"
 	"strings"
 
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 	"github.com/joomcode/errorx"
 )
 
diff --git a/dhcpd/standalone/main.go b/dhcpd/standalone/main.go
index 3b8c2b4c..fff02664 100644
--- a/dhcpd/standalone/main.go
+++ b/dhcpd/standalone/main.go
@@ -8,7 +8,7 @@ import (
 	"time"
 
 	"github.com/AdguardTeam/AdGuardHome/dhcpd"
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 	"github.com/krolaw/dhcp4"
 )
 
diff --git a/dns.go b/dns.go
index 6ced782a..54e56184 100644
--- a/dns.go
+++ b/dns.go
@@ -6,8 +6,8 @@ import (
 
 	"github.com/AdguardTeam/AdGuardHome/dnsfilter"
 	"github.com/AdguardTeam/AdGuardHome/dnsforward"
-	"github.com/AdguardTeam/AdGuardHome/log"
 	"github.com/AdguardTeam/dnsproxy/upstream"
+	"github.com/hmage/golibs/log"
 	"github.com/joomcode/errorx"
 )
 
diff --git a/dnsfilter/dnsfilter.go b/dnsfilter/dnsfilter.go
index 5da4259c..51204e1b 100644
--- a/dnsfilter/dnsfilter.go
+++ b/dnsfilter/dnsfilter.go
@@ -16,8 +16,8 @@ import (
 	"sync/atomic"
 	"time"
 
-	"github.com/AdguardTeam/AdGuardHome/log"
 	"github.com/bluele/gcache"
+	"github.com/hmage/golibs/log"
 	"golang.org/x/net/publicsuffix"
 )
 
diff --git a/dnsfilter/dnsfilter_test.go b/dnsfilter/dnsfilter_test.go
index 08ee2b5b..02feb0c7 100644
--- a/dnsfilter/dnsfilter_test.go
+++ b/dnsfilter/dnsfilter_test.go
@@ -17,7 +17,7 @@ import (
 	"os"
 	"runtime"
 
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 	"github.com/shirou/gopsutil/process"
 	"go.uber.org/goleak"
 )
diff --git a/dnsforward/dnsforward.go b/dnsforward/dnsforward.go
index f60b0cf4..a242f460 100644
--- a/dnsforward/dnsforward.go
+++ b/dnsforward/dnsforward.go
@@ -9,9 +9,9 @@ import (
 	"time"
 
 	"github.com/AdguardTeam/AdGuardHome/dnsfilter"
-	"github.com/AdguardTeam/AdGuardHome/log"
 	"github.com/AdguardTeam/dnsproxy/proxy"
 	"github.com/AdguardTeam/dnsproxy/upstream"
+	"github.com/hmage/golibs/log"
 	"github.com/joomcode/errorx"
 	"github.com/miekg/dns"
 )
diff --git a/dnsforward/querylog.go b/dnsforward/querylog.go
index dd7bf2c2..901fa1f3 100644
--- a/dnsforward/querylog.go
+++ b/dnsforward/querylog.go
@@ -11,7 +11,7 @@ import (
 	"time"
 
 	"github.com/AdguardTeam/AdGuardHome/dnsfilter"
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 	"github.com/miekg/dns"
 )
 
diff --git a/dnsforward/querylog_file.go b/dnsforward/querylog_file.go
index 39f9cc46..930c4a8d 100644
--- a/dnsforward/querylog_file.go
+++ b/dnsforward/querylog_file.go
@@ -9,8 +9,8 @@ import (
 	"sync"
 	"time"
 
-	"github.com/AdguardTeam/AdGuardHome/log"
 	"github.com/go-test/deep"
+	"github.com/hmage/golibs/log"
 )
 
 var (
diff --git a/dnsforward/querylog_top.go b/dnsforward/querylog_top.go
index 563e64ca..2e55ffd7 100644
--- a/dnsforward/querylog_top.go
+++ b/dnsforward/querylog_top.go
@@ -13,8 +13,8 @@ import (
 	"sync"
 	"time"
 
-	"github.com/AdguardTeam/AdGuardHome/log"
 	"github.com/bluele/gcache"
+	"github.com/hmage/golibs/log"
 	"github.com/miekg/dns"
 )
 
diff --git a/dnsforward/stats.go b/dnsforward/stats.go
index 47a881f1..5791e1dc 100644
--- a/dnsforward/stats.go
+++ b/dnsforward/stats.go
@@ -8,7 +8,7 @@ import (
 	"time"
 
 	"github.com/AdguardTeam/AdGuardHome/dnsfilter"
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 )
 
 var (
diff --git a/filter.go b/filter.go
index b6bc4051..a776f458 100644
--- a/filter.go
+++ b/filter.go
@@ -12,7 +12,7 @@ import (
 	"time"
 
 	"github.com/AdguardTeam/AdGuardHome/dnsfilter"
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 )
 
 var (
diff --git a/go.mod b/go.mod
index 41a97633..81fe1a75 100644
--- a/go.mod
+++ b/go.mod
@@ -10,6 +10,7 @@ require (
 	github.com/go-ole/go-ole v1.2.1 // indirect
 	github.com/go-test/deep v1.0.1
 	github.com/gobuffalo/packr v1.19.0
+	github.com/hmage/golibs v0.0.0-20181229160906-c8491df0bfc4
 	github.com/jedisct1/go-dnsstamps v0.0.0-20180418170050-1e4999280f86
 	github.com/joomcode/errorx v0.1.0
 	github.com/krolaw/dhcp4 v0.0.0-20180925202202-7cead472c414
diff --git a/go.sum b/go.sum
index 4c18efc7..6e2c7424 100644
--- a/go.sum
+++ b/go.sum
@@ -32,6 +32,8 @@ github.com/gobuffalo/packd v0.0.0-20181031195726-c82734870264 h1:roWyi0eEdiFreSq
 github.com/gobuffalo/packd v0.0.0-20181031195726-c82734870264/go.mod h1:Yf2toFaISlyQrr5TfO3h6DB9pl9mZRmyvBGQb/aQ/pI=
 github.com/gobuffalo/packr v1.19.0 h1:3UDmBDxesCOPF8iZdMDBBWKfkBoYujIMIZePnobqIUI=
 github.com/gobuffalo/packr v1.19.0/go.mod h1:MstrNkfCQhd5o+Ct4IJ0skWlxN8emOq8DsoT1G98VIU=
+github.com/hmage/golibs v0.0.0-20181229160906-c8491df0bfc4 h1:FMAReGTEDNr4AdbScv/PqzjMQUpkkVHiF/t8sDHQQVQ=
+github.com/hmage/golibs v0.0.0-20181229160906-c8491df0bfc4/go.mod h1:H6Ev6svFxUVPFThxLtdnFfcE9e3GWufpfmcVFpqV6HM=
 github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
 github.com/jedisct1/go-dnsstamps v0.0.0-20180418170050-1e4999280f86 h1:Olj4M6T1omUfx7yTTcnhLf4xo6gYMmRHSJIfeA1NZy0=
 github.com/jedisct1/go-dnsstamps v0.0.0-20180418170050-1e4999280f86/go.mod h1:j/ONpSHHmPgDwmFKXg9vhQvIjADe/ft1X4a3TVOmp9g=
diff --git a/i18n.go b/i18n.go
index 80afd70a..5b8ad62f 100644
--- a/i18n.go
+++ b/i18n.go
@@ -6,7 +6,7 @@ import (
 	"net/http"
 	"strings"
 
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 )
 
 // --------------------
diff --git a/log/log.go b/log/log.go
deleted file mode 100644
index ba564153..00000000
--- a/log/log.go
+++ /dev/null
@@ -1,57 +0,0 @@
-// Wrapper for standard library log, with the only difference is that it has extra function Tracef() and optional verbose flag to enable output from that.
-package log
-
-import (
-	"fmt"
-	"log"
-	"os"
-	"path"
-	"runtime"
-	"strings"
-)
-
-var Verbose = false
-
-// Print calls Output to print to the standard logger.
-// Arguments are handled in the manner of fmt.Print.
-func Print(v ...interface{}) {
-	log.Print(v...)
-}
-
-// Printf calls Output to print to the standard logger.
-// Arguments are handled in the manner of fmt.Printf.
-func Printf(format string, v ...interface{}) {
-	log.Printf(format, v...)
-}
-
-// Println calls Output to print to the standard logger.
-// Arguments are handled in the manner of fmt.Println.
-func Println(v ...interface{}) {
-	log.Println(v...)
-}
-
-// Fatal is equivalent to Print() followed by a call to os.Exit(1).
-func Fatal(v ...interface{}) {
-	log.Fatal(v...)
-}
-
-// Fatalf is equivalent to Printf() followed by a call to os.Exit(1).
-func Fatalf(format string, v ...interface{}) {
-	log.Fatalf(format, v...)
-}
-
-func Tracef(format string, v ...interface{}) {
-	if Verbose {
-		pc := make([]uintptr, 10) // at least 1 entry needed
-		runtime.Callers(2, pc)
-		f := runtime.FuncForPC(pc[0])
-		var buf strings.Builder
-		buf.WriteString(fmt.Sprintf("%s(): ", path.Base(f.Name())))
-		text := fmt.Sprintf(format, v...)
-		buf.WriteString(text)
-		if len(text) == 0 || text[len(text)-1] != '\n' {
-			buf.WriteRune('\n')
-		}
-		fmt.Fprint(os.Stderr, buf.String())
-	}
-}
diff --git a/upgrade.go b/upgrade.go
index 582a9d0c..452df4d0 100644
--- a/upgrade.go
+++ b/upgrade.go
@@ -6,7 +6,7 @@ import (
 	"os"
 	"path/filepath"
 
-	"github.com/AdguardTeam/AdGuardHome/log"
+	"github.com/hmage/golibs/log"
 	"gopkg.in/yaml.v2"
 )