Editor’s note: This blog post is part of a series. In it, Greymatter.io team members share reflections from research and development in support of the Envoy Proxy open source community.
Introduction to Envoy
I’ve been using Envoy for quite a while now, since v1 of the xDS APIs. Recently I contributed back to their go-control-plane repository. If you are not familiar with it, it is their open source control plane that follows their predefined xDS discovery spec.
I use this repository actively. Its performance was good, and I liked the functionality it gave our control plane at Greymatter. However, the more I familiarized myself with the code, the more I wanted to improve it and give back to the community. After all, a change made upstream benefits everyone, so why patch logic in a closed source implementation and keep the improvements to yourself?
One thing my co-worker and I noted when we first brought the project in was an overload of logging in the console from go-control-plane. There weren’t any levels so we couldn’t apply our own logging mechanism without having to overload go-control-plane’s exposed interface. Originally, something like this existed:
// Logger interface for reporting informational and warning messages.
type Logger interface {
// Infof logs a formatted informational message.
Infof(format string, args ...interface{})
// Errorf logs a formatted error message.
Errorf(format string, args ...interface{})
}
Digging Deeper into the Control Plane
As you can imagine, you’re quite limited with only Info and Error levels. We had to overload our Info level to hold our debug messages which got messy rather quickly:
type consoleLogger struct{}
func (consoleLogger) Infof(format string, args ...interface{}) {
// the go-control-plane repo over-uses the Info log level causing our xDS logs
// to become polluted with RPC log statements. To suppress that, we moved their Info
// level to our Debug level to reduce Info level log pollution. We pass this logger
// into the snapshot cache package as it implements their logger interface.
console.Debug().Printf(format, args...)
}
func (consoleLogger) Debugf(format string, args ...interface{}) {
console.Debug().Printf(format, args...)
}
func (consoleLogger) Errorf(format string, args ...interface{}) {
console.Error().Printf(format, args...)
}
Beyond Control
So instead of keeping this patch local, I took it upstream. My change gives everyone better logs and simpler debugging:
// Logger interface for reporting informational and warning messages.
type Logger interface {
// Debugf logs a formatted debugging message.
Debugf(format string, args ...interface{})
// Infof logs a formatted informational message.
Infof(format string, args ...interface{})
// Warnf logs a formatted warning message.
Warnf(format string, args ...interface{})
// Errorf logs a formatted error message.
Errorf(format string, args ...interface{})
}
It was a small contribution to open source. Still, I was excited to finally get involved in the community and add logic that every go-control-plane and Envoy user can use. Happy debugging!

