tailog 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/env.erb +6 -0
- data/app/views/error.erb +1 -1
- data/app/views/layout.erb +62 -0
- data/app/views/logs/index.erb +42 -106
- data/lib/tailog/version.rb +1 -1
- data/lib/tailog.rb +6 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93481db09b17c1316e746bc42f2b5d5d3ac68a5c
|
4
|
+
data.tar.gz: c412238da872b246a0506a838126bc3b54c98a74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 281e8fdfd628c36e3eccdea2c759643641d9d11f26f42d664eef81382e3afd0293fec70035d68cb200762e7a3c481cfb4606cb8a104645fb0e44db967dd35974
|
7
|
+
data.tar.gz: 74f55c1e650fd08c537c8add13cf3acea9402ecc0b03ea8e3fd83beff2c8ae512d89913c10be87027b0a744ff726ad4cf2e1804961b567111ffd08e1011e237d
|
data/app/views/env.erb
ADDED
data/app/views/error.erb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>TAILOG</title>
|
5
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>
|
6
|
+
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
|
7
|
+
<style type="text/css">
|
8
|
+
body {
|
9
|
+
font-family: "Lucida Console", Monaco, monospace;
|
10
|
+
padding-top: 20px;
|
11
|
+
padding-bottom: 20px;
|
12
|
+
}
|
13
|
+
|
14
|
+
p {
|
15
|
+
white-space: pre-wrap;
|
16
|
+
margin: 0;
|
17
|
+
}
|
18
|
+
|
19
|
+
p:hover {
|
20
|
+
background: #EEE;
|
21
|
+
}
|
22
|
+
|
23
|
+
a {
|
24
|
+
display: block;
|
25
|
+
}
|
26
|
+
</style>
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
|
30
|
+
<div class="container">
|
31
|
+
|
32
|
+
<!-- Static navbar -->
|
33
|
+
<% p path_info = request.path_info %>
|
34
|
+
<nav class="navbar navbar-default">
|
35
|
+
<div class="container-fluid">
|
36
|
+
<div class="navbar-header">
|
37
|
+
<a class="navbar-brand">TAILOG</a>
|
38
|
+
</div>
|
39
|
+
<div id="navbar" class="navbar-collapse collapse">
|
40
|
+
<ul class="nav navbar-nav">
|
41
|
+
<li<%= ' class="active"' if path_info == "/logs" %>><a href="logs">Logs</a></li>
|
42
|
+
<li<%= ' class="active"' if path_info == "/env" %>><a href="env">Env</a></li>
|
43
|
+
</ul>
|
44
|
+
<ul class="nav navbar-nav navbar-right">
|
45
|
+
<form class="navbar-form navbar-left" method="get">
|
46
|
+
<div class="input-group">
|
47
|
+
<input name="file" type="text" class="form-control" placeholder="<%= params[:file] || 'File Name...' %>">
|
48
|
+
<span class="input-group-btn">
|
49
|
+
<button class="btn btn-default" type="button">Go!</button>
|
50
|
+
</span>
|
51
|
+
</div>
|
52
|
+
</form>
|
53
|
+
</ul>
|
54
|
+
</div><!--/.nav-collapse -->
|
55
|
+
</div><!--/.container-fluid -->
|
56
|
+
</nav>
|
57
|
+
|
58
|
+
<%= yield %>
|
59
|
+
|
60
|
+
</div> <!-- /container -->
|
61
|
+
</body>
|
62
|
+
</html>
|
data/app/views/logs/index.erb
CHANGED
@@ -1,120 +1,56 @@
|
|
1
|
-
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>TAILOG</title>
|
5
|
-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>
|
6
|
-
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
|
7
|
-
<style type="text/css">
|
8
|
-
body {
|
9
|
-
padding-top: 20px;
|
10
|
-
padding-bottom: 20px;
|
11
|
-
}
|
1
|
+
<% begin %>
|
12
2
|
|
13
|
-
|
14
|
-
font-family: "Lucida Console", Monaco, monospace;
|
15
|
-
}
|
3
|
+
<% raise RuntimeError, "Tailog.log_path is not present!" unless Tailog.log_path %>
|
16
4
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
5
|
+
<% if params[:file] %>
|
6
|
+
<% file_path = File.join Tailog.log_path, params[:file] %>
|
7
|
+
<h3 class="page-header"><%= file_path %></h3>
|
21
8
|
|
22
|
-
|
23
|
-
|
24
|
-
}
|
9
|
+
<% File.open file_path do |file| end %>
|
10
|
+
<div id="content"></div>
|
25
11
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
12
|
+
<script type="text/javascript">
|
13
|
+
window.fileSize = {};
|
14
|
+
window.fileSizeDone = {};
|
15
|
+
var $window = $(window),
|
16
|
+
$document = $(document),
|
17
|
+
$content = $("#content");
|
32
18
|
|
33
|
-
|
19
|
+
function loadMore() {
|
20
|
+
$.post(window.location.href, { seek: window.fileSize }, function(json) {
|
21
|
+
try {
|
22
|
+
var data = JSON.parse(json);
|
34
23
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
<a class="navbar-brand monospace">TAILOG</a>
|
40
|
-
</div>
|
41
|
-
<div id="navbar" class="navbar-collapse collapse">
|
42
|
-
<ul class="nav navbar-nav">
|
43
|
-
<li class="active"><a href="#">Logs</a></li>
|
44
|
-
</ul>
|
45
|
-
<ul class="nav navbar-nav navbar-right">
|
46
|
-
<form class="navbar-form navbar-left" method="get">
|
47
|
-
<div class="input-group">
|
48
|
-
<input name="file" type="text" class="form-control" placeholder="<%= params[:file] || 'File Name...' %>">
|
49
|
-
<span class="input-group-btn">
|
50
|
-
<button class="btn btn-default" type="button">Go!</button>
|
51
|
-
</span>
|
52
|
-
</div>
|
53
|
-
</form>
|
54
|
-
</ul>
|
55
|
-
</div><!--/.nav-collapse -->
|
56
|
-
</div><!--/.container-fluid -->
|
57
|
-
</nav>
|
24
|
+
var fileSizeKey = data.server_uuid + '-' + data.file_size;
|
25
|
+
if (window.fileSizeDone[fileSizeKey]) return;
|
26
|
+
window.fileSizeDone[fileSizeKey] = true;
|
27
|
+
window.fileSize[data.server_uuid] = data.file_size;
|
58
28
|
|
59
|
-
|
29
|
+
if (!data.content) return;
|
30
|
+
var shouldScrollToBottom = $window.scrollTop() + $window.height() == $document.height();
|
31
|
+
$(data.content).appendTo($content);
|
60
32
|
|
61
|
-
|
33
|
+
if (shouldScrollToBottom) {
|
34
|
+
$window.scrollTop($document.height() - $window.height());
|
35
|
+
}
|
62
36
|
|
63
|
-
|
64
|
-
|
65
|
-
<h3 class="page-header monospace"><%= file_path %></h3>
|
66
|
-
|
67
|
-
<% File.open file_path do |file| end %>
|
68
|
-
<div id="content" class="monospace"></div>
|
69
|
-
|
70
|
-
<script type="text/javascript">
|
71
|
-
window.fileSize = {};
|
72
|
-
window.fileSizeDone = {};
|
73
|
-
var $window = $(window),
|
74
|
-
$document = $(document),
|
75
|
-
$content = $("#content");
|
76
|
-
|
77
|
-
function loadMore() {
|
78
|
-
$.post(window.location.href, { seek: window.fileSize }, function(json) {
|
79
|
-
try {
|
80
|
-
var data = JSON.parse(json);
|
81
|
-
|
82
|
-
var fileSizeKey = data.server_uuid + '-' + data.file_size;
|
83
|
-
if (window.fileSizeDone[fileSizeKey]) return;
|
84
|
-
window.fileSizeDone[fileSizeKey] = true;
|
85
|
-
window.fileSize[data.server_uuid] = data.file_size;
|
86
|
-
|
87
|
-
if (!data.content) return;
|
88
|
-
var shouldScrollToBottom = $window.scrollTop() + $window.height() == $document.height();
|
89
|
-
$(data.content).appendTo($content);
|
90
|
-
|
91
|
-
if (shouldScrollToBottom) {
|
92
|
-
$window.scrollTop($document.height() - $window.height());
|
93
|
-
}
|
94
|
-
|
95
|
-
} catch (error) {
|
96
|
-
console.log(error)
|
97
|
-
}
|
98
|
-
});
|
37
|
+
} catch (error) {
|
38
|
+
console.log(error)
|
99
39
|
}
|
40
|
+
});
|
41
|
+
}
|
100
42
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
<% else %>
|
106
|
-
<div id="content" class="monospace">
|
107
|
-
<% Dir[File.join Tailog.log_path, '**/*.log'].each do |file| %>
|
108
|
-
<% relative_file = Pathname.new(file).relative_path_from(Pathname.new(Tailog.log_path)) %>
|
109
|
-
<a href="?file=<%= relative_file %>"><%= file %></a>
|
110
|
-
<% end %>
|
111
|
-
</div>
|
112
|
-
<% end %>
|
43
|
+
setInterval(loadMore, 3000);
|
44
|
+
loadMore();
|
45
|
+
</script>
|
113
46
|
|
114
|
-
|
115
|
-
|
47
|
+
<% else %>
|
48
|
+
<% Dir[File.join Tailog.log_path, '**/*.log'].each do |file| %>
|
49
|
+
<% relative_file = Pathname.new(file).relative_path_from(Pathname.new(Tailog.log_path)) %>
|
50
|
+
<a href="?file=<%= relative_file %>"><%= file %></a>
|
116
51
|
<% end %>
|
52
|
+
<% end %>
|
117
53
|
|
118
|
-
|
119
|
-
|
120
|
-
|
54
|
+
<% rescue => error %>
|
55
|
+
<%= erb :error, locals: { error: error }, layout: false %>
|
56
|
+
<% end %>
|
data/lib/tailog/version.rb
CHANGED
data/lib/tailog.rb
CHANGED
@@ -42,10 +42,10 @@ module Tailog
|
|
42
42
|
file_size = file.size
|
43
43
|
seek = params[:seek] && params[:seek][Tailog.server_uuid] || file_size
|
44
44
|
file.seek seek.to_i
|
45
|
-
content = erb :'logs/list', locals: { file: file }
|
45
|
+
content = erb :'logs/list', locals: { file: file }, layout: false
|
46
46
|
file.close
|
47
47
|
rescue => error
|
48
|
-
content = erb :error, locals: { error: error }
|
48
|
+
content = erb :error, locals: { error: error }, layout: false
|
49
49
|
end
|
50
50
|
|
51
51
|
{
|
@@ -54,5 +54,9 @@ module Tailog
|
|
54
54
|
content: content
|
55
55
|
}.to_json
|
56
56
|
end
|
57
|
+
|
58
|
+
get '/env' do
|
59
|
+
erb :env
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bbtfr
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -50,7 +50,9 @@ files:
|
|
50
50
|
- Gemfile
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
|
+
- app/views/env.erb
|
53
54
|
- app/views/error.erb
|
55
|
+
- app/views/layout.erb
|
54
56
|
- app/views/logs/index.erb
|
55
57
|
- app/views/logs/list.erb
|
56
58
|
- bin/console
|