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.
15 16 17 |
# File 'lib/logstash/logging/logger.rb', line 15 def initialize(name) @logger = LogManager.getLogger(name) end |
Class Method Details
.configure_logging(level, path = LogManager::ROOT_LOGGER_NAME) ⇒ Object
67 68 69 70 71 |
# File 'lib/logstash/logging/logger.rb', line 67 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
90 91 92 |
# File 'lib/logstash/logging/logger.rb', line 90 def self.get_logging_context return @@logging_context end |
.initialize(config_location) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/logstash/logging/logger.rb', line 73 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
43 44 45 |
# File 'lib/logstash/logging/logger.rb', line 43 def debug(, data = {}) @logger.debug(, data) end |
#debug? ⇒ Boolean
19 20 21 |
# File 'lib/logstash/logging/logger.rb', line 19 def debug? @logger.is_debug_enabled end |
#error(message, data = {}) ⇒ Object
55 56 57 |
# File 'lib/logstash/logging/logger.rb', line 55 def error(, data = {}) @logger.error(, data) end |
#error? ⇒ Boolean
27 28 29 |
# File 'lib/logstash/logging/logger.rb', line 27 def error? @logger.is_error_enabled end |
#fatal(message, data = {}) ⇒ Object
59 60 61 |
# File 'lib/logstash/logging/logger.rb', line 59 def fatal(, data = {}) @logger.fatal(, data) end |
#fatal? ⇒ Boolean
35 36 37 |
# File 'lib/logstash/logging/logger.rb', line 35 def fatal? @logger.is_fatal_enabled end |
#info(message, data = {}) ⇒ Object
51 52 53 |
# File 'lib/logstash/logging/logger.rb', line 51 def info(, data = {}) @logger.info(, data) end |
#info? ⇒ Boolean
23 24 25 |
# File 'lib/logstash/logging/logger.rb', line 23 def info? @logger.is_info_enabled end |
#trace(message, data = {}) ⇒ Object
63 64 65 |
# File 'lib/logstash/logging/logger.rb', line 63 def trace(, data = {}) @logger.trace(, data) end |
#trace? ⇒ Boolean
39 40 41 |
# File 'lib/logstash/logging/logger.rb', line 39 def trace? @logger.is_trace_enabled end |
#warn(message, data = {}) ⇒ Object
47 48 49 |
# File 'lib/logstash/logging/logger.rb', line 47 def warn(, data = {}) @logger.warn(, data) end |
#warn? ⇒ Boolean
31 32 33 |
# File 'lib/logstash/logging/logger.rb', line 31 def warn? @logger.is_warn_enabled end |