Skip to content

Commit

Permalink
添加error.log显示
Browse files Browse the repository at this point in the history
  • Loading branch information
zyh001 authored Aug 20, 2018
2 parents b2cf0fa + 175a421 commit 138a325
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
16 changes: 14 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ def get_info():

return json_dump

@app.route('/get_log')
def get_log():
@app.route('/get_access_log')
def get_access_log():
file = open('/var/log/v2ray/access.log',"r")
content = file.read().split("\n")
min_length = min(20,len(content))
Expand All @@ -213,6 +213,18 @@ def get_log():
string = string + content[i] + "<br>"
return string

@app.route('/get_error_log')
def get_error_log():
file = open('/var/log/v2ray/error.log',"r")
content = file.read().split("\n")
min_length = min(20,len(content))
content = content[-min_length:]
string = ""
for i in range(min_length):
string = string + content[i] + "<br>"
return string



@app.route('/gen_ssl',methods=['GET', 'POST'])
def gen_ssl():
Expand Down
37 changes: 22 additions & 15 deletions templates/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
<a href="https://github.com/FunctionClub/" target="_blank" class="mdui-btn mdui-btn-icon mdui-ripple mdui-ripple-white" mdui-tooltip="{content: 'Github'}">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 36 36" enable-background="new 0 0 36 36" xml:space="preserve" class="mdui-icon" style="width: 24px;height:24px;">
<path fill-rule="evenodd" clip-rule="evenodd" fill="#ffffff" d="M18,1.4C9,1.4,1.7,8.7,1.7,17.7c0,7.2,4.7,13.3,11.1,15.5
c0.8,0.1,1.1-0.4,1.1-0.8c0-0.4,0-1.4,0-2.8c-4.5,1-5.5-2.2-5.5-2.2c-0.7-1.9-1.8-2.4-1.8-2.4c-1.5-1,0.1-1,0.1-1
c1.6,0.1,2.5,1.7,2.5,1.7c1.5,2.5,3.8,1.8,4.7,1.4c0.1-1.1,0.6-1.8,1-2.2c-3.6-0.4-7.4-1.8-7.4-8.1c0-1.8,0.6-3.2,1.7-4.4
c-0.2-0.4-0.7-2.1,0.2-4.3c0,0,1.4-0.4,4.5,1.7c1.3-0.4,2.7-0.5,4.1-0.5c1.4,0,2.8,0.2,4.1,0.5c3.1-2.1,4.5-1.7,4.5-1.7
c0.9,2.2,0.3,3.9,0.2,4.3c1,1.1,1.7,2.6,1.7,4.4c0,6.3-3.8,7.6-7.4,8c0.6,0.5,1.1,1.5,1.1,3c0,2.2,0,3.9,0,4.5
c0,0.4,0.3,0.9,1.1,0.8c6.5-2.2,11.1-8.3,11.1-15.5C34.3,8.7,27,1.4,18,1.4z"></path>
c0.8,0.1,1.1-0.4,1.1-0.8c0-0.4,0-1.4,0-2.8c-4.5,1-5.5-2.2-5.5-2.2c-0.7-1.9-1.8-2.4-1.8-2.4c-1.5-1,0.1-1,0.1-1
c1.6,0.1,2.5,1.7,2.5,1.7c1.5,2.5,3.8,1.8,4.7,1.4c0.1-1.1,0.6-1.8,1-2.2c-3.6-0.4-7.4-1.8-7.4-8.1c0-1.8,0.6-3.2,1.7-4.4
c-0.2-0.4-0.7-2.1,0.2-4.3c0,0,1.4-0.4,4.5,1.7c1.3-0.4,2.7-0.5,4.1-0.5c1.4,0,2.8,0.2,4.1,0.5c3.1-2.1,4.5-1.7,4.5-1.7
c0.9,2.2,0.3,3.9,0.2,4.3c1,1.1,1.7,2.6,1.7,4.4c0,6.3-3.8,7.6-7.4,8c0.6,0.5,1.1,1.5,1.1,3c0,2.2,0,3.9,0,4.5
c0,0.4,0.3,0.9,1.1,0.8c6.5-2.2,11.1-8.3,11.1-15.5C34.3,8.7,27,1.4,18,1.4z"></path>
</svg>
</a>
</div>
Expand Down Expand Up @@ -60,7 +60,7 @@
<table class="mdui-table">
<thead>
<tr>
<th>
<th colspan="2">
<div class="mdui-row">
运行日志 (实时刷新)
</div>
Expand All @@ -73,14 +73,20 @@
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="mdui-row" style="width: 100%">
<pre><code id="log-content" class="language-css"></code></pre>
</div>
</td>

</tr>
<tr>
<td style="width: 50%">
<div class="mdui-row" style="width: 100%">
access.log
<pre><code id="log-access-content" class="language-css"></code></pre>
</div>
</td>
<td style="width: 50%">
<div class="mdui-row" style="width: 100%">
error.log
<pre><code id="log-error-content" class="language-css"></code></pre>
</div>
</td>
</tr>
</tbody>
</table>
</div>
Expand All @@ -94,7 +100,8 @@


function timer() {
$('#log-content').load('/get_log');
$('#log-access-content').load('/get_access_log');
$('#log-error-content').load('/get_error_log');
var t=setTimeout("timer()",1500);
}
timer()
Expand Down

0 comments on commit 138a325

Please sign in to comment.