Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

add available context info to debug log file headers #607

Merged
merged 2 commits into from
Jun 11, 2018
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions common/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"os/user"
"runtime"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -36,7 +35,8 @@ type ClientSessionIdentityT struct {

// String is the stringer fn for ClientSessionIdentityT
func (s *ClientSessionIdentityT) String() string {
return fmt.Sprint(s.Goos, s.Goarch, s.SessionID, s.Hostname, s.Username, s.MachineID, strconv.Itoa(s.Pid))
return fmt.Sprintf("VERSION=%s GO=%s GOOS=%s GOARCH=%s SESSIONID=%s HOSTNAME=%s USER=%s MACHINE=%s PID=%d",
s.Version, s.Goversion, s.Goos, s.Goarch, s.SessionID, s.Hostname, s.Username, s.MachineID, s.Pid)
}

// Helpers for random sessionid string.
Expand Down
3 changes: 2 additions & 1 deletion logger/glog/glog.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ import (
"sync/atomic"
"time"

"github.com/ethereumproject/go-ethereum/common"
"github.com/fatih/color"
)

Expand Down Expand Up @@ -1159,8 +1160,8 @@ func (sb *syncBuffer) rotateCurrent(now time.Time) error {
// Write header.
var buf bytes.Buffer
fmt.Fprintf(&buf, "Log file created at: %s\n", now.Format("2006/01/02 15:04:05"))
fmt.Fprintf(&buf, "Running on machine: %s\n", host)
fmt.Fprintf(&buf, "Binary: Built with %s %s for %s/%s\n", runtime.Compiler, runtime.Version(), runtime.GOOS, runtime.GOARCH)
fmt.Fprintf(&buf, "Context: %s\n", common.GetClientSessionIdentity().String())
fmt.Fprintf(&buf, "Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg\n")
n, err := sb.file.Write(buf.Bytes())
sb.nbytes += uint64(n)
Expand Down