Project

logplex

0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
Publish and Consume Logplex messages
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0

Runtime

>= 0
>= 0
 Project Readme

Logplex

Publish and Consume Logplex messages

Logplex is the Heroku log router, and can be found here.

Publishing messages

publisher = Logplex::Publisher.new(logplex_url)
publisher.publish("There's a lady who's sure, all that glitters is gold",
                   process: 'worker.2', host: 'some-host')

Passing an array of messages to the #publish method will publish them all in one request, so some latency optimization is possible:

publisher.publish [ "And as we wind on down the road",
                    "Our shadows taller than our soul",
                    "There walks a lady we all know",
                    "Who shines white light and wants to show"]

The message can also be passed in the form of a Hash, in which case it is formatted as machine readble key/value pairs suitable for metrics collection, eg: log2viz

publisher.publish { vocals: 'Robert Plant', guitar: 'Jimmy Page' }
# produces the message: vocals='Robert Plant' guitar='Jimmy Page'

Consuming messages

TBD

Configuration

You can configure default values for logplex message posting:

Logplex.configure do |config|
  config.logplex_url     = 'https://logplex.example.com/logs'
  config.process         = 'stats'
  config.host            = 'host'
  config.publish_timeout = 2
end

In the example above, it is now not not necessary to specify a logplex URL, process or host when getting a hold of a publisher and publishing messages:

publisher = Logplex::Publisher.new
publisher.publish "And she's buying a stairway to heaven"

License

Copyright (c) Harold Giménez. Released under the terms of the MIT License found in the LICENSE file.