Class: Stackify::LoggerClient
Constant Summary collapse
- PERIOD =
1
Instance Method Summary collapse
-
#initialize ⇒ LoggerClient
constructor
A new instance of LoggerClient.
- #log(level, msg) ⇒ Object
- #log_exception(level = :error, ex) ⇒ Object
Constructor Details
#initialize ⇒ LoggerClient
Returns a new instance of LoggerClient.
5 6 7 |
# File 'lib/stackify/logger_client.rb', line 5 def initialize @@errors_governor = Stackify::ErrorsGovernor.new end |
Instance Method Details
#log(level, msg) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/stackify/logger_client.rb', line 9 def log level, msg Stackify::Utils. Stackify::MODES[:logging] do if acceptable? level, msg && Stackify.working? worker = Stackify::AddMsgWorker.new task = level, msg worker.async_perform PERIOD, task end end end |
#log_exception(level = :error, ex) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/stackify/logger_client.rb', line 19 def log_exception level= :error, ex if ex.is_a?(Stackify::StackifiedError) Stackify::Utils. Stackify::MODES[:logging] do if acceptable? level, ex. && Stackify.working? if @@errors_governor.can_send? ex worker = Stackify::AddMsgWorker.new task = log_exception_task level, ex worker.async_perform PERIOD, task else Stackify.internal_log :warn, "LoggerClient: logging of exception with message \"#{ex.message}\" is skipped - flood_limit is exceeded" end end end else Stackify.log_internal_error 'LoggerClient: log_exception should get StackifiedError object' end end |