Class: Logsly::Outputs::BaseData

Inherits:
Object
  • Object
show all
Defined in:
lib/logsly/outputs.rb

Direct Known Subclasses

FileData, SyslogData

Instance Method Summary collapse

Constructor Details

#initialize(*args, &build) ⇒ BaseData

Returns a new instance of BaseData.



43
44
45
46
47
48
49
50
# File 'lib/logsly/outputs.rb', line 43

def initialize(*args, &build)
  @pattern = DEFAULT_PATTERN
  @colors  = nil
  @level   = nil

  @args = args
  self.instance_exec(*@args, &(build || Proc.new{}))
end

Instance Method Details

#colors(value = nil) ⇒ Object



57
58
59
60
# File 'lib/logsly/outputs.rb', line 57

def colors(value = nil)
  @colors = value if !value.nil?
  @colors
end

#level(value = nil) ⇒ Object



62
63
64
65
# File 'lib/logsly/outputs.rb', line 62

def level(value = nil)
  @level = value if !value.nil?
  @level
end

#pattern(value = nil) ⇒ Object



52
53
54
55
# File 'lib/logsly/outputs.rb', line 52

def pattern(value = nil)
  @pattern = value if !value.nil?
  @pattern
end

#to_pattern_optsObject



67
68
69
70
71
72
73
74
75
# File 'lib/logsly/outputs.rb', line 67

def to_pattern_opts
  Hash.new.tap do |opts|
    opts[:pattern] = self.pattern if self.pattern

    if scheme_name = colors_obj.to_scheme(*@args)
      opts[:color_scheme] = scheme_name
    end
  end
end