Module | AWS::S3::Logging::Management::ClassMethods |
In: |
lib/aws/s3/logging.rb
|
Disables logging for the bucket named name.
# File lib/aws/s3/logging.rb, line 252 252: def disable_logging_for(name = nil) 253: logging_status(bucket_name(name), Status.new) 254: end
Enables logging for the bucket named name. You can specify what bucket to log to with the ‘target_bucket‘ option as well as what prefix to add to the log files with the ‘target_prefix‘ option. Unless you specify otherwise, logs will be delivered to the same bucket that is being logged and will be prefixed with log-.
# File lib/aws/s3/logging.rb, line 242 242: def enable_logging_for(name = nil, options = {}) 243: name = bucket_name(name) 244: default_options = {'target_bucket' => name, 'target_prefix' => 'log-'} 245: options = default_options.merge(options) 246: grant_logging_access_to_target_bucket(options['target_bucket']) 247: logging_status(name, Status.new(options)) 248: end
Returns true if logging has been enabled for the bucket named name.
# File lib/aws/s3/logging.rb, line 258 258: def logging_enabled_for?(name = nil) 259: logging_status(bucket_name(name)).logging_enabled? 260: end
Returns the logging status for the bucket named name. From the logging status you can determine the bucket logs are delivered to and what the bucket object‘s keys are prefixed with. For more information see the Logging::Status class.
Bucket.logging_status_for 'marcel'
# File lib/aws/s3/logging.rb, line 228 228: def logging_status_for(name = nil, status = nil) 229: if name.is_a?(Status) 230: status = name 231: name = nil 232: end 233: 234: path = path(name) << '?logging' 235: status ? put(path, {}, status.to_xml) : Status.new(get(path).parsed) 236: end
Returns the collection of logs for the bucket named name.
Bucket.logs_for 'marcel'
Accepts the same options as Bucket.find, such as :max_keys and :marker.
# File lib/aws/s3/logging.rb, line 268 268: def logs_for(name = nil, options = {}) 269: if name.is_a?(Hash) 270: options = name 271: name = nil 272: end 273: 274: name = bucket_name(name) 275: logging_status = logging_status_for(name) 276: return [] unless logging_status.logging_enabled? 277: objects(logging_status.target_bucket, options.merge(:prefix => logging_status.target_prefix)).map do |log_object| 278: Log.new(log_object) 279: end 280: end