Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lichenggang
/
web_log
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e1e29920
authored
Jan 04, 2021
by
lichenggang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加readme
parent
89eccf1d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
10 deletions
README.md
config/config.go
main.go
utils/util.go
web/views/page.html
README.md
0 → 100644
View file @
e1e29920
# web_log
## 项目简介
####1. 开发人员
李成刚, 郑宗霖, 陈森彬
####2. 主要用途
-
实时监控特定目录下的日志目录和日志文件
-
登录后可在外网浏览器上进行浏览
####3. 使用方式
```
code
go run main.go -p 9997 -d /data/logs
```
参数说明
-d 需要监听的日志目录目录 (必填)
-p 端口 (选填,默认为9997端口)
config/config.go
View file @
e1e29920
...
...
@@ -2,6 +2,7 @@ package config
import
(
"flag"
"fmt"
"log"
"os"
"strings"
...
...
@@ -19,16 +20,20 @@ func GetCurrentPath() string {
return
strings
.
Replace
(
dir
,
"
\\
"
,
"/"
,
-
1
)
}
func
InitConfig
()
{
Directory
=
"E:
\\
test_logs"
// directory of the log
flag
.
StringVar
(
&
Directory
,
"d"
,
"/data/inotify_logs"
,
"监听目录"
)
flag
.
StringVar
(
&
Port
,
"p
ort
"
,
"9997"
,
"监听端口"
)
flag
.
StringVar
(
&
Port
,
"p"
,
"9997"
,
"监听端口"
)
flag
.
Parse
()
logenv
:=
os
.
Getenv
(
"GOLOGENV"
)
if
logenv
==
"TEST"
{
Directory
=
"/data/soft/bigdatav3.0/test_rsync_log"
}
if
logenv
==
"PRODUCT"
{
Directory
=
"/data/inotify_logs"
_
,
err
:=
os
.
Stat
(
Directory
)
if
err
!=
nil
{
fmt
.
Printf
(
"目录: [%s] 不存在, 请重新用[-d]参数指定目录"
,
Directory
)
os
.
Exit
(
0
)
}
//logenv := os.Getenv("GOLOGENV")
//if logenv == "TEST" {
// Directory = "/data/soft/bigdatav3.0/test_rsync_log"
//}
//if logenv == "PRODUCT" {
// Directory = "/data/inotify_logs"
//}
UserConfigPath
=
GetCurrentPath
()
+
"/config/users.json"
}
main.go
View file @
e1e29920
...
...
@@ -13,7 +13,7 @@ func main() {
config
.
InitConfig
()
addrs
:=
"0.0.0.0:"
+
config
.
Port
fmt
.
Printf
(
"查看日志目录: %s
\n
用户配置文件: %s"
,
config
.
Directory
,
config
.
UserConfigPath
)
fmt
.
Printf
(
"查看日志目录: %s
\n
用户配置文件: %s
\n
"
,
config
.
Directory
,
config
.
UserConfigPath
)
app
:=
code
.
GetApp
(
config
.
Directory
)
app
.
Run
(
iris
.
Addr
(
addrs
),
iris
.
WithCharset
(
"UTF-8"
))
...
...
utils/util.go
0 → 100644
View file @
e1e29920
package
utils
import
"os"
func
PathExists
(
path
string
)
(
bool
,
error
)
{
_
,
err
:=
os
.
Stat
(
path
)
if
err
==
nil
{
return
true
,
nil
}
if
os
.
IsNotExist
(
err
)
{
return
false
,
nil
}
return
false
,
err
}
web/views/page.html
View file @
e1e29920
...
...
@@ -142,7 +142,8 @@
<body>
<header>
<h2
id=
"title"
>
实时查看日志信息
<button
id=
"status"
style=
"background-color: darkorange"
>
正在连接...
</button>
<h2
id=
"title"
style=
"margin: 1px"
>
实时查看日志信息
<button
id=
"status"
style=
"background-color: darkorange"
>
正在连接...
</button>
<h5
style=
"margin: 1px"
>
(默认显示最后500行)
</h5>
</h2>
<div
class=
"tool"
>
<button
id=
"pause"
>
暂停
</button>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment