Sha256: 6bf158b42c210a6f4805999edbd2600ffce1460b5fce1f891697b06d694a1c6a
Contents?: true
Size: 1.88 KB
Versions: 3
Compression:
Stored size: 1.88 KB
Contents
require 'logger' require 'tracebin/subscribers' require 'tracebin/health_monitor' require 'tracebin/worker_process_monitor' require 'tracebin/storage' require 'tracebin/reporter' module Tracebin module Agent class << self attr_accessor :config, :storage, :logger def start! return if started? || !config.enabled logger.info "TRACEBIN: Starting Tracebin agent..." @subscribers = Subscribers.new @health_monitor = HealthMonitor.start @worker_process_monitor = WorkerProcessMonitor.start @reporter = Reporter.new(storage, config, logger) @reporter.start! @started = true logger.info "TRACEBIN: Tracebin agent started!" end def stop! return unless started? logger.info "TRACEBIN: Shutting down Tracebin agent..." @health_monitor.stop! @worker_process_monitor.stop! @reporter.stop! storage.unload @started = false logger.info "TRACEBIN: Tracebin agent stopped!" end def started? @started end def init_logger if defined? ::Rails @logger = ::Rails.logger else @logger ||= Logger.new(STDOUT) @logger.level = log_level end @logger end def log_level case config.log_level.downcase when 'debug' then Logger::DEBUG when 'info' then Logger::INFO when 'warn' then Logger::WARN when 'error' then Logger::ERROR when 'fatal' then Logger::FATAL else Logger::INFO end end end def self.logger @logger || init_logger end def self.storage @storage ||= ::Tracebin::Storage.new end def self.config @config ||= Config.new end def self.reset @config = Config.new end def self.configure yield config end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tracebin-0.0.11 | lib/tracebin/agent.rb |
tracebin-0.0.10 | lib/tracebin/agent.rb |
tracebin-0.0.9 | lib/tracebin/agent.rb |