-
Notifications
You must be signed in to change notification settings - Fork 225
Logging
client-go uses pingcap/log
for logging messages. pingcap/log
internall adopts go.uber.org/zap
as the logging framework.
pingcap/log
provides a set of global methods for configuring loggers. The easiest way is to create a logger with the InitLogger
function, and then use ReplaceGlobals() to set the logger as a global logger.
client-go also supports passing a logger through context. It also exports a handy function tikv.WithLogContext()
that can be used to set the logger in a context.
In common usage, code that calls the client-go interface may have different contexts, such as different connections or different users. A common requirement is the need for client-go to identify different contexts in the log to help troubleshoot problems. This requirement can also be achieved by passing additional information through the context. Using the util.SetSessionID
function, we can pass a session id of type uint64 to client-go. client-go will record this session id in the logs.
Feel free to help improving! Minor changes are warmly welcomed. Just simply click edit!
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Contents
- Client-Go Wiki
- Compatibility
- API V2
- Transactional API
- RawKV API
- Configurations
- Utilities