Class: SemanticLogger::Formatters::Base
- Inherits:
-
Object
- Object
- SemanticLogger::Formatters::Base
- Defined in:
- lib/semantic_logger/formatters/base.rb
Constant Summary collapse
- PRECISION =
Time precision varies by Ruby interpreter JRuby 9.1.8.0 supports microseconds
if defined?(JRuby) if JRUBY_VERSION.to_f >= 9.1 maint = JRUBY_VERSION.match(/\A\d+\.\d+\.(\d+)\./)[1].to_i (maint >= 8) || (JRUBY_VERSION.to_f > 9.1) ? 6 : 3 else 3 end else 6 end
- TIME_FORMAT =
"%Y-%m-%d %H:%M:%S.%#{PRECISION}N".freeze
Instance Attribute Summary collapse
-
#log_application ⇒ Object
Returns the value of attribute log_application.
-
#log_host ⇒ Object
Returns the value of attribute log_host.
-
#time_format ⇒ Object
Returns the value of attribute time_format.
Instance Method Summary collapse
-
#initialize(time_format: TIME_FORMAT, log_host: true, log_application: true) ⇒ Base
constructor
Parameters time_format: [String|Symbol|nil] See Time#strftime for the format of this string.
-
#time ⇒ Object
Date & time.
Constructor Details
#initialize(time_format: TIME_FORMAT, log_host: true, log_application: true) ⇒ Base
Parameters
time_format: [String|Symbol|nil]
See Time#strftime for the format of this string.
:iso_8601 Outputs an ISO8601 Formatted timestamp.
:ms Output in miliseconds since epoch.
nil: Returns Empty string for time ( no time is output ).
Default: '%Y-%m-%d %H:%M:%S.%6N'
29 30 31 32 33 |
# File 'lib/semantic_logger/formatters/base.rb', line 29 def initialize(time_format: TIME_FORMAT, log_host: true, log_application: true) @time_format = time_format @log_host = log_host @log_application = log_application end |
Instance Attribute Details
#log_application ⇒ Object
Returns the value of attribute log_application.
5 6 7 |
# File 'lib/semantic_logger/formatters/base.rb', line 5 def log_application @log_application end |
#log_host ⇒ Object
Returns the value of attribute log_host.
5 6 7 |
# File 'lib/semantic_logger/formatters/base.rb', line 5 def log_host @log_host end |
#time_format ⇒ Object
Returns the value of attribute time_format.
5 6 7 |
# File 'lib/semantic_logger/formatters/base.rb', line 5 def time_format @time_format end |
Instance Method Details
#time ⇒ Object
Date & time
36 37 38 |
# File 'lib/semantic_logger/formatters/base.rb', line 36 def time format_time(log.time) if time_format end |