diff --git a/cmd/yggmail/main.go b/cmd/yggmail/main.go index de2d6f4..d8cf81d 100644 --- a/cmd/yggmail/main.go +++ b/cmd/yggmail/main.go @@ -13,6 +13,7 @@ import ( "github.com/emersion/go-sasl" "github.com/emersion/go-smtp" + "github.com/fatih/color" "golang.org/x/term" "github.com/neilalexander/yggmail/internal/config" @@ -37,7 +38,8 @@ func (i *peerAddrList) Set(value string) error { func main() { rawlog := log.New(os.Stdout, "", 0) - log := log.New(rawlog.Writer(), "[ \033[32mYggmail\033[0m ] ", 0) + green := color.New(color.FgGreen).SprintfFunc() + log := log.New(rawlog.Writer(), fmt.Sprintf("[ %s ] ", green("Yggmail")), 0) var peerAddrs peerAddrList database := flag.String("database", "yggmail.db", "SQLite database file") diff --git a/go.mod b/go.mod index adf5558..d2b0975 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/emersion/go-message v0.15.0 github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 github.com/emersion/go-smtp v0.15.0 + github.com/fatih/color v1.12.0 github.com/gologme/log v1.2.0 github.com/mattn/go-sqlite3 v1.14.7 github.com/neilalexander/utp v0.1.1-0.20210705212447-691f29ad692b diff --git a/go.sum b/go.sum index 7187357..3aa4df8 100644 --- a/go.sum +++ b/go.sum @@ -48,6 +48,7 @@ github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe/go.mod h1: github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594 h1:IbFBtwoTQyw0fIM5xv1HF+Y+3ZijDR839WMulgxCcUY= github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20180728074245-46e3a41ad493/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= @@ -70,8 +71,10 @@ github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJ github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk= github.com/martinlindhe/base36 v1.0.0/go.mod h1:+AtEs8xrBpCeYgSLoY/aJ6Wf37jtBuR0s35750M27+8= github.com/martinlindhe/base36 v1.1.0/go.mod h1:+AtEs8xrBpCeYgSLoY/aJ6Wf37jtBuR0s35750M27+8= +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= diff --git a/internal/transport/yggdrasil.go b/internal/transport/yggdrasil.go index 0719514..45dd89e 100644 --- a/internal/transport/yggdrasil.go +++ b/internal/transport/yggdrasil.go @@ -8,6 +8,7 @@ import ( "net" iwt "github.com/Arceliar/ironwood/types" + "github.com/fatih/color" gologme "github.com/gologme/log" "github.com/neilalexander/utp" "github.com/yggdrasil-network/yggdrasil-go/src/config" @@ -36,7 +37,8 @@ func NewYggdrasilTransport(log *log.Logger, sk ed25519.PrivateKey, pk ed25519.Pu }, NodeInfoPrivacy: true, } - glog := gologme.New(log.Writer(), "[ \033[33mYggdrasil\033[0m ] ", 0) + yellow := color.New(color.FgYellow).SprintfFunc() + glog := gologme.New(log.Writer(), fmt.Sprintf("[ %s ] ", yellow("Yggdrasil")), 0) glog.EnableLevel("warn") glog.EnableLevel("error") glog.EnableLevel("info")