feat: replace logrus logger with logf
logf is a minimal logger with no dependencies. this commit should bring down the binary size.
This commit is contained in:
parent
218eb0233a
commit
0f8084b13c
14 changed files with 102 additions and 114 deletions
|
@ -4,12 +4,12 @@ import (
|
|||
"github.com/miekg/dns"
|
||||
"github.com/mr-karan/doggo/pkg/models"
|
||||
"github.com/mr-karan/doggo/pkg/resolvers"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/mr-karan/logf"
|
||||
)
|
||||
|
||||
// App represents the structure for all app wide configuration.
|
||||
type App struct {
|
||||
Logger *logrus.Logger
|
||||
Logger *logf.Logger
|
||||
Version string
|
||||
QueryFlags models.QueryFlags
|
||||
Questions []dns.Question
|
||||
|
@ -19,7 +19,7 @@ type App struct {
|
|||
}
|
||||
|
||||
// NewApp initializes an instance of App which holds app wide configuration.
|
||||
func New(logger *logrus.Logger, buildVersion string) App {
|
||||
func New(logger *logf.Logger, buildVersion string) App {
|
||||
app := App{
|
||||
Logger: logger,
|
||||
Version: buildVersion,
|
||||
|
|
|
@ -15,8 +15,7 @@ func (app *App) outputJSON(rsp []resolvers.Response) {
|
|||
// Pretty print with 4 spaces.
|
||||
res, err := json.MarshalIndent(rsp, "", " ")
|
||||
if err != nil {
|
||||
app.Logger.WithError(err).Error("unable to output data in JSON")
|
||||
app.Logger.Exit(-1)
|
||||
app.Logger.WithError(err).Fatal("unable to output data in JSON")
|
||||
}
|
||||
fmt.Printf("%s", res)
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@ func (app *App) ReverseLookup() {
|
|||
for _, n := range app.QueryFlags.QNames {
|
||||
addr, err := dns.ReverseAddr(n)
|
||||
if err != nil {
|
||||
app.Logger.WithError(err).Error("error formatting address")
|
||||
app.Logger.Exit(2)
|
||||
app.Logger.WithError(err).Fatal("error formatting address")
|
||||
}
|
||||
formattedNames = append(formattedNames, addr)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue