summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-10-29 08:31:26 +0300
committerPaul Buetow <paul@buetow.org>2021-10-29 08:31:26 +0300
commitffa39a17f48ee9847cc85819d8134b5eb9482b77 (patch)
tree22ac90a46160ccc2927ba0a5b4406906072a56bb /internal
parentf9c51eb8bc3295c52dfde821aaed324f9447a993 (diff)
explicitly use dlog.Server for server packages and dlog.Clent for client packages for logging
Diffstat (limited to 'internal')
-rw-r--r--internal/mapr/client/aggregate.go2
-rw-r--r--internal/mapr/server/aggregate.go24
-rw-r--r--internal/ssh/client/clientkeypair.go14
-rw-r--r--internal/ssh/client/knownhostscallback.go12
-rw-r--r--internal/ssh/server/hostkey.go10
-rw-r--r--internal/ssh/server/publickeycallback.go10
6 files changed, 36 insertions, 36 deletions
diff --git a/internal/mapr/client/aggregate.go b/internal/mapr/client/aggregate.go
index 02a6a5a..1704d43 100644
--- a/internal/mapr/client/aggregate.go
+++ b/internal/mapr/client/aggregate.go
@@ -54,7 +54,7 @@ func (a *Aggregate) Aggregate(message string) error {
for _, sc := range a.query.Select {
if val, ok := fields[sc.FieldStorage]; ok {
if err := set.Aggregate(sc.FieldStorage, sc.Operation, val, true); err != nil {
- dlog.Common.Error(err)
+ dlog.Client.Error(err)
continue
}
addedSamples = true
diff --git a/internal/mapr/server/aggregate.go b/internal/mapr/server/aggregate.go
index 4162828..cb0da2b 100644
--- a/internal/mapr/server/aggregate.go
+++ b/internal/mapr/server/aggregate.go
@@ -39,7 +39,7 @@ func NewAggregate(queryStr string) (*Aggregate, error) {
fqdn, err := config.Hostname()
if err != nil {
- dlog.Common.Error(err)
+ dlog.Server.Error(err)
}
s := strings.Split(fqdn, ".")
@@ -54,12 +54,12 @@ func NewAggregate(queryStr string) (*Aggregate, error) {
parserName = query.LogFormat
}
- dlog.Common.Info("Creating log format parser", parserName)
+ dlog.Server.Info("Creating log format parser", parserName)
logParser, err := logformat.NewParser(parserName, query)
if err != nil {
- dlog.Common.Error("Could not create log format parser. Falling back to 'generic'", err)
+ dlog.Server.Error("Could not create log format parser. Falling back to 'generic'", err)
if logParser, err = logformat.NewParser("generic", query); err != nil {
- dlog.Common.FatalPanic("Could not create log format parser", err)
+ dlog.Server.FatalPanic("Could not create log format parser", err)
}
}
@@ -115,7 +115,7 @@ func (a *Aggregate) aggregateTimer(ctx context.Context) {
func (a *Aggregate) nextLine() (line line.Line, ok bool, noMoreChannels bool) {
- dlog.Common.Trace("nextLine", "entry", line, ok, noMoreChannels)
+ dlog.Server.Trace("nextLine", "entry", line, ok, noMoreChannels)
select {
case line, ok = <-a.linesCh:
if !ok {
@@ -137,7 +137,7 @@ func (a *Aggregate) nextLine() (line line.Line, ok bool, noMoreChannels bool) {
// No new lines channel found.
}
}
- dlog.Common.Trace("nextLine", "exit", line, ok, noMoreChannels)
+ dlog.Server.Trace("nextLine", "exit", line, ok, noMoreChannels)
return
}
@@ -180,7 +180,7 @@ func (a *Aggregate) fieldsFromLines(ctx context.Context) <-chan map[string]strin
if err != nil {
// Should fields be ignored anyway?
if err != logformat.ErrIgnoreFields {
- dlog.Common.Error(fields, err)
+ dlog.Server.Error(fields, err)
}
continue
}
@@ -210,7 +210,7 @@ func (a *Aggregate) setAdditionalFields(ctx context.Context,
return
}
if err := a.query.SetClause(fields); err != nil {
- dlog.Common.Error(err)
+ dlog.Server.Error(err)
}
select {
@@ -227,7 +227,7 @@ func (a *Aggregate) aggregateAndSerialize(ctx context.Context,
group := mapr.NewGroupSet()
serialize := func() {
- dlog.Common.Info("Serializing mapreduce result")
+ dlog.Server.Info("Serializing mapreduce result")
group.Serialize(ctx, maprMessages)
group = mapr.NewGroupSet()
}
@@ -264,7 +264,7 @@ func (a *Aggregate) aggregate(group *mapr.GroupSet, fields map[string]string) {
for _, sc := range a.query.Select {
if val, ok := fields[sc.Field]; ok {
if err := set.Aggregate(sc.FieldStorage, sc.Operation, val, false); err != nil {
- dlog.Common.Error(err)
+ dlog.Server.Error(err)
continue
}
addedSample = true
@@ -275,7 +275,7 @@ func (a *Aggregate) aggregate(group *mapr.GroupSet, fields map[string]string) {
set.Samples++
return
}
- dlog.Common.Trace("Aggregated data locally without adding new samples")
+ dlog.Server.Trace("Aggregated data locally without adding new samples")
}
// Serialize all the aggregated data.
@@ -283,7 +283,7 @@ func (a *Aggregate) Serialize(ctx context.Context) {
select {
case a.serialize <- struct{}{}:
case <-time.After(time.Minute):
- dlog.Common.Warn("Starting to serialize mapredice data takes over a minute")
+ dlog.Server.Warn("Starting to serialize mapredice data takes over a minute")
case <-ctx.Done():
}
}
diff --git a/internal/ssh/client/clientkeypair.go b/internal/ssh/client/clientkeypair.go
index 0e21d0c..b35b25d 100644
--- a/internal/ssh/client/clientkeypair.go
+++ b/internal/ssh/client/clientkeypair.go
@@ -16,7 +16,7 @@ import (
// GeneratePrivatePublicKeyPairIfNotExists generates a SSH key pair (used by the integration tests)
func GeneratePrivatePublicKeyPairIfNotExists(keyPath string, bitSize int) {
if _, err := os.Stat(keyPath); err == nil {
- dlog.Common.Debug("Private/public key pair already exists", keyPath)
+ dlog.Client.Debug("Private/public key pair already exists", keyPath)
return
}
GeneratePrivatePublicKeyPair(keyPath, bitSize)
@@ -27,27 +27,27 @@ func GeneratePrivatePublicKeyPair(keyPath string, bitSize int) {
privateKeyPath := keyPath
publicKeyPath := fmt.Sprintf("%s.pub", keyPath)
- dlog.Common.Debug("Generating private/public key pair", privateKeyPath, publicKeyPath)
+ dlog.Client.Debug("Generating private/public key pair", privateKeyPath, publicKeyPath)
privateKey, err := generatePrivateKey(bitSize)
if err != nil {
- dlog.Common.FatalPanic(err)
+ dlog.Client.FatalPanic(err)
}
publicKeyBytes, err := generatePublicKey(&privateKey.PublicKey)
if err != nil {
- dlog.Common.FatalPanic(err)
+ dlog.Client.FatalPanic(err)
}
privateKeyBytes := encodePrivateKeyToPEM(privateKey)
err = writeKey(privateKeyBytes, privateKeyPath)
if err != nil {
- dlog.Common.FatalPanic(err)
+ dlog.Client.FatalPanic(err)
}
err = writeKey([]byte(publicKeyBytes), publicKeyPath)
if err != nil {
- dlog.Common.FatalPanic(err)
+ dlog.Client.FatalPanic(err)
}
- dlog.Common.Debug("Done generating private/public key pair", privateKeyPath, publicKeyPath)
+ dlog.Client.Debug("Done generating private/public key pair", privateKeyPath, publicKeyPath)
}
func generatePrivateKey(bitSize int) (*rsa.PrivateKey, error) {
diff --git a/internal/ssh/client/knownhostscallback.go b/internal/ssh/client/knownhostscallback.go
index dd58925..393c4c7 100644
--- a/internal/ssh/client/knownhostscallback.go
+++ b/internal/ssh/client/knownhostscallback.go
@@ -93,7 +93,7 @@ func (c KnownHostsCallback) Wrap() ssh.HostKeyCallback {
ipLine: knownhosts.Line([]string{remote.String()}, key),
responseCh: make(chan response),
}
- dlog.Common.Warn("Encountered unknown host", unknown)
+ dlog.Client.Warn("Encountered unknown host", unknown)
// Notify user that there is an unknown host
c.unknownCh <- unknown
// Wait for user input.
@@ -132,7 +132,7 @@ func (c KnownHostsCallback) PromptAddHosts(ctx context.Context) {
hosts = []unknownHost{}
}
case <-ctx.Done():
- dlog.Common.Debug("Stopping goroutine prompting new hosts...")
+ dlog.Client.Debug("Stopping goroutine prompting new hosts...")
return
}
}
@@ -146,7 +146,7 @@ func (c KnownHostsCallback) promptAddHosts(hosts []unknownHost) {
select {
case <-c.trustAllHostsCh:
- dlog.Common.Warn("Trusting host keys of servers", servers)
+ dlog.Client.Warn("Trusting host keys of servers", servers)
c.trustHosts(hosts)
return
default:
@@ -166,7 +166,7 @@ func (c KnownHostsCallback) promptAddHosts(hosts []unknownHost) {
c.trustHosts(hosts)
},
EndCallback: func() {
- dlog.Common.Info("Added hosts to known hosts file", c.knownHostsPath)
+ dlog.Client.Info("Added hosts to known hosts file", c.knownHostsPath)
},
}
p.Add(a)
@@ -179,7 +179,7 @@ func (c KnownHostsCallback) promptAddHosts(hosts []unknownHost) {
c.trustHosts(hosts)
},
EndCallback: func() {
- dlog.Common.Info("Added hosts to known hosts file", c.knownHostsPath)
+ dlog.Client.Info("Added hosts to known hosts file", c.knownHostsPath)
},
}
p.Add(a)
@@ -191,7 +191,7 @@ func (c KnownHostsCallback) promptAddHosts(hosts []unknownHost) {
c.dontTrustHosts(hosts)
},
EndCallback: func() {
- dlog.Common.Info("Didn't add hosts to known hosts file", c.knownHostsPath)
+ dlog.Client.Info("Didn't add hosts to known hosts file", c.knownHostsPath)
},
}
p.Add(a)
diff --git a/internal/ssh/server/hostkey.go b/internal/ssh/server/hostkey.go
index 4844d36..be23d85 100644
--- a/internal/ssh/server/hostkey.go
+++ b/internal/ssh/server/hostkey.go
@@ -18,25 +18,25 @@ func PrivateHostKey() []byte {
_, err := os.Stat(hostKeyFile)
if os.IsNotExist(err) {
- dlog.Common.Info("Generating private server RSA host key")
+ dlog.Server.Info("Generating private server RSA host key")
privateKey, err := ssh.GeneratePrivateRSAKey(config.Server.HostKeyBits)
if err != nil {
- dlog.Common.FatalPanic("Failed to generate private server RSA host key", err)
+ dlog.Server.FatalPanic("Failed to generate private server RSA host key", err)
}
pem := ssh.EncodePrivateKeyToPEM(privateKey)
if err := ioutil.WriteFile(hostKeyFile, pem, 0600); err != nil {
- dlog.Common.Error("Unable to write private server RSA host key to file",
+ dlog.Server.Error("Unable to write private server RSA host key to file",
hostKeyFile, err)
}
return pem
}
- dlog.Common.Info("Reading private server RSA host key from file", hostKeyFile)
+ dlog.Server.Info("Reading private server RSA host key from file", hostKeyFile)
pem, err := ioutil.ReadFile(hostKeyFile)
if err != nil {
- dlog.Common.FatalPanic("Failed to load private server RSA host key", err)
+ dlog.Server.FatalPanic("Failed to load private server RSA host key", err)
}
return pem
}
diff --git a/internal/ssh/server/publickeycallback.go b/internal/ssh/server/publickeycallback.go
index 585469f..c661419 100644
--- a/internal/ssh/server/publickeycallback.go
+++ b/internal/ssh/server/publickeycallback.go
@@ -23,9 +23,9 @@ func PublicKeyCallback(c gossh.ConnMetadata,
return nil, err
}
- dlog.Common.Info(user, "Incoming authorization")
+ dlog.Server.Info(user, "Incoming authorization")
if config.ServerRelaxedAuthEnable {
- dlog.Common.Fatal(user, "Granting permissions via relaxed-auth")
+ dlog.Server.Fatal(user, "Granting permissions via relaxed-auth")
return nil, nil
}
@@ -34,7 +34,7 @@ func PublicKeyCallback(c gossh.ConnMetadata,
return nil, err
}
- dlog.Common.Info(user, "Reading", authorizedKeysFile)
+ dlog.Server.Info(user, "Reading", authorizedKeysFile)
authorizedKeysBytes, err := ioutil.ReadFile(authorizedKeysFile)
if err != nil {
return nil, fmt.Errorf("Unable to read authorized keys file|%s|%s|%s",
@@ -56,11 +56,11 @@ func verifyAuthorizedKeys(user *user.User, authorizedKeysBytes []byte,
}
authorizedKeysMap[string(authorizedPubKey.Marshal())] = true
authorizedKeysBytes = restBytes
- dlog.Common.Debug(user, "Authorized public key fingerprint",
+ dlog.Server.Debug(user, "Authorized public key fingerprint",
gossh.FingerprintSHA256(authorizedPubKey))
}
- dlog.Common.Debug(user, "Offered public key fingerprint", gossh.FingerprintSHA256(offeredPubKey))
+ dlog.Server.Debug(user, "Offered public key fingerprint", gossh.FingerprintSHA256(offeredPubKey))
if authorizedKeysMap[string(offeredPubKey.Marshal())] {
return &gossh.Permissions{
Extensions: map[string]string{"pubkey-fp": gossh.FingerprintSHA256(offeredPubKey)},