Module: Collins::Api::Logging
Defined Under Namespace
Modules: Severity
Constant Summary
Constants included from Util::Logging
Util::Logging::DEFAULT_LOG_FORMAT
Instance Method Summary collapse
-
#all_logs(options = {}) ⇒ Object
Same as logs but for all assets.
-
#log!(asset_or_tag, message, level = nil) ⇒ Boolean
Log a message against an asset using the specified level.
-
#logs(asset_or_tag, options = {}) ⇒ Array<OpenStruct>
Fetch logs for an asset according to the options specified.
-
#search_logs(options = {}) ⇒ Object
new solr interface.
Methods included from Util
#deep_copy_hash, #get_asset_or_tag, included, #require_non_empty, #require_that, #stringify_hash, #symbolize_hash
Methods included from Util::Logging
Instance Method Details
#all_logs(options = {}) ⇒ Object
Same as logs but for all assets
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/collins/api/logging.rb', line 126 def all_logs = {} parameters = ().merge( :filter => get_option(:filter, , nil) ) parameters = select_non_empty_parameters parameters logger.debug("Fetching logs for all assets with parameters #{parameters.inspect}") http_get("/api/assets/logs", parameters) 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 |
#log!(asset_or_tag, message, level = nil) ⇒ Boolean
Log a message against an asset using the specified level
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/collins/api/logging.rb', line 64 def log! asset_or_tag, , level = nil asset = get_asset_or_tag asset_or_tag parameters = { :message => , :type => log_level_from_string(level) } parameters = select_non_empty_parameters parameters logger.debug("Logging to #{asset.tag} with parameters #{parameters.inspect}") http_put("/api/asset/#{asset.tag}/log", parameters, asset.location) do |response| parse_response response, :as => :status, :expects => 201 end end |
#logs(asset_or_tag, options = {}) ⇒ Array<OpenStruct>
Note:
To exclude a level via a filter it must be prepended with a ‘!`
Fetch logs for an asset according to the options specified
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/collins/api/logging.rb', line 91 def logs asset_or_tag, = {} asset = get_asset_or_tag asset_or_tag all_tag = .delete(:all_tag) if all_tag && all_tag.to_s.downcase == asset.tag.to_s.downcase then return all_logs end parameters = ().merge( :filter => get_option(:filter, , 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 |
#search_logs(options = {}) ⇒ Object
new solr interface
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/collins/api/logging.rb', line 110 def search_logs = {} parameters = ().merge( :query => get_option(:query, , nil), :sortField => get_option(:sortField, , 'ID') ) parameters = select_non_empty_parameters parameters logger.debug("Fetching logs for all assets with parameters #{parameters.inspect}") http_get("/api/assets/logs/search", parameters) 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 |