Class: UU::LoggerFluent
- Inherits:
-
Object
- Object
- UU::LoggerFluent
- Defined in:
- lib/uu/logger_fluent.rb
Defined Under Namespace
Constant Summary collapse
- NIL =
Nil.new
Instance Attribute Summary collapse
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #create_logger(host, port) ⇒ Object
- #format_message(severity, message) ⇒ Object
-
#initialize(cxt, host: , port: ) ⇒ LoggerFluent
constructor
A new instance of LoggerFluent.
Constructor Details
#initialize(cxt, host: , port: ) ⇒ LoggerFluent
Returns a new instance of LoggerFluent.
59 60 61 62 |
# File 'lib/uu/logger_fluent.rb', line 59 def initialize(cxt, host: ENV['FLUENTD_HOST'], port: ENV['FLUENTD_PORT']) @logger = create_logger(host, port) @formatter = Formatter.new(cxt) end |
Instance Attribute Details
#formatter ⇒ Object
Returns the value of attribute formatter.
75 76 77 |
# File 'lib/uu/logger_fluent.rb', line 75 def formatter @formatter end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
74 75 76 |
# File 'lib/uu/logger_fluent.rb', line 74 def logger @logger end |
Instance Method Details
#create_logger(host, port) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/uu/logger_fluent.rb', line 64 def create_logger(host, port) return NIL unless host Fluent::Logger::FluentLogger.new( nil, nanosecond_precision: true, host: host, **(port ? { port: port.to_i } : {}) ) end |
#format_message(severity, message) ⇒ Object
77 78 79 |
# File 'lib/uu/logger_fluent.rb', line 77 def (severity, ) @formatter.call(severity, ) end |