zap

package module
v0.0.0-...-de8cd67 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

log-zap GoDoc

Adapter for the uber zap logger to be used behind the log facade.

usage example

The zap adapter automagically detects if the app runs from a development host (e.g. from Goland or Visual Studio Code) and uses the zap development preset. Otherwise, it uses the production preset.

package main

import (
    "github.com/golangee/log"
	zap "github.com/golangee/log-zap"
)

func main() {
	zap.Configure()
	logger := log.New("myNamedLogger")
	logger.Info("my message", log.Obj("some key", "some value"))
    //...
}

Documentation

Overview

Package zap provides an implementation for the golangee/log facade. It also provides an automatic configure method, which detects automatically if the development or production logger must be used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure()

Configure initializes the uber zap logger to be used with the golangee/log package. See also #IsDevelopment().

func IsDevelopment

func IsDevelopment() bool

IsDevelopment evaluates the following sources:

  • if any _INTELLIJ_* environment variable is defined, returns true
  • XPC_SERVICE_NAME contains goland
  • if APP_ENV or NODE_ENV environment variable is set to 'production' returns false, otherwise if specified at all returns true
  • if any VSCODE_* environment variable is defined, returns true
  • otherwise returns false

Types

type LogAdapter

type LogAdapter struct {
	// contains filtered or unexported fields
}

LogAdapter is a delegating implementation of golangee/log#Logger.

func NewLogAdapter

func NewLogAdapter(delegate *zap.Logger) LogAdapter

NewLogAdapter creates a new logger

func (LogAdapter) Debug

func (l LogAdapter) Debug(msg string, fields ...log.Field)

func (LogAdapter) Error

func (l LogAdapter) Error(msg string, fields ...log.Field)

func (LogAdapter) Fatal

func (l LogAdapter) Fatal(msg string, fields ...log.Field)

func (LogAdapter) Info

func (l LogAdapter) Info(msg string, fields ...log.Field)

func (LogAdapter) Panic

func (l LogAdapter) Panic(msg string, fields ...log.Field)

func (LogAdapter) Trace

func (l LogAdapter) Trace(msg string, fields ...log.Field)

func (LogAdapter) Unwrap

func (l LogAdapter) Unwrap() *zap.Logger

func (LogAdapter) Warn

func (l LogAdapter) Warn(msg string, fields ...log.Field)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL