nfo

Go Client

Go HTTP client for the nfo centralized logging service.

What it shows

Prerequisites

Start the HTTP service first:

python examples/http-service/main.py

Run

cd examples/go-client
go run main.go

Key code

type LogEntry struct {
    Cmd  string   `json:"cmd"`
    Args []string `json:"args"`
    Lang string   `json:"language"`
}

func NfoLog(cmd string, args ...string) {
    entry := LogEntry{Cmd: cmd, Args: args, Lang: "go"}
    jsonData, _ := json.Marshal(entry)
    http.Post(nfoURL+"/log", "application/json",
              bytes.NewBuffer(jsonData))
}