Documentation ¶
Overview ¶
Package logging implements a Zap-based logger, configured to be GCE/Stackdriver-compatible.
Index ¶
Constants ¶
const DomainKey = "_domain"
DomainKey is the map key used for logging domains. Domains divide a source into sub-sources (see Logger.NewDomainLogger).
const HostKey = "_host"
HostKey is the map key used for logging the machine hostname (via os.Hostname; see NewLog).
const SourceKey = "_source"
SourceKey is the map key used for logging sources (typically the name of the application; see NewLog).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldSet ¶
FieldSet is an alias for a slice of zapcore Fields. Functions that aggregate fields can return a FieldSet to allow further aggregation.
func (FieldSet) AppendFieldSet ¶
AppendFieldSet appends a FieldSet to the current FieldSet.
type Logger ¶
Logger is a Zap-based logger configured to be GCE/Stackdriver-compatible.
func NewLog ¶
NewLog returns a new Logger instance. If 'productionLogging' is true, JSON logger is constructed which logs at the Info level (by default); if 'productionLogging' is false, a developent-oriented console logger is constructed which logs at the Debug level. 'source' is the optional source (e.g. application or service name) of the events; all logs under this logger and its domains will be tagged with the source, if one is provided. 'fields' is an optional set of fields to install in the logger instance.
func (*Logger) Debug ¶
Debug logs development-related information that is not typically necessary for production. When choosing a logging level, you should assume that debug logging will be disabled in production environments.
func (*Logger) ErrorWithTrace ¶
ErrorWithTrace logs an error and captures the current stack trace (at the cost of a small performance hit). ErrorWithTrace is appropriate for unexpected errors, where the stack trace will be useful in diagnosing the root cause. For expected / non-critical errors, you may wish to prefer Info with a zap.Error() field.
func (*Logger) Info ¶
Info logs at a level suitable for production; the log should be *actionable information* that will be read by a human, or by a machine.
func (*Logger) NewDomainLogger ¶
NewDomainLogger returns a new Logger instance, based on the current instance, with the provided domain. The domain is set via With() using a well-defined key.