Class: HQ::Logger::IoLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/hq/logger/io-logger.rb

Direct Known Subclasses

AnsiLogger, HtmlLogger, RawLogger, TextLogger

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#levelObject

Returns the value of attribute level.



7
8
9
# File 'lib/hq/logger/io-logger.rb', line 7

def level
  @level
end

#outObject

Returns the value of attribute out.



6
7
8
# File 'lib/hq/logger/io-logger.rb', line 6

def out
  @out
end

Instance Method Details

#fix_stuff(old_stuff, content, prefix = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hq/logger/io-logger.rb', line 9

def fix_stuff old_stuff, content, prefix = nil

	content = {} \
		unless content.is_a? Hash

	new_stuff = {
		hostname: content["hostname"] || old_stuff[:hostname],
		level: (content["level"] || old_stuff[:level]).to_sym,
		prefix: (old_stuff[:prefix] || "") + (prefix || ""),
		mode: old_stuff[:mode].to_sym,
	}

	raise "No hostname" \
		unless new_stuff[:hostname]

	raise "No level" \
		unless new_stuff[:level]

	return new_stuff

end

#output(content, stuff = {}, prefix = "") ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/hq/logger/io-logger.rb', line 31

def output content, stuff = {}, prefix = ""

	stuff = fix_stuff stuff, content, prefix

	# check we want to output this entry

	return unless Logger.level_includes \
		level,
		stuff[:level]

	return unless valid_modes.include? stuff[:mode].to_sym

	# output it

	output_real content, stuff

end