Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions dhcpv4/server4/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,21 @@ func (d DebugLogger) Printf(format string, v ...interface{}) {
func (d DebugLogger) PrintMessage(prefix string, message *dhcpv4.DHCPv4) {
d.Printf("%s: %s", prefix, message.Summary())
}

// SimpleLogger is a straight-forward implementation of the new Logger
// interface, for anyone who wishes to wrap logging simply, without having to
// use the complicated interface directly. Just pass in your desired printf
// function, and off you go!
type SimpleLogger struct {
Logf func(format string, v ...interface{})
}

// Printf does what you'd expect, except it does so to your configured function.
func (obj *SimpleLogger) Printf(format string, v ...interface{}) {
obj.Logf(format, v...)
}

// PrintMessage prints to your configured function.
func (obj *SimpleLogger) PrintMessage(prefix string, message *dhcpv4.DHCPv4) {
obj.Logf("%s: %s", prefix, message)
}