Class | AWS::Core::LogFormatter |
In: |
lib/aws/core/log_formatter.rb
|
Parent: | Object |
Log formatters receive a {AWS::Core::Response} object and return a log message. When you construct a {LogFormatter}, you provide a pattern string with substitutions.
pattern = '[REQUEST :http_status_code] :service :operation :duration' formatter = AWS::Core::LogFormatter.new(pattern) formatter.format(response) #=> '[AWS 200] EC2 get_bucket 0.0352'
AWS.config provides a {LogFormatter.default} log formatter. You can repace this formatter by building your own and then passing it to {AWS.config}.
pattern = '[REQUEST :http_status_code] :service :operation :duration' AWS.config(:log_formatter => AWS::Core::LogFormatter.new(pattern)
Instead of providing your own pattern, you can choose a canned log formatter.
AWS.config(:log_formatter => AWS::Core::LogFormatter.colored)
Here is the list of canned formatters.
You can put any of these placeholders into you pattern.
max_string_size | [R] | @return [Integer] |
pattern | [R] | @return [String] |
@param [String] pattern The log format pattern should be a string
and may contain any of the following placeholders: * +:service+ * +:region+ * +:operation+ * +:options+ * +:retry_count * +:duration+ * +:error_class+ * +:error_message+ * +:http_request_method+ * +:http_request_protocol+ * +:http_request_host+ * +:http_request_port+ * +:http_request_uri+ * +:http_request_body+ * +:http_request_headers+ * +:http_request_proxy_uri+ * +:http_response_status+ * +:http_response_headers+ * +:http_response_body+
@param [Hash] options
@option options [Integer] :max_string_size (1000)
The default log format with ANSI colors.
@example A sample of the colored format (sans the ansi colors).
[AWS SimpleEmailService 200 0.580066 0 retries] list_verified_email_addresses()
@return [LogFormatter]
A debug format that dumps most of the http request and response data.
@example A truncated sample of the debug format.
+------------------------------------------------------------------------------- | AWS us-east-1 SimpleEmailService list_verified_email_addresses 0.429189 0 retries +------------------------------------------------------------------------------- | REQUEST +------------------------------------------------------------------------------- | METHOD: POST | URL: https://email.us-east-1.amazonaws.com::443:/ | HEADERS: {"content-type"=>"application/x-www-form-urlencoded" ... | BODY: Action=ListVerifiedEmailAddresses&Timestamp= ... +------------------------------------------------------------------------------- | RESPONSE +------------------------------------------------------------------------------- | STATUS: 200 | HEADERS: {"x-amzn-requestid"=>["..."], ... | BODY: <ListVerifiedEmailAddressesResponse ...
@return [LogFormatter]
@example A sample of the default format.
[AWS SimpleEmailService 200 0.580066 0 retries] list_verified_email_addresses()
@return [LogFormatter]