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) ⇒ 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) ⇒ CoralogixLogger
Constructor.
11 12 13 14 15 16 |
# 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 self.debug_mode=debug @category = CORALOGIX_CATEGORY @manager = LoggerManager.new 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
53 54 55 56 57 58 59 60 |
# File 'lib/centralized_ruby_logger.rb', line 53 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.
32 33 34 |
# File 'lib/centralized_ruby_logger.rb', line 32 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.
23 24 25 |
# File 'lib/centralized_ruby_logger.rb', line 23 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.
41 42 43 |
# File 'lib/centralized_ruby_logger.rb', line 41 def disable_proxy=(value) @manager.disable_proxy=value end |
#flush ⇒ Object
Flush all messages in buffer and send them immediately on the current thread.
64 65 66 |
# File 'lib/centralized_ruby_logger.rb', line 64 def flush @manager.flush end |
#log(severity, message, category = @category, named_args = {}) ⇒ Object
Log a message.
76 77 78 79 80 81 82 83 |
# File 'lib/centralized_ruby_logger.rb', line 76 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 |