Module: AWS::S3::Logging::Management::ClassMethods
- Defined in:
- lib/aws-matt/s3/logging.rb
Instance Method Summary collapse
-
#disable_logging_for(name = nil) ⇒ Object
(also: #disable_logging)
Disables logging for the bucket named
name. -
#enable_logging_for(name = nil, options = {}) ⇒ Object
(also: #enable_logging)
Enables logging for the bucket named
name. -
#logging_enabled_for?(name = nil) ⇒ Boolean
(also: #logging_enabled?)
Returns true if logging has been enabled for the bucket named
name. -
#logging_status_for(name = nil, status = nil) ⇒ Object
(also: #logging_status)
Returns the logging status for the bucket named
name. -
#logs_for(name = nil, options = {}) ⇒ Object
(also: #logs)
Returns the collection of logs for the bucket named
name.
Instance Method Details
#disable_logging_for(name = nil) ⇒ Object Also known as: disable_logging
Disables logging for the bucket named name.
248 249 250 |
# File 'lib/aws-matt/s3/logging.rb', line 248 def disable_logging_for(name = nil) logging_status(bucket_name(name), Status.new) end |
#enable_logging_for(name = nil, options = {}) ⇒ Object Also known as: enable_logging
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-.
238 239 240 241 242 243 244 |
# File 'lib/aws-matt/s3/logging.rb', line 238 def enable_logging_for(name = nil, = {}) name = bucket_name(name) = {'target_bucket' => name, 'target_prefix' => 'log-'} = .merge() grant_logging_access_to_target_bucket(['target_bucket']) logging_status(name, Status.new()) end |
#logging_enabled_for?(name = nil) ⇒ Boolean Also known as: logging_enabled?
Returns true if logging has been enabled for the bucket named name.
254 255 256 |
# File 'lib/aws-matt/s3/logging.rb', line 254 def logging_enabled_for?(name = nil) logging_status(bucket_name(name)).logging_enabled? end |
#logging_status_for(name = nil, status = nil) ⇒ Object Also known as: logging_status
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'
224 225 226 227 228 229 230 231 232 |
# File 'lib/aws-matt/s3/logging.rb', line 224 def logging_status_for(name = nil, status = nil) if name.is_a?(Status) status = name name = nil end path = path(name) << '?logging' status ? put(path, {}, status.to_xml) : Status.new(get(path).parsed) end |
#logs_for(name = nil, options = {}) ⇒ Object Also known as: logs
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.
264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/aws-matt/s3/logging.rb', line 264 def logs_for(name = nil, = {}) if name.is_a?(Hash) = name name = nil end name = bucket_name(name) logging_status = logging_status_for(name) return [] unless logging_status.logging_enabled? objects(logging_status.target_bucket, .merge(:prefix => logging_status.target_prefix)).map do |log_object| Log.new(log_object) end end |