diff options
Diffstat (limited to 'lib/crypto/gpg')
-rw-r--r-- | lib/crypto/gpg/gpg.go | 8 | ||||
-rw-r--r-- | lib/crypto/gpg/gpgbin/gpgbin.go | 33 |
2 files changed, 4 insertions, 37 deletions
diff --git a/lib/crypto/gpg/gpg.go b/lib/crypto/gpg/gpg.go index 00125ba6..e545e1c9 100644 --- a/lib/crypto/gpg/gpg.go +++ b/lib/crypto/gpg/gpg.go @@ -3,7 +3,6 @@ package gpg import ( "bytes" "io" - "log" "os/exec" "git.sr.ht/~rjarry/aerc/lib/crypto/gpg/gpgbin" @@ -13,12 +12,9 @@ import ( ) // Mail satisfies the PGPProvider interface in aerc -type Mail struct { - logger *log.Logger -} +type Mail struct{} -func (m *Mail) Init(l *log.Logger) error { - m.logger = l +func (m *Mail) Init() error { _, err := exec.LookPath("gpg") return err } diff --git a/lib/crypto/gpg/gpgbin/gpgbin.go b/lib/crypto/gpg/gpgbin/gpgbin.go index 9f79e972..2eb83dc9 100644 --- a/lib/crypto/gpg/gpgbin/gpgbin.go +++ b/lib/crypto/gpg/gpgbin/gpgbin.go @@ -6,15 +6,12 @@ import ( "errors" "fmt" "io" - "io/ioutil" - "log" - "os" "os/exec" "strconv" "strings" + "git.sr.ht/~rjarry/aerc/logging" "git.sr.ht/~rjarry/aerc/models" - "github.com/mattn/go-isatty" ) // gpg represents a gpg command with buffers attached to stdout and stderr @@ -112,17 +109,6 @@ func longKeyToUint64(key string) (uint64, error) { // parse parses the output of gpg --status-fd func parse(r io.Reader, md *models.MessageDetails) error { - var ( - logOut io.Writer - logger *log.Logger - ) - if !isatty.IsTerminal(os.Stdout.Fd()) { - logOut = os.Stdout - } else { - logOut = ioutil.Discard - os.Stdout, _ = os.Open(os.DevNull) - } - logger = log.New(logOut, "", log.LstdFlags) var err error var msgContent []byte var msgCollecting bool @@ -135,7 +121,7 @@ func parse(r io.Reader, md *models.MessageDetails) error { } if strings.HasPrefix(line, "[GNUPG:]") { msgCollecting = false - logger.Println(line) + logging.Debugf(line) } if msgCollecting { msgContent = append(msgContent, scanner.Bytes()...) @@ -270,18 +256,3 @@ var micalgs = map[int]string{ 10: "pgp-sha512", 11: "pgp-sha224", } - -func logger(s string) { - var ( - logOut io.Writer - logger *log.Logger - ) - if !isatty.IsTerminal(os.Stdout.Fd()) { - logOut = os.Stdout - } else { - logOut = ioutil.Discard - os.Stdout, _ = os.Open(os.DevNull) - } - logger = log.New(logOut, "", log.LstdFlags) - logger.Println(s) -} |