update installer logs

This commit is contained in:
Andrea Franz 2019-03-06 13:38:49 +01:00
parent 7354d52c0a
commit 9648e01c71
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D

View File

@ -9,6 +9,8 @@ import (
"github.com/status-im/keycard-go/hexutils"
)
var ndefRecord = hexutils.HexToBytes("0024d40f12616e64726f69642e636f6d3a706b67696d2e7374617475732e657468657265756d")
// Installer defines a struct with methods to install applets in a card.
type Installer struct {
c globalplatform.Channel
@ -23,29 +25,31 @@ func NewInstaller(t globalplatform.Transmitter) *Installer {
// Install installs the applet from the specified capFile.
func (i *Installer) Install(capFile *os.File, overwriteApplet bool) (err error) {
logger.Debug("installation started")
logger.Info("installation started")
startTime := time.Now()
cmdSet := globalplatform.NewCommandSet(i.c)
logger.Debug("select ISD")
if err = cmdSet.Select(); err != nil {
logger.Info("select ISD")
isd, err := cmdSet.Select()
if err != nil {
logger.Error("select failed", "error", err)
return err
}
logger.Debug("isd retrieved", "isd", hexutils.BytesToHexWithSpaces(isd))
logger.Debug("opening secure channel")
logger.Info("opening secure channel")
if err = cmdSet.OpenSecureChannel(); err != nil {
logger.Error("open secure channel failed", "error", err)
return err
}
logger.Debug("delete old version (if present)")
logger.Info("delete old version (if present)")
if err = cmdSet.DeleteKeycardInstancesAndPackage(); err != nil {
logger.Error("delete keycard instances and package failed", "error", err)
return err
}
logger.Debug("loading package")
logger.Info("loading package")
callback := func(index, total int) {
logger.Debug(fmt.Sprintf("loading %d/%d", index+1, total))
}
@ -54,14 +58,13 @@ func (i *Installer) Install(capFile *os.File, overwriteApplet bool) (err error)
return err
}
logger.Debug("installing NDEF applet")
ndefRecord := hexutils.HexToBytes("0024d40f12616e64726f69642e636f6d3a706b67696d2e7374617475732e657468657265756d")
logger.Info("installing NDEF applet")
if err = cmdSet.InstallNDEFApplet(ndefRecord); err != nil {
logger.Error("installing NDEF applet failed", "error", err)
return err
}
logger.Debug("installing Keycard applet")
logger.Info("installing Keycard applet")
if err = cmdSet.InstallKeycardApplet(); err != nil {
logger.Error("installing Keycard applet failed", "error", err)
return err