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.
14 15 16 |
# File 'lib/logstash/logging/logger.rb', line 14 def initialize(name) @logger = LogManager.getLogger(name) end |
Class Method Details
.configure_logging(level, path = LogManager::ROOT_LOGGER_NAME) ⇒ Object
66 67 68 69 70 |
# File 'lib/logstash/logging/logger.rb', line 66 def self.configure_logging(level, path = LogManager::ROOT_LOGGER_NAME) @@config_mutex.synchronize { Configurator.setLevel(path, Level.valueOf(level)) } rescue Exception => e raise ArgumentError, "invalid level[#{level}] for logger[#{path}]" end |
.get_logging_context ⇒ Object
89 90 91 |
# File 'lib/logstash/logging/logger.rb', line 89 def self.get_logging_context return @@logging_context end |
.initialize(config_location) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/logstash/logging/logger.rb', line 72 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
42 43 44 |
# File 'lib/logstash/logging/logger.rb', line 42 def debug(, data = {}) @logger.debug(, data) end |
#debug? ⇒ Boolean
18 19 20 |
# File 'lib/logstash/logging/logger.rb', line 18 def debug? @logger.is_debug_enabled end |
#error(message, data = {}) ⇒ Object
54 55 56 |
# File 'lib/logstash/logging/logger.rb', line 54 def error(, data = {}) @logger.error(, data) end |
#error? ⇒ Boolean
26 27 28 |
# File 'lib/logstash/logging/logger.rb', line 26 def error? @logger.is_error_enabled end |
#fatal(message, data = {}) ⇒ Object
58 59 60 |
# File 'lib/logstash/logging/logger.rb', line 58 def fatal(, data = {}) @logger.fatal(, data) end |
#fatal? ⇒ Boolean
34 35 36 |
# File 'lib/logstash/logging/logger.rb', line 34 def fatal? @logger.is_fatal_enabled end |
#info(message, data = {}) ⇒ Object
50 51 52 |
# File 'lib/logstash/logging/logger.rb', line 50 def info(, data = {}) @logger.info(, data) end |
#info? ⇒ Boolean
22 23 24 |
# File 'lib/logstash/logging/logger.rb', line 22 def info? @logger.is_info_enabled end |
#trace(message, data = {}) ⇒ Object
62 63 64 |
# File 'lib/logstash/logging/logger.rb', line 62 def trace(, data = {}) @logger.trace(, data) end |
#trace? ⇒ Boolean
38 39 40 |
# File 'lib/logstash/logging/logger.rb', line 38 def trace? @logger.is_trace_enabled end |
#warn(message, data = {}) ⇒ Object
46 47 48 |
# File 'lib/logstash/logging/logger.rb', line 46 def warn(, data = {}) @logger.warn(, data) end |
#warn? ⇒ Boolean
30 31 32 |
# File 'lib/logstash/logging/logger.rb', line 30 def warn? @logger.is_warn_enabled end |