Sha256: 3185d4f3a37ebc2867aa9978011fafb1d213efed3a5884da639a9ae0f91b5aca

Contents?: true

Size: 730 Bytes

Versions: 39

Compression:

Stored size: 730 Bytes

Contents

require "rubygems"
require "cabin"
require "logger"

def fib(n)
  return 1 if n < 2
  return fib(n - 1) + fib(n - 2)
end

# Logging::... is something I'm implemented and experimenting with.
@logger = Cabin::Channel.new

# A logging channel can have any number of subscribers.
# Any subscriber is simply expected to respond to '<<' and take a single
# argument (the event)
# Special case of stdlib Logger instances that are wrapped smartly to 
# log JSON and call the right Logger method (Logger#info, etc).
@logger.subscribe(Logger.new(STDOUT))

# You can store arbitrary key-value pairs in the logging channel. 
# These are emitted with every event.

n = 35
@logger[:input] = n
@logger.time("fibonacci latency") do
  fib(n)
end

Version data entries

39 entries across 37 versions & 6 rubygems

Version Path
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/cabin-0.8.1/examples/fibonacci-timing.rb
logstash-filter-zabbix-0.1.1 vendor/bundle/jruby/1.9/gems/cabin-0.8.1/examples/fibonacci-timing.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/cabin-0.8.1/examples/fibonacci-timing.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/cabin-0.8.1/examples/fibonacci-timing.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/cabin-0.8.1/examples/fibonacci-timing.rb
cabin-0.9.0 examples/fibonacci-timing.rb
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/cabin-0.7.1/examples/fibonacci-timing.rb
cabin-0.8.1 examples/fibonacci-timing.rb
cabin-0.8.0 examples/fibonacci-timing.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/cabin-0.7.2/examples/fibonacci-timing.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/cabin-0.7.1/examples/fibonacci-timing.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-codec-json-2.0.3/vendor/gems/cabin-0.7.2/examples/fibonacci-timing.rb
logstash-codec-json-2.0.3 vendor/gems/cabin-0.7.2/examples/fibonacci-timing.rb
cabin-0.7.2 examples/fibonacci-timing.rb
logstash-input-beats-0.9.2 vendor/jruby/1.9/gems/cabin-0.7.1/examples/fibonacci-timing.rb
logstash-input-beats-0.9.1 vendor/jruby/1.9/gems/cabin-0.7.1/examples/fibonacci-timing.rb
cabin-0.7.1 examples/fibonacci-timing.rb
cabin-0.6.1 examples/fibonacci-timing.rb
cabin-0.6.0 examples/fibonacci-timing.rb
cabin-0.5.0 examples/fibonacci-timing.rb