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.



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

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.



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

def levelno
  @levelno
end

#msgObject (readonly)

Returns the value of attribute msg.



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

def msg
  @msg
end

#pidObject (readonly)

process_id



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

def pid
  @pid
end

#tidObject (readonly)

thread_id



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

def tid
  @tid
end

#tsObject (readonly)

timestamp



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

def ts
  @ts
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


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

def error?
  @levelno == ERROR
end

#fatal?Boolean

Returns:

  • (Boolean)


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

def fatal?
  @levelno == FATAL
end

#levelObject



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

def level
  LEVEL_NAME[ @levelno ]
end

#to_sObject



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

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

#unknown?Boolean

Returns:

  • (Boolean)


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

def unknown?
  @levelno == UNKNOWN
end

#warn?Boolean

Returns:

  • (Boolean)


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

def warn?
  @levelno == WARN
end