class Riemann::Tail::Config
Attributes
defaults[RW]
formatters[RW]
line_format[RW]
Public Class Methods
new()
click to toggle source
# File lib/riemann/tail/config.rb, line 4 def initialize @defaults = {} @formatters = {} end
Public Instance Methods
default(field, value)
click to toggle source
# File lib/riemann/tail/config.rb, line 18 def default(field, value) @defaults[field.to_sym] = value.to_s end
format(field, format, &block)
click to toggle source
# File lib/riemann/tail/config.rb, line 11 def format(field, format, &block) @formatters[field.to_sym] = { methods: (format.is_a?(Array) ? format : [format.to_sym]) } @formatters[field.to_sym][:block] = block if block_given? end
line_format=(format)
click to toggle source
# File lib/riemann/tail/config.rb, line 22 def line_format=(format) # hacky way to prevent sprintf (%) from throwing key errors format.scan(/%{([^}]+)}|%<([^>])>/).each do |(m, n)| @defaults[(m||n).to_sym] ||= "" end @line_format = format end