Skip to content

Commit

Permalink
fix parameters default value
Browse files Browse the repository at this point in the history
  • Loading branch information
TenderIronh committed Dec 30, 2021
1 parent 029d698 commit ac454ec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
21 changes: 7 additions & 14 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const (
type V8log struct {
loggers map[LogLevel]*log.Logger
files map[LogLevel]*os.File
llevel LogLevel
level LogLevel
stopSig chan bool
logDir string
mtx *sync.Mutex
Expand Down Expand Up @@ -92,17 +92,10 @@ func InitLogger(path string, filePrefix string, level LogLevel, maxLogSize int64
return pLog
}

// UninitLogger ...
func (vl *V8log) UninitLogger() {
if !vl.stoped {
vl.stoped = true
close(vl.stopSig)
for l := range logFileNames {
if l >= vl.llevel {
vl.files[l].Close()
}
}
}
func (vl *V8log) setLevel(level LogLevel) {
vl.mtx.Lock()
defer vl.mtx.Unlock()
vl.level = level
}

func (vl *V8log) checkFile() {
Expand Down Expand Up @@ -150,7 +143,7 @@ func (vl *V8log) Printf(level LogLevel, format string, params ...interface{}) {
if vl.stoped {
return
}
if level < vl.llevel {
if level < vl.level {
return
}
pidAndLevel := []interface{}{vl.pid, loglevel[level]}
Expand All @@ -170,7 +163,7 @@ func (vl *V8log) Println(level LogLevel, params ...interface{}) {
if vl.stoped {
return
}
if level < vl.llevel {
if level < vl.level {
return
}
pidAndLevel := []interface{}{vl.pid, " ", loglevel[level], " "}
Expand Down
19 changes: 17 additions & 2 deletions openp2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func main() {
rand.Seed(time.Now().UnixNano())
binDir := filepath.Dir(os.Args[0])
os.Chdir(binDir) // for system service
gLog = InitLogger(binDir, "openp2p", LevelDEBUG, 1024*1024, LogFileAndConsole)
// TODO: install sub command, deamon process
// groups := flag.String("groups", "", "you could join in several groups. like: GroupName1:Password1;GroupName2:Password2; group name 8-31 characters")
if len(os.Args) > 1 {
Expand Down Expand Up @@ -74,7 +75,7 @@ func main() {
gConf.add(config)
gConf.load()
gConf.mtx.Lock()

gLog.setLevel(LogLevel(gConf.logLevel))
flag.Visit(func(f *flag.Flag) {
if f.Name == "sharebandwidth" {
gConf.Network.ShareBandwidth = *shareBandwidth
Expand All @@ -95,7 +96,21 @@ func main() {
gConf.logLevel = *logLevel
}
})
gLog = InitLogger(binDir, "openp2p", LogLevel(gConf.logLevel), 1024*1024, LogFileAndConsole)
if gConf.Network.ServerHost == "" {
gConf.Network.ServerHost = *serverHost
}
if gConf.Network.Node == "" {
gConf.Network.Node = *node
}
if gConf.Network.User == "" {
gConf.Network.User = *user
}
if gConf.Network.Password == "" {
gConf.Network.Password = *password
}
gConf.Network.ServerPort = 27182
gConf.Network.UDPPort1 = 27182
gConf.Network.UDPPort2 = 27183
gLog.Println(LevelINFO, "openp2p start. version: ", OpenP2PVersion)
gConf.mtx.Unlock()
gConf.save()
Expand Down
2 changes: 1 addition & 1 deletion protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"
)

const OpenP2PVersion = "0.98.0"
const OpenP2PVersion = "0.98.1"
const ProducnName string = "openp2p"

type openP2PHeader struct {
Expand Down

0 comments on commit ac454ec

Please sign in to comment.