Skip to content

Commit

Permalink
assorted log (minor)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Aizman <alex.aizman@gmail.com>
  • Loading branch information
alex-aizman committed Nov 3, 2023
1 parent 6642456 commit e4ce2cb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
15 changes: 8 additions & 7 deletions ais/backend/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ func NewGCP(t cluster.TargetPut) (bp cluster.BackendProvider, err error) {
err = fmt.Errorf("both %q and %q env vars cannot be defined (and not equal %s)",
projectIDEnvVar, credPathEnvVar, projectIDField)
return
} else if credProjectID != "" {
}
switch {
case credProjectID != "":
projectID = credProjectID
nlog.Infof("[cloud_gcp] %s: %q (using %q env variable)", projectIDField, projectID, credPathEnvVar)
} else if envProjectID != "" {
nlog.Infof("%s: %q (using %q env)", projectIDField, projectID, credPathEnvVar)
case envProjectID != "":
projectID = envProjectID
nlog.Infof("[cloud_gcp] %s: %q (using %q env variable)", projectIDField, projectID, projectIDEnvVar)
} else {
nlog.Warningf("[cloud_gcp] unable to determine %q (%q and %q env vars are empty) - using unauthenticated client",
projectIDField, projectIDEnvVar, credPathEnvVar)
nlog.Infof("%s: %q (using %q env)", projectIDField, projectID, projectIDEnvVar)
default:
nlog.Warningln("unauthenticated client")
}
gcpp := &gcpProvider{t: t, projectID: projectID}
bp = gcpp
Expand Down
2 changes: 1 addition & 1 deletion cmn/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ type (
MaxSize cos.SizeIEC `json:"max_size"` // exceeding this size triggers log rotation
MaxTotal cos.SizeIEC `json:"max_total"` // (sum individual log sizes); exceeding this number triggers cleanup
FlushTime cos.Duration `json:"flush_time"` // log flush interval
StatsTime cos.Duration `json:"stats_time"` // log stats interval (must be a multiple of `PeriodConf.StatsTime`)
StatsTime cos.Duration `json:"stats_time"` // (not used)
}
LogConfToSet struct {
Level *cos.LogLevel `json:"level,omitempty"`
Expand Down
4 changes: 3 additions & 1 deletion cmn/k8s/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ func initDetect() {
return
}
nodeName = pod.Spec.NodeName
nlog.Infoln("pod.Spec.NodeName", nodeName, "Volumes", pod.Spec.Volumes, "Spec.Hostname", pod.Spec.Hostname,
"Spec.HostNetwork", pod.Spec.HostNetwork)

checkNode:
node, err := client.Node(nodeName)
Expand All @@ -73,7 +75,7 @@ checkNode:
}

NodeName = node.Name
nlog.Infof("Successfully got node name %q, assuming Kubernetes deployment", NodeName)
nlog.Infoln("Kubernetes Node.Name", NodeName, "Namespace", node.Namespace)
}

func Detect() error {
Expand Down
2 changes: 1 addition & 1 deletion cmn/nlog/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func fcreate(tag string, t time.Time) (f *os.File, fname string, err error) {
if err != nil {
return
}
// re-slink
// re-symlink
symlink := filepath.Join(logDir, link)
os.Remove(symlink)
os.Symlink(name, symlink)
Expand Down
12 changes: 8 additions & 4 deletions cmn/nlog/nlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,19 +215,23 @@ func (nlog *nlog) do(pw *fixed) {

func (nlog *nlog) rotate(now time.Time) (err error) {
var (
s = fmt.Sprintf("host %s, %s for %s/%s\n", host, runtime.Version(), runtime.GOOS, runtime.GOARCH)
snow = now.Format("2006/01/02 15:04:05")
line1 string
s = fmt.Sprintf("host %s, %s for %s/%s\n", host, runtime.Version(), runtime.GOOS, runtime.GOARCH)
snow = now.Format("2006/01/02 15:04:05")
)
if nlog.file, _, err = fcreate(sevText[nlog.sev], now); err != nil {
nlog.erred.Store(true)
return
}

nlog.written.Store(0)
nlog.erred.Store(false)
if title == "" {
_, err = nlog.file.WriteString("Started up at " + snow + ", " + s)
line1 = "Started up at " + snow + ", " + s
_, err = nlog.file.WriteString(line1)
} else {
nlog.file.WriteString("Rotated at " + snow + ", " + s)
line1 = "Rotated at " + snow + ", " + s
nlog.file.WriteString(line1)
_, err = nlog.file.WriteString(title)
}
return
Expand Down

0 comments on commit e4ce2cb

Please sign in to comment.