Class: LogKernel::Event

Inherits:
Object
  • Object
show all
Includes:
Level
Defined in:
lib/logutils/logger.rb

Constant Summary

Constants included from Level

Level::ALL, Level::DEBUG, Level::ERROR, Level::FATAL, Level::INFO, Level::OFF, Level::UNKNOWN, Level::WARN

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(levelno, msg) ⇒ Event

Returns a new instance of Event.



58
59
60
61
62
63
64
65
66
# File 'lib/logutils/logger.rb', line 58

def initialize( levelno, msg )
  @levelno = levelno    # pass in integer e.g. 0,1,2,3,etc.
  @msg     = msg
  
  @pid   = Process.pid
  @tid   = Thread.current.object_id
  
  @ts    = Time.now
end

Instance Attribute Details

#levelnoObject (readonly)

Returns the value of attribute levelno.



72
73
74
# File 'lib/logutils/logger.rb', line 72

def levelno
  @levelno
end

#msgObject (readonly)

Returns the value of attribute msg.



73
74
75
# File 'lib/logutils/logger.rb', line 73

def msg
  @msg
end

#pidObject (readonly)

process_id



74
75
76
# File 'lib/logutils/logger.rb', line 74

def pid
  @pid
end

#tidObject (readonly)

thread_id



75
76
77
# File 'lib/logutils/logger.rb', line 75

def tid
  @tid
end

#tsObject (readonly)

timestamp



76
77
78
# File 'lib/logutils/logger.rb', line 76

def ts
  @ts
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/logutils/logger.rb', line 83

def error?
  @levelno == ERROR
end

#fatal?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/logutils/logger.rb', line 79

def fatal?
  @levelno == FATAL
end

#levelObject



68
69
70
# File 'lib/logutils/logger.rb', line 68

def level
  LEVEL_NAME[ @levelno ]
end

#to_sObject



96
97
98
99
# File 'lib/logutils/logger.rb', line 96

def to_s
  # "[#{level}-#{pid}.#{tid}] #{msg}"
  "[#{level}] #{msg}"
end

#unknown?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/logutils/logger.rb', line 91

def unknown?
  @levelno == UNKNOWN
end

#warn?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/logutils/logger.rb', line 87

def warn?
  @levelno == WARN
end