Class: Coralogix::CoralogixLogger
- Inherits:
-
Object
- Object
- Coralogix::CoralogixLogger
- Defined in:
- lib/centralized_ruby_logger.rb
Instance Method Summary collapse
-
#configure(private_key, app_name, sub_system, type_name, force_compression) ⇒ boolean
Configure coralogix logger with customer specific values.
-
#debug_mode=(value) ⇒ Object
A setter for debug_mode.
-
#debug_mode? ⇒ boolean
A getter for debug_mode.
-
#disable_proxy=(value) ⇒ Object
A setter for disable_proxy.
-
#flush ⇒ Object
Flush all messages in buffer and send them immediately on the current thread.
-
#initialize(private_key, app_name, sub_system_name, debug = false, type_name = "Centralized Ruby", force_compression = false, proxy = {}, external_logger = nil) ⇒ CoralogixLogger
constructor
Constructor.
-
#log(severity, message, category = @category, named_args = {}) ⇒ Object
Log a message.
Constructor Details
#initialize(private_key, app_name, sub_system_name, debug = false, type_name = "Centralized Ruby", force_compression = false, proxy = {}, external_logger = nil) ⇒ CoralogixLogger
Constructor.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/centralized_ruby_logger.rb', line 11 def initialize private_key, app_name, sub_system_name, debug=false, type_name="Centralized Ruby", force_compression=false, proxy={}, external_logger=nil self.debug_mode=debug @category = CORALOGIX_CATEGORY @manager = LoggerManager.new proxy unless external_logger.nil? DebugLogger.enabled = true DebugLogger.external = true DebugLogger.logger = external_logger end configure(private_key, app_name, sub_system_name, type_name, force_compression) end |
Instance Method Details
#configure(private_key, app_name, sub_system, type_name, force_compression) ⇒ boolean
Configure coralogix logger with customer specific values
58 59 60 61 62 63 64 65 |
# File 'lib/centralized_ruby_logger.rb', line 58 def configure private_key, app_name, sub_system, type_name, force_compression private_key = (private_key.nil? || private_key.to_s.strip.empty?) ? FAILED_PRIVATE_KEY : private_key app_name = (app_name.nil? || app_name.to_s.strip.empty?) ? NO_APP_NAME : app_name sub_system = (sub_system.nil? || sub_system.to_s.strip.empty?) ? NO_SUB_SYSTEM : sub_system @manager.set_logger_type_name type_name @manager.force_compression = force_compression @manager.configure(:privateKey => private_key, :applicationName => app_name, :subsystemName => sub_system) unless @manager.configured end |
#debug_mode=(value) ⇒ Object
A setter for debug_mode.
Default value is false. When set to true the coralogix logger will print output messages to a console and a file.
37 38 39 |
# File 'lib/centralized_ruby_logger.rb', line 37 def debug_mode=(value) DebugLogger.debug_mode=value end |
#debug_mode? ⇒ boolean
A getter for debug_mode. Default value is false. When set to true the coralogix logger will print output messages to a console and a file.
28 29 30 |
# File 'lib/centralized_ruby_logger.rb', line 28 def debug_mode? DebugLogger.debug_mode end |
#disable_proxy=(value) ⇒ Object
A setter for disable_proxy. By default HTTP object will use proxy environment variable if exists. In some cases this migh be an issue When set to false the HTTP object will ignore any proxy.
46 47 48 |
# File 'lib/centralized_ruby_logger.rb', line 46 def disable_proxy=(value) @manager.disable_proxy=value end |
#flush ⇒ Object
Flush all messages in buffer and send them immediately on the current thread.
69 70 71 |
# File 'lib/centralized_ruby_logger.rb', line 69 def flush @manager.flush end |
#log(severity, message, category = @category, named_args = {}) ⇒ Object
Log a message.
81 82 83 84 85 86 87 88 |
# File 'lib/centralized_ruby_logger.rb', line 81 def log severity, , category=@category, named_args = {} className = named_args.fetch(:className,"") methodName = named_args.fetch(:methodName,"") threadId = named_args.fetch(:threadId,Thread.current.object_id.to_s) @manager.add_logline , severity, category, :className => className, :methodName => methodName, :threadId => threadId end |