github.com/qiniu/go-sdk/v7@v7.27.0/storagev2/uplog/uplog.go (about) 1 package uplog 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/qiniu/go-sdk/v7/internal/uplog" 8 ) 9 10 // UpApiVersion 表示上传接口的版本 11 type UpApiVersion = uplog.UpApiVersion 12 13 // UpType 表示上传类型 14 type UpType = uplog.UpType 15 16 const ( 17 // UpApiVersionV1 表示上传接口的版本 1 18 UpApiVersionV1 = uplog.UpApiVersionV1 19 // UpApiVersionV1 表示上传接口的版本 2 20 UpApiVersionV2 = uplog.UpApiVersionV2 21 // UpTypeForm 表示表单上传 22 UpTypeForm = uplog.UpTypeForm 23 // UpTypeResumableV1 表示分片上传 V1 24 UpTypeResumableV1 = uplog.UpTypeResumableV1 25 // UpTypeResumableV2 表示分片上传 V2 26 UpTypeResumableV2 = uplog.UpTypeResumableV2 27 ) 28 29 // WithBlock 用于记录一轮分片上传的日志 30 func WithBlock(ctx context.Context, upApiVersion UpApiVersion, fileSize, recoveredFrom uint64, targetBucket, targetKey, upToken string, handle func(context.Context) error) error { 31 return uplog.WithBlock(ctx, upApiVersion, fileSize, recoveredFrom, targetBucket, targetKey, upToken, handle) 32 } 33 34 // WithQuality 用于记录上传质量日志 35 func WithQuality(ctx context.Context, upType UpType, fileSize uint64, targetBucket, targetKey, upToken string, handle func(ctx context.Context, switchRegion func()) error) error { 36 return uplog.WithQuality(ctx, upType, fileSize, targetBucket, targetKey, upToken, handle) 37 } 38 39 // DisableUplog 禁止日志功能 40 func DisableUplog() { 41 uplog.DisableUplog() 42 } 43 44 // EnableUplog 启用日志功能 45 func EnableUplog() { 46 uplog.EnableUplog() 47 } 48 49 // IsUplogEnabled 判断日志功能是否启用 50 func IsUplogEnabled() bool { 51 return uplog.IsUplogEnabled() 52 } 53 54 // GetUplogMaxStorageBytes 获取日志最大存储容量 55 func GetUplogMaxStorageBytes() uint64 { 56 return uplog.GetUplogMaxStorageBytes() 57 } 58 59 // SetUplogMaxStorageBytes 设置日志最大存储容量 60 func SetUplogMaxStorageBytes(max uint64) { 61 uplog.SetUplogMaxStorageBytes(max) 62 } 63 64 // SetUplogFileBufferDirPath 设置日志文件缓存目录 65 func SetUplogFileBufferDirPath(path string) { 66 uplog.SetUplogFileBufferDirPath(path) 67 } 68 69 // SetFlushFileBufferInterval 设置日志文件缓存刷新间隔 70 func SetFlushFileBufferInterval(d time.Duration) { 71 uplog.SetWriteFileBufferInterval(d) 72 } 73 74 // GetWriteFileBufferInterval() 获取日志文件缓存刷新间隔 75 func GetWriteFileBufferInterval() time.Duration { 76 return uplog.GetWriteFileBufferInterval() 77 } 78 79 // FlushBuffer 刷新日志缓存 80 func FlushBuffer() error { 81 return uplog.FlushBuffer() 82 } 83 84 // GetUplogUrl 获取日志上传 URL 85 func GetUplogUrl() string { 86 return uplog.GetUplogUrl() 87 } 88 89 // SetUplogUrl 设置日志上传 URL 90 func SetUplogUrl(url string) { 91 uplog.SetUplogUrl(url) 92 }