查看桶日志

更新时间: 2019-03-14 10:05

您可以通过ObsClient.GetBucketLoggingConfiguration查看桶日志配置。以下代码展示了如何查看桶日志配置:

  1. // 引入依赖包
  2. import (
  3. "fmt"
  4. "obs"
  5. )
  6.  
  7. var ak = "*** Provide your Access Key ***"
  8. var sk = "*** Provide your Secret Key ***"
  9. var endpoint = "https://your-endpoint"
  10.  
  11. // 创建ObsClient结构体
  12. var obsClient, _ = obs.New(ak, sk, endpoint)
  13.  
  14. func main() {
  15. output, err := obsClient.GetBucketLoggingConfiguration("bucketname")
  16. if err == nil {
  17. fmt.Printf("TargetBucket:%s, TargetPrefix:%s\n", output.TargetBucket, output.TargetPrefix)
  18. for index, grant := range output.TargetGrants {
  19. fmt.Printf("Grant[%d]-Type:%s, ID:%s, URI:%s, Permission:%s\n", index, grant.Grantee.Type, grant.Grantee.ID, grant.Grantee.URI, grant.Permission)
  20. }
  21. } else if obsError, ok := err.(obs.ObsError); ok {
  22. fmt.Printf("Code:%s\n", obsError.Code)
  23. fmt.Printf("Message:%s\n", obsError.Message)
  24. }
  25. }

父主题:设置访问日志