Top Level Namespace

Defined Under Namespace

Modules: Logworm Classes: LogwormCompute, LogwormTail

Instance Method Summary collapse

Instance Method Details

#lw_list_logsObject

Returns an array with information about the logging tables in the database Each element in the array has;

:tablename   => The name of the logging table
:url         => The URL for POSTing new log entries
:last_write  => Datetime of last entry
:rows        => Count of entries

raises Logworm::DatabaseException, Logworm::ForbiddenAccessException, Logworm::InvalidQueryException or just a regular Exception if it cannot find the URL to the logging database



59
60
61
62
# File 'lib/logworm_client_amqp.rb', line 59

def lw_list_logs
  db = Logworm::DB.from_config_or_die                                   # Establish connection to DB
  db.tables                                                             # Call tables command
end

#lw_log(logname, values) ⇒ Object



7
8
9
# File 'lib/logworm_client_amqp.rb', line 7

def lw_log (logname, values)
  Logworm::Logger.log(logname, values)
end

#lw_query(logname, query = {}) ⇒ Object

Perform a query against the logworm server

Requires a log table, and a query The query can be provided as a JSON string, following the syntax described in www.logworm.com/docs/query

or as a Hash of options, with the following keys (all optional)
 :fields             => String with a comma-separated list of fields (quoted or not), or Array of Strings
 :aggregate_function => String
 :aggregate_argument => String
 :aggregate_group    => String with a comma-separated list of fields (quoted or not), or Array of Strings
 :conditions         => String with comma-separated conditions (in MongoDB syntax), or Array of Strings
 :start              => String or Integer (for year)
 :end                => String or Integer (for year)
 :limit              => String or Integer

See Logworm::QueryBuilder

Returns Hash with

id              ==> id of the query
query_url       ==> URL to GET information about the query
results_url     ==> URL to GET the results for the query
created         ==> First creation of the query
updated         ==> most recent update of the query and/or its results
expires         ==> until that datime, the query won't be rerun against the database
execution_time  ==> time in ms to run the query
results         ==> array of hashmaps. Each element corresponds to a log entry, with its fields

raises Logworm::DatabaseException, Logworm::ForbiddenAccessException, Logworm::InvalidQueryException or just a regular Exception if it cannot find the URL to the logging database



41
42
43
44
45
46
# File 'lib/logworm_client_amqp.rb', line 41

def lw_query(logname, query = {}) 
  db = Logworm::DB.from_config_or_die                                   # Establish connection to DB
  query = Logworm::QueryBuilder.new(query).to_json if query.is_a? Hash  # Turn query into proper JSON string
  query_data = db.query(logname, query)                                 # POST to create query
  db.results(query_data["results_uri"])                                 # GET from query's results uri
end