Class: Gat::LogEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/gat/logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, global_type = "trace", category = "undefined", message = "Empty", *options) ⇒ LogEntry

Returns a new instance of LogEntry.



189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/gat/logger.rb', line 189

def initialize(logger, global_type = "trace", category = "undefined",  message = "Empty", *options)
  @logger         = logger
  @time           = Time.now
  @global_type    = global_type

  unless logger.global_types.keys.include?(global_type)
    raise GatgetException.new("Undefined log global_type #{ global_type }", "initialize_log_entry")
  end

  @category       = category
  @message        = message
  @options        = options
  @verbose_level  = logger.global_types[global_type]['verbose']
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



182
183
184
# File 'lib/gat/logger.rb', line 182

def category
  @category
end

#global_typeObject (readonly)

Returns the value of attribute global_type.



181
182
183
# File 'lib/gat/logger.rb', line 181

def global_type
  @global_type
end

#loggerObject (readonly)

Returns the value of attribute logger.



180
181
182
# File 'lib/gat/logger.rb', line 180

def logger
  @logger
end

#messageObject (readonly)

Returns the value of attribute message.



183
184
185
# File 'lib/gat/logger.rb', line 183

def message
  @message
end

#optionsObject (readonly)

Returns the value of attribute options.



184
185
186
# File 'lib/gat/logger.rb', line 184

def options
  @options
end

#timeObject (readonly)

Returns the value of attribute time.



186
187
188
# File 'lib/gat/logger.rb', line 186

def time
  @time
end

#verbose_levelObject (readonly)

Returns the value of attribute verbose_level.



185
186
187
# File 'lib/gat/logger.rb', line 185

def verbose_level
  @verbose_level
end

Instance Method Details

#inspectObject



205
206
207
# File 'lib/gat/logger.rb', line 205

def inspect
  "#{ self.time.strftime("%Y-%m-%d %H:%M:%S") } | #{ self.global_type.ljust(20) } | #{ self.category.ljust(20) }  => #{ self.message }"
end

#outputObject



213
214
215
# File 'lib/gat/logger.rb', line 213

def output
  self.message
end

#to_hashObject



209
210
211
# File 'lib/gat/logger.rb', line 209

def to_hash
  { 'time' => self.time, 'global_type' => self.global_type, 'category' => self.category, 'message' => self.message, 'options' => self.options }
end