Class: LogStash::Logging::Logger
- Inherits:
-
Object
- Object
- LogStash::Logging::Logger
- Defined in:
- lib/logstash/logging/logger.rb
Constant Summary collapse
- @@config_mutex =
Mutex.new
- @@logging_context =
nil
Class Method Summary collapse
- .configure_logging(level, path = LogManager::ROOT_LOGGER_NAME) ⇒ Object
- .get_logging_context ⇒ Object
- .initialize(config_location) ⇒ Object
Instance Method Summary collapse
- #debug(message, data = {}) ⇒ Object
- #debug? ⇒ Boolean
- #error(message, data = {}) ⇒ Object
- #error? ⇒ Boolean
- #fatal(message, data = {}) ⇒ Object
- #fatal? ⇒ Boolean
- #info(message, data = {}) ⇒ Object
- #info? ⇒ Boolean
-
#initialize(name) ⇒ Logger
constructor
A new instance of Logger.
- #trace(message, data = {}) ⇒ Object
- #trace? ⇒ Boolean
- #warn(message, data = {}) ⇒ Object
- #warn? ⇒ Boolean
Constructor Details
#initialize(name) ⇒ Logger
Returns a new instance of Logger.
16 17 18 |
# File 'lib/logstash/logging/logger.rb', line 16 def initialize(name) @logger = LogManager.getLogger(name) end |
Class Method Details
.configure_logging(level, path = LogManager::ROOT_LOGGER_NAME) ⇒ Object
68 69 70 71 72 |
# File 'lib/logstash/logging/logger.rb', line 68 def self.configure_logging(level, path = LogManager::ROOT_LOGGER_NAME) @@config_mutex.synchronize { set_level(level, path) } rescue Exception => e raise ArgumentError, "invalid level[#{level}] for logger[#{path}]" end |
.get_logging_context ⇒ Object
91 92 93 |
# File 'lib/logstash/logging/logger.rb', line 91 def self.get_logging_context return @@logging_context end |
.initialize(config_location) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/logstash/logging/logger.rb', line 74 def self.initialize(config_location) @@config_mutex.synchronize do if @@logging_context.nil? file_path = URI(config_location).path if ::File.exists?(file_path) logs_location = java.lang.System.getProperty("ls.logs") puts "Sending Logstash's logs to #{logs_location} which is now configured via log4j2.properties" @@logging_context = Configurator.initialize(nil, config_location) else # fall back to default config puts "Could not find log4j2 configuration at path #{file_path}. Using default config which logs to console" @@logging_context = Configurator.initialize(DefaultConfiguration.new) end end end end |
Instance Method Details
#debug(message, data = {}) ⇒ Object
44 45 46 |
# File 'lib/logstash/logging/logger.rb', line 44 def debug(, data = {}) @logger.debug(, data) end |
#debug? ⇒ Boolean
20 21 22 |
# File 'lib/logstash/logging/logger.rb', line 20 def debug? @logger.is_debug_enabled end |
#error(message, data = {}) ⇒ Object
56 57 58 |
# File 'lib/logstash/logging/logger.rb', line 56 def error(, data = {}) @logger.error(, data) end |
#error? ⇒ Boolean
28 29 30 |
# File 'lib/logstash/logging/logger.rb', line 28 def error? @logger.is_error_enabled end |
#fatal(message, data = {}) ⇒ Object
60 61 62 |
# File 'lib/logstash/logging/logger.rb', line 60 def fatal(, data = {}) @logger.fatal(, data) end |
#fatal? ⇒ Boolean
36 37 38 |
# File 'lib/logstash/logging/logger.rb', line 36 def fatal? @logger.is_fatal_enabled end |
#info(message, data = {}) ⇒ Object
52 53 54 |
# File 'lib/logstash/logging/logger.rb', line 52 def info(, data = {}) @logger.info(, data) end |
#info? ⇒ Boolean
24 25 26 |
# File 'lib/logstash/logging/logger.rb', line 24 def info? @logger.is_info_enabled end |
#trace(message, data = {}) ⇒ Object
64 65 66 |
# File 'lib/logstash/logging/logger.rb', line 64 def trace(, data = {}) @logger.trace(, data) end |
#trace? ⇒ Boolean
40 41 42 |
# File 'lib/logstash/logging/logger.rb', line 40 def trace? @logger.is_trace_enabled end |
#warn(message, data = {}) ⇒ Object
48 49 50 |
# File 'lib/logstash/logging/logger.rb', line 48 def warn(, data = {}) @logger.warn(, data) end |
#warn? ⇒ Boolean
32 33 34 |
# File 'lib/logstash/logging/logger.rb', line 32 def warn? @logger.is_warn_enabled end |