Module: Tracebin::Agent
- Defined in:
- lib/tracebin/agent.rb
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.storage ⇒ Object
Returns the value of attribute storage.
Class Method Summary collapse
- .configure {|config| ... } ⇒ Object
- .init_logger ⇒ Object
- .log_level ⇒ Object
- .reset ⇒ Object
- .start! ⇒ Object
- .started? ⇒ Boolean
- .stop! ⇒ Object
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
12 13 14 |
# File 'lib/tracebin/agent.rb', line 12 def config @config end |
.logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/tracebin/agent.rb', line 12 def logger @logger end |
.storage ⇒ Object
Returns the value of attribute storage.
12 13 14 |
# File 'lib/tracebin/agent.rb', line 12 def storage @storage end |
Class Method Details
.configure {|config| ... } ⇒ Object
90 91 92 |
# File 'lib/tracebin/agent.rb', line 90 def self.configure yield config end |
.init_logger ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/tracebin/agent.rb', line 51 def init_logger if defined? ::Rails @logger = ::Rails.logger else @logger ||= Logger.new(STDOUT) @logger.level = log_level end @logger end |
.log_level ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/tracebin/agent.rb', line 62 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 |
.reset ⇒ Object
86 87 88 |
# File 'lib/tracebin/agent.rb', line 86 def self.reset @config = Config.new end |
.start! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tracebin/agent.rb', line 14 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 |
.started? ⇒ Boolean
47 48 49 |
# File 'lib/tracebin/agent.rb', line 47 def started? @started end |
.stop! ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tracebin/agent.rb', line 31 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 |