Class: HQ::Logger::TextLogger

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

Instance Attribute Summary

Attributes inherited from IoLogger

#level, #out

Instance Method Summary collapse

Methods inherited from IoLogger

#fix_stuff, #output

Instance Method Details

#output_real(content, stuff) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/hq/logger/text-logger.rb', line 25

def output_real content, stuff

	if content.is_a? String
		text_line content, stuff
		return
	end

	case content["type"]

	when "log"

		text_line content["text"], stuff

		if content["content"]

			content["content"].each do
				|item|
				output item, stuff, "  "
			end

		end

	when "exception"

		text_line content["text"], stuff
		text_line content["message"], stuff, "  "

		content["backtrace"].each do
			|frame|
			output frame, stuff, "    "
		end

	when "diff"

		text_line content["text"], stuff

		content["content"].each do
			|line|
			output line["text"], stuff, "  "
		end

	when "command"

		text_line content["text"], stuff

		if content["output"]

			content["output"].each do
				|line|
				output line, stuff, "  "
			end

		end

	when "command-output"

		text_line content["text"], stuff, "  "

	else

		pp content
		raise "Error"

	end

end

#text_line(text, stuff, prefix = "") ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hq/logger/text-logger.rb', line 12

def text_line text, stuff, prefix = ""

	out.print \
		stuff[:hostname],
		" ",
		stuff[:level],
		": ",
		stuff[:prefix] + prefix,
		text,
		"\n"

end

#valid_modesObject



8
9
10
# File 'lib/hq/logger/text-logger.rb', line 8

def valid_modes
	[ :normal, :partial ]
end