Class: LogEasy::Level
- Inherits:
-
Object
- Object
- LogEasy::Level
- Defined in:
- lib/logeasy/level.rb
Overview
A level represents the severity of a log message. The predefined levels are; ALL < FINE_TRACE < TRACE < DEBUG < CONFIG < INFO < WARN < ERROR < FATAL < UNFORMATTED < OFF
Constant Summary collapse
- ALL =
new("ALL", 0)
- FINE_TRACE =
new("FINE", 1000)
- TRACE =
new("TRACE", 2000)
- DEBUG =
new("DEBUG", 3000)
- CONF =
new("CONF", 4000)
- INFO =
new("INFO", 5000)
- WARN =
new("WARN", 6000)
- ERROR =
new("ERROR", 7000)
- FATAL =
new("FATAL", 8000)
- UNFORMATTED =
new("UNF", 9000)
- OFF =
new("OFF", 10000)
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
-
#<(other) ⇒ Object
Overload the < operator to compare the weights of the levels.
-
#<=(other) ⇒ Object
Overload the <= operator to compare the weights of the levels.
-
#==(other) ⇒ Object
Overload the == operator to compare the weights of the levels.
-
#>(other) ⇒ Object
Overload the > operator to compare the weights of the levels.
-
#>=(other) ⇒ Object
Overload the >= operator to compare the weights of the levels.
-
#initialize(name, weight) ⇒ Level
constructor
New logging level.
-
#to_s ⇒ Object
Overrides ‘to_s’ to return the name of the level.
Constructor Details
#initialize(name, weight) ⇒ Level
New logging level.
‘name’ - The name of the level. Formatted log messages will print this value. ‘weight’ - The severity of this level. The higher the value, the more severe.
19 20 21 22 |
# File 'lib/logeasy/level.rb', line 19 def initialize(name, weight) @name = name @weight = weight end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/logeasy/level.rb', line 12 def name @name end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
13 14 15 |
# File 'lib/logeasy/level.rb', line 13 def weight @weight end |
Instance Method Details
#<(other) ⇒ Object
Overload the < operator to compare the weights of the levels.
‘other’ - The level to compare this level with.
48 49 50 |
# File 'lib/logeasy/level.rb', line 48 def <(other) self.weight < other.weight end |
#<=(other) ⇒ Object
Overload the <= operator to compare the weights of the levels.
‘other’ - The level to compare this level with.
55 56 57 |
# File 'lib/logeasy/level.rb', line 55 def <=(other) self.weight <= other.weight end |
#==(other) ⇒ Object
Overload the == operator to compare the weights of the levels.
‘other’ - The level to compare this level with.
41 42 43 |
# File 'lib/logeasy/level.rb', line 41 def ==(other) self.weight == other.weight end |
#>(other) ⇒ Object
Overload the > operator to compare the weights of the levels.
‘other’ - The level to compare this level with.
27 28 29 |
# File 'lib/logeasy/level.rb', line 27 def >(other) self.weight > other.weight end |
#>=(other) ⇒ Object
Overload the >= operator to compare the weights of the levels.
‘other’ - The level to compare this level with.
34 35 36 |
# File 'lib/logeasy/level.rb', line 34 def >=(other) self.weight >= other.weight end |
#to_s ⇒ Object
Overrides ‘to_s’ to return the name of the level.
60 61 62 |
# File 'lib/logeasy/level.rb', line 60 def to_s name end |