Commit 208cfc10 authored by Bharath Radhakrishnan's avatar Bharath Radhakrishnan

Logger modified

parent ce25b4bb
......@@ -211,13 +211,8 @@ func initializeLogger(serverId int) {
if !DEBUG {
Info = log.New(ioutil.Discard, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
} else {
f, err := os.OpenFile(strconv.Itoa(serverId+CLIENT_PORT), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
fmt.Println("error opening file: %v", err)
}
defer f.Close()
Info = log.New(f, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
Info = log.New(os.Stdout, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
}
Info.Println("Initialized server")
......
package main
import (
//"os"
"fmt"
"os"
//"log"
"os/exec"
"strconv"
......@@ -16,12 +16,20 @@ const (
func TestServersCommunic(i int) {
cmd := exec.Command("go", "run", "replic_kvstore.go", strconv.Itoa(i+1), strconv.Itoa(NUM_SERVERS))
out, err := cmd.CombinedOutput()
f, err := os.OpenFile(strconv.Itoa(i), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
fmt.Println("error opening file: %v", err)
}
defer f.Close()
cmd.Stdout = f
cmd.Stderr = f
cmd.Run()
/*if err != nil {
fmt.Println(err)
}
fmt.Println(string(out))
fmt.Println(string(out))*/
}
func main() {
......
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 to comment