Refactor logger (#1185)
* refactor: logger * refactor: logging * refactor: rename func * refactor: logging * refactor: logging format
This commit is contained in:
		@@ -19,6 +19,7 @@ import (
 | 
			
		||||
	"github.com/aws/aws-sdk-go/service/sts"
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	c "github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/logging"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"golang.org/x/xerrors"
 | 
			
		||||
@@ -50,7 +51,7 @@ func (w Writer) Write(rs ...models.ScanResult) error {
 | 
			
		||||
 | 
			
		||||
	ipv4s, ipv6s, err := util.IP()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		util.Log.Errorf("Failed to fetch scannedIPs. err: %+v", err)
 | 
			
		||||
		logging.Log.Warnf("Failed to get scannedIPs. err: %+v", err)
 | 
			
		||||
	}
 | 
			
		||||
	hostname, _ := os.Hostname()
 | 
			
		||||
 | 
			
		||||
@@ -114,7 +115,7 @@ func (w Writer) Write(rs ...models.ScanResult) error {
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return xerrors.Errorf("Failed to Marshal to JSON: %w", err)
 | 
			
		||||
		}
 | 
			
		||||
		util.Log.Infof("Uploading... %s", r.FormatServerName())
 | 
			
		||||
		logging.Log.Infof("Uploading... %s", r.FormatServerName())
 | 
			
		||||
		s3Key := renameKeyName(r.ServerUUID, r.Container)
 | 
			
		||||
		putObjectInput := &s3.PutObjectInput{
 | 
			
		||||
			Bucket: aws.String(tempCredential.S3Bucket),
 | 
			
		||||
@@ -126,7 +127,7 @@ func (w Writer) Write(rs ...models.ScanResult) error {
 | 
			
		||||
				tempCredential.S3Bucket, s3Key, err)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	util.Log.Infof("done")
 | 
			
		||||
	logging.Log.Infof("done")
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,8 +10,8 @@ import (
 | 
			
		||||
 | 
			
		||||
	"github.com/BurntSushi/toml"
 | 
			
		||||
	c "github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/logging"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/hashicorp/go-uuid"
 | 
			
		||||
	"golang.org/x/xerrors"
 | 
			
		||||
)
 | 
			
		||||
@@ -48,7 +48,7 @@ func ensure(servers map[string]c.ServerInfo, path string, scanResults models.Sca
 | 
			
		||||
				needsOverwrite = true
 | 
			
		||||
			} else if _, err := uuid.ParseUUID(id); err != nil {
 | 
			
		||||
				// if the UUID of the host is invalid, re-generate it
 | 
			
		||||
				util.Log.Warnf("UUID `%s` is invalid. Re-generate and overwrite", id)
 | 
			
		||||
				logging.Log.Warnf("UUID `%s` is invalid. Re-generate and overwrite", id)
 | 
			
		||||
				serverInfo.UUIDs[r.ServerName], err = generateFunc()
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					return false, err
 | 
			
		||||
@@ -74,7 +74,7 @@ func ensure(servers map[string]c.ServerInfo, path string, scanResults models.Sca
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			// re-generate
 | 
			
		||||
			util.Log.Warnf("UUID `%s` is invalid. Re-generate and overwrite", id)
 | 
			
		||||
			logging.Log.Warnf("UUID `%s` is invalid. Re-generate and overwrite", id)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Generate a new UUID and set to config and scanResult
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user