support/ruby/collins-client/lib/collins/api/logging.rb
def logs asset_or_tag, options = {}
      asset = get_asset_or_tag asset_or_tag
      all_tag = options.delete(:all_tag)
      if all_tag && all_tag.to_s.downcase == asset.tag.to_s.downcase then
        return all_logs options
      end
      parameters = get_page_options(options).merge(
        :filter => get_option(:filter, options, nil)
      )
      parameters = select_non_empty_parameters parameters
      logger.debug("Fetching logs for #{asset.tag} with parameters #{parameters.inspect}")
      http_get("/api/asset/#{asset.tag}/logs", parameters, asset.location) do |response|
        parse_response response, :as => :paginated, :default => [], :raise => strict?, :expects => 200 do |json|
          json.map{|j| OpenStruct.new(symbolize_hash(j))}
        end
      end
    end
# Fetch logs for an asset according to the options specified
# @example
#   :filter => "EMERGENCY;ALERT" # Only retrieve emergency and alert messages
#   :filter => "!DEBUG;!NOTE"    # Only retrieve non-debug/non-notes
# @param [String,Collins::Asset] asset_or_tag
# @param [Hash] options query options
# @option options [Fixnum] :page (0) Page of results
# @option options [Fixnum] :size (25) Number of results to retrieve
# @option options [String] :sort (DESC) Sort ordering for results
# @option options [String] :filter Semicolon separated list of severity levels to include or exclude
# @option options [String] :all_tag If specified, and asset tag is set to :all_tag, proxy to the all_logs method
# @note To exclude a level via a filter it must be prepended with a `!`
# @return [Array<OpenStruct>] Array of log objects
# @raise [Collins::UnexpectedResponseError] on a non-200 response
Fetch logs for an asset according to the options specified
Fetch logs for an asset according to the options specified
def logs asset_or_tag, options = {}
      asset = get_asset_or_tag asset_or_tag
      all_tag = options.delete(:all_tag)
      if all_tag && all_tag.to_s.downcase == asset.tag.to_s.downcase then
        return all_logs options
      end
      parameters = get_page_options(options).merge(
        :filter => get_option(:filter, options, nil)
      )
      parameters = select_non_empty_parameters parameters
      logger.debug("Fetching logs for #{asset.tag} with parameters #{parameters.inspect}")
      http_get("/api/asset/#{asset.tag}/logs", parameters, asset.location) do |response|
        parse_response response, :as => :paginated, :default => [], :raise => strict?, :expects => 200 do |json|
          json.map{|j| OpenStruct.new(symbolize_hash(j))}
        end
      end
    end
def logs asset_or_tag , options = { } asset = get_asset_or_tag asset_or_tag all_tag = options . delete ( :all_tag ) if all_tag && all_tag . to_s . downcase == asset . tag . to_s . downcase then return all_logs options end parameters = get_page_options ( options ) . merge ( :filter => get_option ( :filter , options , nil ) ) parameters = select_non_empty_parameters parameters logger . debug ( "Fetching logs for #{asset.tag} with parameters #{parameters.inspect}" ) http_get ( "/api/asset/#{asset.tag}/logs" , parameters , asset . location ) do | response | parse_response response , :as => :paginated , :default => [ ] , :raise => strict? , :expects => 200 do | json | json . map { | j | OpenStruct . new ( symbolize_hash ( j ) ) } end end end
Fetch logs for an asset according to the options specified
Fetch logs for an asset according to the options specified
Array of log objects
Array of log objects
Array<OpenStruct>
[Collins::UnexpectedResponseError] on a non-200 response
[ Collins :: UnexpectedResponseError ] on a non - 200 response
asset_or_tag
options
:all_tag If specified, and asset tag is set to :all_tag, proxy to the all_logs method
: all_tag If specified and asset tag is set to : all_tag proxy to the all_logs method
options query options
options query options
example
:filter => "EMERGENCY;ALERT" # Only retrieve emergency and alert messages :filter => "!DEBUG;!NOTE" # Only retrieve non-debug/non-notes
: filter = > " EMERGENCY ; ALERT " # Only retrieve emergency and alert messages : filter = > " !DEBUG ; !NOTE " # Only retrieve non - debug / non - notes
note
To exclude a level via a filter it must be prepended with a `!`
To exclude a level via a filter it must be prepended with a ` ! `