Class: LogStash::Logging::Logger
- Inherits:
-
Object
- Object
- LogStash::Logging::Logger
- Defined in:
- lib/logstash/logging/logger.rb
Constant Summary collapse
- @@config_mutex =
Mutex.new
Class Method Summary collapse
- .configure_logging(level, path = LogManager::ROOT_LOGGER_NAME) ⇒ Object
- .get_logging_context ⇒ Object
- .reconfigure(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.
18 19 20 |
# File 'lib/logstash/logging/logger.rb', line 18 def initialize(name) @logger = LogManager.getLogger(name) end |
Class Method Details
.configure_logging(level, path = LogManager::ROOT_LOGGER_NAME) ⇒ Object
70 71 72 73 74 |
# File 'lib/logstash/logging/logger.rb', line 70 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
98 99 100 |
# File 'lib/logstash/logging/logger.rb', line 98 def self.get_logging_context return LoggerContext.getContext(false) end |
.reconfigure(config_location) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/logstash/logging/logger.rb', line 76 def self.reconfigure(config_location) @@config_mutex.synchronize do config_location_uri = URI.create(config_location) file_path = config_location_uri.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" #reconfigure the default context to use our log4j2.properties file get_logging_context.setConfigLocation(URI.create(config_location)) #ensure everyone agrees which context to use for the LogManager context_factory = LogstashLoggerContextFactory.new(get_logging_context) LogManager.setFactory(context_factory) else # fall back to default config puts "Could not find log4j2 configuration at path #{file_path}. Using default config which logs errors to the console" end end end |
Instance Method Details
#debug(message, data = {}) ⇒ Object
46 47 48 |
# File 'lib/logstash/logging/logger.rb', line 46 def debug(, data = {}) @logger.debug(, data) end |
#debug? ⇒ Boolean
22 23 24 |
# File 'lib/logstash/logging/logger.rb', line 22 def debug? @logger.is_debug_enabled end |
#error(message, data = {}) ⇒ Object
58 59 60 |
# File 'lib/logstash/logging/logger.rb', line 58 def error(, data = {}) @logger.error(, data) end |
#error? ⇒ Boolean
30 31 32 |
# File 'lib/logstash/logging/logger.rb', line 30 def error? @logger.is_error_enabled end |
#fatal(message, data = {}) ⇒ Object
62 63 64 |
# File 'lib/logstash/logging/logger.rb', line 62 def fatal(, data = {}) @logger.fatal(, data) end |
#fatal? ⇒ Boolean
38 39 40 |
# File 'lib/logstash/logging/logger.rb', line 38 def fatal? @logger.is_fatal_enabled end |
#info(message, data = {}) ⇒ Object
54 55 56 |
# File 'lib/logstash/logging/logger.rb', line 54 def info(, data = {}) @logger.info(, data) end |
#info? ⇒ Boolean
26 27 28 |
# File 'lib/logstash/logging/logger.rb', line 26 def info? @logger.is_info_enabled end |
#trace(message, data = {}) ⇒ Object
66 67 68 |
# File 'lib/logstash/logging/logger.rb', line 66 def trace(, data = {}) @logger.trace(, data) end |
#trace? ⇒ Boolean
42 43 44 |
# File 'lib/logstash/logging/logger.rb', line 42 def trace? @logger.is_trace_enabled end |
#warn(message, data = {}) ⇒ Object
50 51 52 |
# File 'lib/logstash/logging/logger.rb', line 50 def warn(, data = {}) @logger.warn(, data) end |
#warn? ⇒ Boolean
34 35 36 |
# File 'lib/logstash/logging/logger.rb', line 34 def warn? @logger.is_warn_enabled end |