From ff1c66e7ac31cc7eb4aef821fb21e0bdbcadeee7 Mon Sep 17 00:00:00 2001 From: cuixiaotian Date: Tue, 26 May 2020 15:19:07 +0800 Subject: [PATCH] fix log print --- helper/config.go | 6 +++--- package/access.logrotate | 2 +- package/yig.logrotate | 2 +- storage/backend_ceph.go | 13 +++++++------ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/helper/config.go b/helper/config.go index 67f0c10ad..37bf06789 100644 --- a/helper/config.go +++ b/helper/config.go @@ -112,8 +112,8 @@ func MarshalTOMLConfig() error { CONFIG.Region = c.Region CONFIG.Plugins = c.Plugins CONFIG.PiggybackUpdateUsage = c.PiggybackUpdateUsage - CONFIG.LogPath = logFilePathWithPid(c.LogPath) - CONFIG.AccessLogPath = logFilePathWithPid(c.AccessLogPath) + CONFIG.LogPath = c.LogPath + CONFIG.AccessLogPath = c.AccessLogPath CONFIG.AccessLogFormat = c.AccessLogFormat CONFIG.PanicLogPath = c.PanicLogPath CONFIG.PidFile = c.PidFile @@ -181,4 +181,4 @@ func logFilePathWithPid(rawPath string) string { parts := strings.Split(rawPath, "/") parts[len(parts)-1] = fmt.Sprintf("%d.%s", pid, parts[len(parts)-1]) return strings.Join(parts, "/") -} \ No newline at end of file +} diff --git a/package/access.logrotate b/package/access.logrotate index 88e05373b..190681eb6 100644 --- a/package/access.logrotate +++ b/package/access.logrotate @@ -1,5 +1,5 @@ compress -/var/log/yig/*.access.log { +/var/log/yig/access.log { daily rotate 7 missingok diff --git a/package/yig.logrotate b/package/yig.logrotate index 7d52d1541..6ff1f63cb 100755 --- a/package/yig.logrotate +++ b/package/yig.logrotate @@ -1,5 +1,5 @@ compress -/var/log/yig/*.yig.log { +/var/log/yig/yig.log { daily rotate 7 missingok diff --git a/storage/backend_ceph.go b/storage/backend_ceph.go index cb6a58f34..94aa72860 100644 --- a/storage/backend_ceph.go +++ b/storage/backend_ceph.go @@ -3,6 +3,10 @@ package storage import ( "crypto/md5" "encoding/hex" + "io" + "sync" + "time" + "github.com/journeymidnight/yig/api/datatype" "github.com/journeymidnight/yig/backend" "github.com/journeymidnight/yig/ceph" @@ -14,9 +18,6 @@ import ( "github.com/journeymidnight/yig/meta/types" "github.com/journeymidnight/yig/redis" "github.com/journeymidnight/yig/signature" - "io" - "sync" - "time" ) func New(metaCacheType int, enableDataCache bool, kms crypto.KMS) *YigStorage { @@ -75,7 +76,7 @@ func (yig *YigStorage) AppendObject(bucketName string, objectName string, creden initializationVector = objInfo.InitializationVector objSize = objInfo.Size storageClass = objInfo.StorageClass - helper.Logger.Println(20, "request append oid:", oid, "iv:", initializationVector, "size:", objSize) + helper.Logger.Info("request append oid:", oid, "iv:", initializationVector, "size:", objSize) } else { // New appendable object cephCluster, poolName = yig.pickClusterAndPool(bucketName, objectName, storageClass, size, true) @@ -89,7 +90,7 @@ func (yig *YigStorage) AppendObject(bucketName string, objectName string, creden return } } - helper.Logger.Println(20, "request first append oid:", oid, "iv:", initializationVector, "size:", objSize) + helper.Logger.Info("request first append oid:", oid, "iv:", initializationVector, "size:", objSize) } dataReader := io.TeeReader(limitedDataReader, md5Writer) @@ -149,7 +150,7 @@ func (yig *YigStorage) AppendObject(bucketName string, objectName string, creden result.LastModified = object.LastModifiedTime result.NextPosition = object.Size - helper.Logger.Println(20, "Append info.", "bucket:", bucketName, "objName:", objectName, "oid:", oid, + helper.Logger.Info("Append info.", "bucket:", bucketName, "objName:", objectName, "oid:", oid, "objSize:", object.Size, "bytesWritten:", bytesWritten, "storageClass:", storageClass) err = yig.MetaStorage.AppendObject(object, objInfo != nil) if err != nil {