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
1d972ac5
authored
Dec 31, 2020
by
lichenggang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
用户自行配置
parent
6ecaf9d1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletions
config/config.go
main.go
config/config.go
View file @
1d972ac5
package
config
import
(
"flag"
"log"
"os"
"strings"
...
...
@@ -8,6 +9,7 @@ import (
var
Directory
string
var
UserConfigPath
string
var
Port
string
func
GetCurrentPath
()
string
{
dir
,
err
:=
os
.
Getwd
()
...
...
@@ -17,6 +19,9 @@ func GetCurrentPath() string {
return
strings
.
Replace
(
dir
,
"
\\
"
,
"/"
,
-
1
)
}
func
InitConfig
()
{
flag
.
StringVar
(
&
Directory
,
"dir"
,
"/data/inotify_logs"
,
"监听目录"
)
flag
.
StringVar
(
&
Port
,
"port"
,
"9997"
,
"监听端口"
)
Directory
=
"E:
\\
test_logs"
// directory of the log
logenv
:=
os
.
Getenv
(
"GOLOGENV"
)
if
logenv
==
"TEST"
{
...
...
main.go
View file @
1d972ac5
...
...
@@ -9,7 +9,7 @@ import (
// example
func
main
()
{
addrs
:=
"0.0.0.0:
9997"
addrs
:=
"0.0.0.0:
"
+
config
.
Port
config
.
InitConfig
()
fmt
.
Printf
(
"查看日志目录: %s
\n
用户配置文件: %s"
,
config
.
Directory
,
config
.
UserConfigPath
)
...
...
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