Skip to content

Commit

Permalink
logging: Fixed debug log level checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfox-equinix authored and stephen-fox committed Mar 28, 2023
1 parent a248450 commit 963a846
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func Run(ctx context.Context, osArgs []string, h *common.Health, optLoggerConfig

eg.Go(func() error {
err := logDirReader.Wait()
if logger.Level() == zap.DebugLevel {
if logger.Level().Enabled(zap.DebugLevel) {
logger.Debugf("linux audit log dir reader worker exited (%v)", err)
}
return err
Expand All @@ -143,7 +143,7 @@ func Run(ctx context.Context, osArgs []string, h *common.Health, optLoggerConfig
}

err := jp.Read(groupCtx)
if logger.Level() == zap.DebugLevel {
if logger.Level().Enabled(zap.DebugLevel) {
logger.Debugf("journald worker exited (%v)", err)
}
return err
Expand All @@ -160,7 +160,7 @@ func Run(ctx context.Context, osArgs []string, h *common.Health, optLoggerConfig
}

err := ap.Read(groupCtx)
if logger.Level() == zap.DebugLevel {
if logger.Level().Enabled(zap.DebugLevel) {
logger.Debugf("audit worker exited (%v)", err)
}
return err
Expand Down
8 changes: 4 additions & 4 deletions internal/auditd/sessiontracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type sessionTracker struct {

func (o *sessionTracker) remoteLogin(rul common.RemoteUserLogin) error {
var debugLogger *zap.SugaredLogger
if logger.Level() == zap.DebugLevel {
if logger.Level().Enabled(zap.DebugLevel) {
debugLogger = logger.With("RemoteUserLogin", rul)
debugLogger.Debugln("new remote user login")
}
Expand Down Expand Up @@ -113,7 +113,7 @@ func (o *sessionTracker) auditdEvent(event *aucoalesce.Event) error {
}

var debugLogger *zap.SugaredLogger
if logger.Level() == zap.DebugLevel {
if logger.Level().Enabled(zap.DebugLevel) {
debugLogger = logger.With(
"auditEvent", *event,
"auditEventType", event.Type.String(),
Expand Down Expand Up @@ -242,7 +242,7 @@ func (o *sessionTracker) auditdEvent(event *aucoalesce.Event) error {

func (o *sessionTracker) deleteUsersWithoutLoginsBefore(t time.Time) {
var debugLogger *zap.SugaredLogger
if logger.Level() == zap.DebugLevel {
if logger.Level().Enabled(zap.DebugLevel) {
debugLogger = logger.With(
"cacheCleanup", "deleteUsersWithoutLoginsBefore",
"before", t.String())
Expand All @@ -264,7 +264,7 @@ func (o *sessionTracker) deleteUsersWithoutLoginsBefore(t time.Time) {

func (o *sessionTracker) deleteRemoteUserLoginsBefore(t time.Time) {
var debugLogger *zap.SugaredLogger
if logger.Level() == zap.DebugLevel {
if logger.Level().Enabled(zap.DebugLevel) {
debugLogger = logger.With(
"cacheCleanup", "deleteRemoteUserLoginsBefore",
"before", t.String())
Expand Down
2 changes: 1 addition & 1 deletion internal/journald/processentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func processAcceptPublicKeyEntry(config *processEntryConfig) error {
}

var debugLogger *zap.SugaredLogger
if logger.Level() == zap.DebugLevel {
if logger.Level().Enabled(zap.DebugLevel) {
debugLogger = logger.With("eventPID", config.pid)
debugLogger.Debugln("writing event to auditevent writer...")
}
Expand Down

0 comments on commit 963a846

Please sign in to comment.