Class: Generic
Overview
Generic Logger
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Generic
constructor
A new instance of Generic.
- #log(message) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Generic
Returns a new instance of Generic.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/botanalytics/generic.rb', line 7 def initialize(params = {}) super(params) @async = params.fetch(:async, false) informs("Logging enabled for #{self.class.name}...") if @async require 'concurrent' @executor_service = Concurrent::ThreadPoolExecutor.new( min_threads: 1, max_threads: Concurrent.processor_count * 2, max_queue: Concurrent.processor_count * 1000, fallback_policy: :caller_runs ) informs("Mode: Async...") end end |
Instance Method Details
#log(message) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/botanalytics/generic.rb', line 24 def log() validation = validate() if validation[:ok] informs("Logging messages...") informs() if @async @executor_service.post do submits() end else submits() end else fails(validation[:err], validation[:reason], ) end end |