Zap Concepts: Difference between revisions
Line 30: | Line 30: | ||
=Two Logging APIs= | =Two Logging APIs= | ||
=Structured Logging= | =Structured Logging= | ||
Also see {{Internal|Logging#Structured_Logging|Structured Logging}} | |||
=Log Rendering= | =Log Rendering= |
Revision as of 20:50, 13 March 2024
Internal
TODO
Deplete from Zap_Concepts_TODEPLETE
Overview
Zap is a logging framework for Go. It provides fast, structured, contextual and leveled logging.
Logging is performing by creating a Logger
object and using its API. Creation of Logger
instances can be done in a number of way that are explored in the Logger Instance Creation section. There are actually two APIs, Logger
and SugaredLogger
. The former is aimed for high-performance scenario, but it only supports structured logging, while the latter has a more friendlier, and just slightly less performant syntax. The difference is discussed in Two Logging APIs section.
Each logging invocation creates a log event with key/value pairs. What about the log message?. Depending on the encoder?, the rendering of the log events can be controlled. These aspects are discussed in the Log Rendering section.
There is no global logger that can be used right away, though one can be configured.
Zap supports the standard DEBUG, INFO, WARN and ERROR logging levels. It comes with a few new ones: TODO The ERROR level requires special attention. There is no TRACE. More details are available in the Logging Levels section.
By default, loggers are unbuffered. This aspect is discussed in the Buffering section.
Child loggers.
Implementation: zap and zap core.
Logger Instance Creation
The framework comes with three preset constructors: zap.NewExample()
, zap.NewProduction()
and zap.NewDevelopment()
.
Two Logging APIs
Structured Logging
Also see