Skip to content

Commit e2fd555

Browse files
authored
Merge pull request #133 from pohly/nil-logger
docs: describe handling of optional logger parameters
2 parents eb02c45 + 68ef51c commit e2fd555

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

logr.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ limitations under the License.
115115
// may be any Go value, but how the value is formatted is determined by the
116116
// LogSink implementation.
117117
//
118+
// Logger instances are meant to be passed around by value. Code that receives
119+
// such a value can call its methods without having to check whether the
120+
// instance is ready for use.
121+
//
122+
// Calling methods with the null logger (Logger{}) as instance will crash
123+
// because it has no LogSink. Therefore this null logger should never be passed
124+
// around. For cases where passing a logger is optional, a pointer to Logger
125+
// should be used.
126+
//
118127
// Key Naming Conventions
119128
//
120129
// Keys are not strictly required to conform to any specification or regex, but

0 commit comments

Comments
 (0)