
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
Log is a logging interface for Go. That's it. Pass around the interface.
Users want to standardise logging. Sometimes libraries log. We leave the underlying logging implementation to the user
while allowing libraries to log by simply expecting something that satisfies the Logger interface. This leaves
the user free to pre-configure structure, output, etc.
The interface is minimalistic on purpose:
type Logger interface {
Log(v ...interface{})
Logf(format string, v ...interface{})
}
For more motivation for this minimal interface, see Dave Cheney's blog post.
Libraries will only need the Logger interface, although they may choose to use the nest package to create subloggers with additional context.
Calling code will need to create a Logger interface, and there are a number of implementations and wrappers available to make that easy:
io.Writer like os.Stdout.
It uses fmt.Sprint and Sprintf to generate the logged lines.Info and Infof calls.
It can be used to wrap implementations like glog.Verbose and logrus.Entry.Print and Printf calls.
It can be used to wrap implementations like glog.Verbose.log.Print and log.Printf.Outside of this repository, there are additional wrappers for:
The Logger interface is also simple enough to make writing your own implementation or wrapper very straightforward.
Pre-configure a logger using WithFields and pass it as an option to a library:
import (
"github.com/go-log/log/print"
"github.com/lib/foo"
"github.com/sirupsen/logrus"
)
logger := print.New(logrus.WithFields(logrus.Fields{
"library": "github.com/lib/foo",
}))
f := foo.New(logger)
github.com/go-logr/logr is a similar interface approach to logging, although the logr.Logger interface is more elaborate.
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.