-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog.rb
68 lines (48 loc) · 1.06 KB
/
Log.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
class Log
def initialize()
@@old_tail=""
end
def set_file(filename)
@@filepath=filename
end
def set_alert_gui(tmp)
@@gui=tmp
end
# find the possition of the EOF
# ... it will be used to compare later
# ... for new entries
def initial_eof()
@@last_eof=0
@@file=File.open(@@filepath,"r")
@@last_eof=get_current_eof()
end
def get_last_eof()
return @@last_eof
end
#detects if a new entries has been added
#...to the log file
def new_entry()
@@current_eof = get_current_eof()
return false if @@last_eof == @@current_eof
return true
end
# returns the possition of the EOF
def get_current_eof()
@@file.seek(0,IO::SEEK_END);
return @@file.pos
end
# dump the errors
def error(msg)
puts "[!!] " + msg
end
# alert on comand line
def display_cli(title,text)
puts "\nFound change:"
puts text
puts "End of Found change\n"
end
# alert on gui
def display_gui(title,text)
@@gui.alert(title,text)
end
end