Class: KXI::Application::Logger

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

Overview

Allows simple unstructured (time-independent) logging

Defined Under Namespace

Classes: Message

Instance Method Summary collapse

Constructor Details

#initializeLogger

Instantiates the KXI::Application::Logger class



23
24
25
26
# File 'lib/kxi/application/logger.rb', line 23

def initialize
	@event = KXI::Application::Event.new
	@start = DateTime.now
end

Instance Method Details

#attach(min = Message::Severity::COMMAND) {|msg| ... } ⇒ Number

Attaches action to message event

Parameters:

Yields:

  • (msg)

    Event action

Yield Parameters:

Returns:

  • (Number)

    Id of event hook



18
19
20
# File 'lib/kxi/application/logger.rb', line 18

def attach(min = Message::Severity::COMMAND, &block)
	return @event.add { |s, msg| block.call(msg) if msg.severity.level >= min.level }
end

#command(cmd) ⇒ Object

Parameters:

  • cmd (String)

    Executed command



30
31
32
# File 'lib/kxi/application/logger.rb', line 30

def command(cmd)
	log(Message::Severity::COMMAND, cmd)
end

#debug(msg) ⇒ Object

Parameters:

  • msg (String)

    Text of message



42
43
44
# File 'lib/kxi/application/logger.rb', line 42

def debug(msg)
	log(Message::Severity::DEBUG, msg)
end

#error(msg) ⇒ Object

Parameters:

  • msg (String)

    Text of message



60
61
62
# File 'lib/kxi/application/logger.rb', line 60

def error(msg)
	log(Message::Severity::ERROR, msg)
end

#fatal(msg) ⇒ Object

Parameters:

  • msg (String)

    Text of message



66
67
68
# File 'lib/kxi/application/logger.rb', line 66

def fatal(msg)
	log(Message::Severity::FATAL, msg)
end

#info(msg) ⇒ Object

Logs message with the KXI::Application::Logger::Message::Severity::INFO severity

Parameters:

  • msg (String)

    Text of message



48
49
50
# File 'lib/kxi/application/logger.rb', line 48

def info(msg)
	log(Message::Severity::INFO, msg)
end

#on_messageKXI::Application::Event

Gets the message event

Returns:



9
10
11
# File 'lib/kxi/application/logger.rb', line 9

def on_message
	@event
end

#trace(msg) ⇒ Object

Parameters:

  • msg (String)

    Text of message



36
37
38
# File 'lib/kxi/application/logger.rb', line 36

def trace(msg)
	log(Message::Severity::TRACE, msg)
end

#warning(msg) ⇒ Object

Parameters:

  • msg (String)

    Text of message



54
55
56
# File 'lib/kxi/application/logger.rb', line 54

def warning(msg)
	log(Message::Severity::WARNING, msg)
end