Skip to content

Instantly share code, notes, and snippets.

@davydotcom
Last active December 13, 2015 18:38
Show Gist options
  • Save davydotcom/4956601 to your computer and use it in GitHub Desktop.
Save davydotcom/4956601 to your computer and use it in GitHub Desktop.
require 'oohlalog'
Oohlalog.api_key = "MY API KEY HERE"
logger = Oohlalog::Logger.new(10)
logger.add(Oohlalog::WARN,"My warning Message","My App Name")
require "oohlalog/version"
module Oohlalog
class << self
attr_accessor :api_key, :host
def initalize
@host = ""
@api_key = nil
end
end
class Logger
def initialize(buffer_size=10)
@buffer_size = buffer_size
@buffer = []
end
def add(severity, message, progname)
@buffer << {severity: severity, message: message, progname: progname}
if @buffer.size >= @buffer_size
flush_buffer
end
end
def flush_buffer
Thread.new do
while @buffer.size > 0
entry = @buffer.shift
# TODO : Send to OohlaLogger API
puts entry
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment