Commit 1d972ac5 by lichenggang

用户自行配置

parent 6ecaf9d1
Showing with 6 additions and 1 deletions
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" {
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment