Class: LogUtils::Kernel::Event
- Inherits:
-
Object
- Object
- LogUtils::Kernel::Event
- Includes:
- Level
- Defined in:
- lib/logutils/logger.rb
Constant Summary collapse
- LEVEL_NAME =
[ 'all', # 0 'debug', # 1 'info', # 2 'warn', # 3 'error', # 4 'fatal', # 5 'off' # 6 ]
Constants included from Level
Level::ALL, Level::DEBUG, Level::ERROR, Level::FATAL, Level::INFO, Level::OFF, Level::WARN
Instance Attribute Summary collapse
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
-
#pid ⇒ Object
readonly
process_id.
-
#tid ⇒ Object
readonly
thread_id.
-
#ts ⇒ Object
readonly
timestamp.
Instance Method Summary collapse
- #error? ⇒ Boolean
- #fatal? ⇒ Boolean
-
#initialize(levelno, msg) ⇒ Event
constructor
A new instance of Event.
- #level ⇒ Object
- #to_s ⇒ Object
- #warn? ⇒ Boolean
Constructor Details
#initialize(levelno, msg) ⇒ Event
Returns a new instance of Event.
42 43 44 45 46 47 48 49 50 |
# File 'lib/logutils/logger.rb', line 42 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
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
56 57 58 |
# File 'lib/logutils/logger.rb', line 56 def msg @msg end |
#pid ⇒ Object (readonly)
process_id
57 58 59 |
# File 'lib/logutils/logger.rb', line 57 def pid @pid end |
#tid ⇒ Object (readonly)
thread_id
58 59 60 |
# File 'lib/logutils/logger.rb', line 58 def tid @tid end |
#ts ⇒ Object (readonly)
timestamp
59 60 61 |
# File 'lib/logutils/logger.rb', line 59 def ts @ts end |
Instance Method Details
#error? ⇒ Boolean
66 67 68 |
# File 'lib/logutils/logger.rb', line 66 def error? @levelno == ERROR end |
#fatal? ⇒ Boolean
62 63 64 |
# File 'lib/logutils/logger.rb', line 62 def fatal? @levelno == FATAL end |
#level ⇒ Object
52 53 54 |
# File 'lib/logutils/logger.rb', line 52 def level LEVEL_NAME[ @levelno ] end |
#to_s ⇒ Object
75 76 77 78 |
# File 'lib/logutils/logger.rb', line 75 def to_s # "[#{level}-#{pid}.#{tid}] #{msg}" "[#{level}] #{msg}" end |