Skip to content

Commit

Permalink
GOCBC-257: Implement log redaction.
Browse files Browse the repository at this point in the history
Motivation
----------
Due to ongoing changes in the space of user information security,
in many cases, organizations are in need of the ability to ensure
that various pieces of data from their infrastructure are not
written to log files.  We've implemented the ability to automatically
redact this information from logs.

Changes
-------
Added a SetRedactionLevel method to the client which enables you to
specify the degree you wish to redact that logs.

Change-Id: I41cc46a4ab6e619470ccfad9185b7e933c2bd147
Reviewed-on: http://review.couchbase.org/90164
Reviewed-by: Ellis Breen <ellis.breen@couchbase.com>
Reviewed-by: Mike Goldsmith <goldsmith.mike@gmail.com>
Tested-by: Brett Lawson <brett19@gmail.com>
  • Loading branch information
brett19 committed Mar 21, 2018
1 parent ea9c23c commit 36e4e5d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ const (
LogMaxVerbosity = LogLevel(gocbcore.LogMaxVerbosity)
)

// LogRedactLevel specifies the degree with which to redact the logs.
type LogRedactLevel int

const (
// RedactNone indicates to perform no redactions
RedactNone = LogRedactLevel(0)

// RedactPartial indicates to redact all possible user-identifying information from logs.
RedactPartial = LogRedactLevel(1)

// RedactFull indicates to fully redact all possible identifying information from logs.
RedactFull = LogRedactLevel(1)
)

// SetLogRedactionLevel specifies the level with which logs should be redacted.
func SetLogRedactionLevel(level LogRedactLevel) {
// We don't current log any data that falls under our current redaction rules.
// This function is included as a stub for future implementations of log redaction
// that act at a higher level and may need to perform actual redaction's.
}

// Logger defines a logging interface. You can either use one of the default loggers
// (DefaultStdioLogger(), VerboseStdioLogger()) or implement your own.
type Logger interface {
Expand Down Expand Up @@ -99,6 +120,10 @@ func logExf(level LogLevel, offset int, format string, v ...interface{}) {
}
}

func logInfof(format string, v ...interface{}) {
logExf(LogInfo, 1, format, v...)
}

func logDebugf(format string, v ...interface{}) {
logExf(LogDebug, 1, format, v...)
}
Expand Down

0 comments on commit 36e4e5d

Please sign in to comment.