2 Commits 24bb263084 ... 792927983d

Author SHA1 Message Date
  Umnik 792927983d No logger 2 years ago
  Umnik 4fe70b6fe5 No logger 2 years ago

+ 0 - 29
common/logger/logger.go

@@ -1,29 +0,0 @@
-package logger
-
-import "log"
-
-//Logger uses for logging
-//goland:noinspection GoUnnecessarilyExportedIdentifiers
-type Logger struct {
-	l *log.Logger
-}
-
-//NewLogger creates Logger
-func NewLogger(prefix string) Logger {
-	l := log.New(log.Writer(), prefix, log.Lshortfile|log.Lmsgprefix)
-	return Logger{l: l}
-}
-
-//Fatal prints fatal error and closes application
-func (l Logger) Fatal(err error) {
-	if err != nil {
-		l.l.Fatal(err)
-	}
-}
-
-//Warn prints warning
-func (l Logger) Warn(err error) {
-	if err != nil {
-		l.l.Print(err)
-	}
-}

+ 1 - 7
common/utils/utils.go

@@ -4,12 +4,8 @@ import (
 	"os"
 	"strconv"
 	"strings"
-
-	"notabug.org/Umnik/GoAndroidSDK/common/logger"
 )
 
-var wLog = logger.NewLogger("[WARNING] ")
-
 //TwoSpotValue returns value from "key:value" line
 func TwoSpotValue(line string) string {
 	return strings.TrimSpace(strings.SplitN(line, ":", 2)[1])
@@ -24,7 +20,6 @@ func RemoveQuoteMark(line string) string {
 func IntExtractor(val string) int {
 	res, err := strconv.Atoi(val)
 	if err != nil {
-		wLog.Warn(err)
 		return -1
 	}
 	return res
@@ -42,13 +37,12 @@ func RemoveBraces(line string) string {
 func BoolExtractor(val string) bool {
 	res, err := strconv.ParseBool(val)
 	if err != nil {
-		wLog.Warn(err)
 		return false
 	}
 	return res
 }
 
-//DirNamesIfDirs returns subdirs in directory
+//DirNamesIfDirs returns subdirectories in directory
 func DirNamesIfDirs(dirPath string) ([]string, error) {
 	dirEntries, err := os.ReadDir(dirPath)
 	if err != nil {

+ 3 - 7
sdk/buildTools/aapt/tools.go

@@ -6,19 +6,15 @@ import (
 	"path/filepath"
 	"strings"
 
-	"notabug.org/Umnik/GoAndroidSDK/common/logger"
 	"notabug.org/Umnik/GoAndroidSDK/common/utils"
 )
 
-var wLog = logger.NewLogger("[WARNING] ")
-
 func findApkSignature(apkFile string) ([]string, error) {
 	zipReader, err := zip.OpenReader(apkFile)
 	if err != nil {
 		return nil, err
 	}
 	defer func(f *zip.ReadCloser) {
-		wLog.Warn(f.Close())
 	}(zipReader)
 
 	var (
@@ -131,11 +127,11 @@ func resStringValue(line string) (result [2]string) {
 	return
 }
 
-var log = logger.NewLogger("[FATAL] ")
-
 func aaptFromPath(dirPath string) Aapt {
 	binPath := filepath.Join(dirPath, "aapt")
 	_, err := os.Stat(binPath)
-	log.Fatal(err)
+	if err != nil {
+		panic(err)
+	}
 	return Aapt{binPath: binPath}
 }

+ 3 - 8
sdk/buildTools/apksigner/tools.go

@@ -1,29 +1,24 @@
 package apksigner
 
 import (
-	"fmt"
 	"os"
 	"path/filepath"
 	"strconv"
 	"strings"
 
-	"notabug.org/Umnik/GoAndroidSDK/common/logger"
 	"notabug.org/Umnik/GoAndroidSDK/common/utils"
 )
 
 func getSingerNumber(line string) int {
 	if !strings.Contains(line, "Signer #") {
-		log.Warn(fmt.Errorf("signer number not found"))
 		return -1
 	}
 	part := strings.SplitN(line, " ", 3)[1]
 	if !strings.HasPrefix(part, "#") {
-		log.Warn(fmt.Errorf("expected \"#X\" but got \"%s\"", part))
 		return -1
 	}
 	res, err := strconv.Atoi(strings.Trim(part, "#"))
 	if err != nil {
-		log.Warn(err)
 		return -1
 	}
 	return res
@@ -43,11 +38,11 @@ func getNotProtectedFile(line string) string {
 	return strings.TrimSpace(strings.SplitN(utils.TwoSpotValue(line), " ", 2)[0])
 }
 
-var log = logger.NewLogger("[FATAL] ")
-
 func apksignerFromPath(dirPath string) Apksigner {
 	binPath := filepath.Join(dirPath, "apksigner")
 	_, err := os.Stat(binPath)
-	log.Fatal(err)
+	if err != nil {
+		panic(err)
+	}
 	return Apksigner{binPath: binPath}
 }

+ 3 - 5
sdk/buildTools/zipalign/tools.go

@@ -3,15 +3,13 @@ package zipalign
 import (
 	"os"
 	"path/filepath"
-
-	"notabug.org/Umnik/GoAndroidSDK/common/logger"
 )
 
-var log = logger.NewLogger("[FATAL] ")
-
 func zipalignFromPath(dirPath string) Zipalign {
 	binPath := filepath.Join(dirPath, "zipalign")
 	_, err := os.Stat(binPath)
-	log.Fatal(err)
+	if err != nil {
+		panic(err)
+	}
 	return Zipalign{binPath: binPath}
 }

+ 7 - 5
sdk/commands.go

@@ -6,7 +6,7 @@ import (
 	"sort"
 
 	"notabug.org/Umnik/GoAndroidSDK/sdk/platforms"
-	system_images "notabug.org/Umnik/GoAndroidSDK/sdk/systemImages"
+	"notabug.org/Umnik/GoAndroidSDK/sdk/systemImages"
 )
 
 //RootDir returns path to SDK dir
@@ -30,7 +30,9 @@ func (s SDK) BuildTools() string {
 //LastBuildToolsVersion returns path to last available version in "build-tools" dir
 func (s SDK) LastBuildToolsVersion() string {
 	dirEntries, err := os.ReadDir(s.BuildTools())
-	log.Fatal(err)
+	if err != nil {
+		panic(err)
+	}
 	versions := make([]string, len(dirEntries))
 
 	for i := range dirEntries {
@@ -64,8 +66,8 @@ func (s SDK) SystemImages() string {
 	return path.Join(s.RootDir(), "systemImages")
 }
 
-//SpecificSystemImage returns path to specific system image catalog
+//SpecificSystemImageType returns path to specific system image catalog
 //goland:noinspection GoUnnecessarilyExportedIdentifiers
-func (s SDK) SpecificSystemImage(image system_images.SystemImage) string {
-	return path.Join(s.SystemImages(), image)
+func (s SDK) SpecificSystemImageType(image systemImages.SystemImage, imageType systemImages.SystemImageType) string {
+	return path.Join(s.SystemImages(), image, imageType)
 }

+ 1 - 5
sdk/creators.go

@@ -3,12 +3,8 @@ package sdk
 import (
 	"fmt"
 	"os"
-
-	"notabug.org/Umnik/GoAndroidSDK/common/logger"
 )
 
-var log = logger.NewLogger("[FATAL] ")
-
 //NewSDKFromPath creates SDK from path to dir
 //goland:noinspection GoUnnecessarilyExportedIdentifiers
 func NewSDKFromPath(dirPath string) SDK {
@@ -30,6 +26,6 @@ func NewSDK() SDK {
 			return NewSDKFromEnv(key)
 		}
 	}
-	log.Fatal(fmt.Errorf("following environments was checked: %s. They are not set", environments))
+	panic(fmt.Errorf("following environments was checked: %s. They are not set", environments))
 	return SDK{} // just for compiler
 }

+ 3 - 2
sdk/platformTools/adb/device/creators.go

@@ -10,8 +10,9 @@ import (
 //ConnectedDevices returns available Device as array
 func ConnectedDevices(adbPath string) []Device {
 	data, err := exec.Command(adbPath, "devices", "-l").CombinedOutput()
-	log.Fatal(err)
-
+	if err != nil {
+		panic(err)
+	}
 	start := false
 	devices := make([]Device, 0)
 

+ 0 - 5
sdk/platformTools/adb/device/tools.go

@@ -1,5 +0,0 @@
-package device
-
-import "notabug.org/Umnik/GoAndroidSDK/common/logger"
-
-var log = logger.NewLogger("[FATAL] ")

+ 0 - 0
sdk/platformTools/adb/tools.go


Some files were not shown because too many files changed in this diff