Zap Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 10: Line 10:
Zap is a logging framework for Go. It provides fast, [[Logging#Structured_Logging|structured]], [[Logging#Contextual_Logging|contextual]], [[#Logging_Levels|leveled]] logging.
Zap is a logging framework for Go. It provides fast, [[Logging#Structured_Logging|structured]], [[Logging#Contextual_Logging|contextual]], [[#Logging_Levels|leveled]] logging.


Logging is performing by creating a <code>Logger</code> object and using its API. There are actually two APIs, <code>Logger</code> and <code>SugaredLogger</code>. The former is aimed for high-performance scenario, while the latter has a more friendlier, and just slightly less performant syntax. The difference is discussed in [[#Two_Logging_APIs|Two Logging APIs]] section.
Logging is performing by creating a <code>Logger</code> object and using its API. Creation of <code>Logger</code> instances can be done in a number of way that are explored in the [[#Logger_Instance_Creation|Logger Instance Creation]] section. There are actually two APIs, <code>Logger</code> and <code>SugaredLogger</code>. The former is aimed for high-performance scenario, while the latter has a more friendlier, and just slightly less performant syntax. The difference is discussed in [[#Two_Logging_APIs|Two Logging APIs]] section.
 
Creation of <code>Logger</code> instances can be done in a number of way that are explored in the [[#Logger_Instance_Creation|Logger Instance Creation]] section.  


Each logging invocation creates a log event with key/value pairs. <font color=darkkhaki>What about the log message?</font>. Depending on the <font color=darkkhaki>encoder?</font>, the rendering of the log events can be controlled. Rendering.
Each logging invocation creates a log event with key/value pairs. <font color=darkkhaki>What about the log message?</font>. Depending on the <font color=darkkhaki>encoder?</font>, the rendering of the log events can be controlled. Rendering.

Revision as of 20:28, 13 March 2024

Internal

TODO

Deplete from Zap_Concepts_TODEPLETE

Overview

Zap is a logging framework for Go. It provides fast, structured, contextual, 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, 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. Rendering.

There is no global logger that can be used right away, though one can be configured.

The supported logging levels are: .... Errors require special attention. More details are available in the Logging Levels section.

Child loggers.

Implementation: zap and zap core.

Logger Instance Creation

Two Logging APIs

Logging Levels

Custom Logging Levels