Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add [etcd] as the prefix of the logging info #4

Merged
merged 1 commit into from
Jul 9, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ import (
"github.com/coreos/etcd/web"
"io"
"io/ioutil"
"log"
"net/http"
"os"
)

//--------------------------------------
// Web Helper
//--------------------------------------
var storeMsg chan string

// Help to send msg from stroe to webHub
func webHelper() {
storeMsg = make(chan string)
for {
// transfere the new msg to webHub
web.Hub().Send(<-storeMsg)
}
}
Expand All @@ -28,7 +32,7 @@ func webHelper() {
func decodeJsonRequest(req *http.Request, data interface{}) error {
decoder := json.NewDecoder(req.Body)
if err := decoder.Decode(&data); err != nil && err != io.EOF {
logger.Println("Malformed json request: %v", err)
warn("Malformed json request: %v", err)
return fmt.Errorf("Malformed json request: %v", err)
}
return nil
Expand Down Expand Up @@ -79,6 +83,12 @@ func leaderClient() string {
// Log
//--------------------------------------

var logger *log.Logger

func init() {
logger = log.New(os.Stdout, "[etcd] ", log.Lmicroseconds)
}

func debug(msg string, v ...interface{}) {
if verbose {
logger.Printf("DEBUG "+msg+"\n", v...)
Expand All @@ -90,7 +100,7 @@ func info(msg string, v ...interface{}) {
}

func warn(msg string, v ...interface{}) {
logger.Printf("Alpaca Server: WARN "+msg+"\n", v...)
logger.Printf("WARN "+msg+"\n", v...)
}

func fatal(msg string, v ...interface{}) {
Expand Down