Sfoglia il codice sorgente

Configuration to log files when startup

master
patrick 5 anni fa
parent
commit
b641a0867b
3 ha cambiato i file con 12 aggiunte e 9 eliminazioni
  1. +0
    -1
      config.go
  2. +11
    -7
      main.go
  3. +1
    -1
      rpnIn.go

+ 0
- 1
config.go Vedi File

@@ -9,7 +9,6 @@ import (
type AppConfig struct {
Rpn struct {
Url string `json:Url`
UrlTest string `json:UrlTest`
MD5P2P string `json:MD5P2P`
MD5FAT string `json:MD5FAT`
MIDP2P string `json:MIDP2P`

+ 11
- 7
main.go Vedi File

@@ -9,18 +9,20 @@ import (
)

func main() {
readConfig()
//readConfigForTest()
db.h = nil //make sure it's in proper state.

filename := "rpn.superforex." + time.Now().Format("20060102150406") + ".log"
//setup log file
filename := "logs/rpn.superforex." + time.Now().Format("2006-01-02-15-04-06") + ".log"
f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("error opening file: %v", err)
log.Fatalf("Error opening file: %v", err)
}
defer f.Close()
log.SetOutput(f)
log.Println("Server started on: http://localhost:8080")

//Read Config
readConfig()
//readConfigForTest()

//setup http handler
http.HandleFunc("/rpnNameAndCard", rpnNameAndCard) //ask name and card no
@@ -28,10 +30,12 @@ func main() {
http.HandleFunc("/alipay", leanworkInFAT) // leanwork in
fs := wrapHandler(http.FileServer(http.Dir("./PG"))) //leanwork P2P embeded in
http.HandleFunc("/", fs)
http.ListenAndServe(":8080", nil)

//start log file
//start listening
log.Println("Server started on: http://localhost:8080")
http.ListenAndServe(Config.Server.Host+":"+Config.Server.Port, nil)

//program never reach here.
}

func errPage(w http.ResponseWriter, code int, msg string) {

+ 1
- 1
rpnIn.go Vedi File

@@ -118,7 +118,7 @@ func (m *RpnIn) signature() (sig string) {
s += "|pay_result=" + m.Pay_result
s += "|key=" + m.md5key()
sig = md5str(s)
log.Println("signature of rpnIn = " + sig + " using key " + m.md5key())
//log.Println("signature of rpnIn = " + sig + " using key " + m.md5key())
return
}


Loading…
Annulla
Salva