log

package
v0.0.0-...-0820d52 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package log redirects output from the standard library's package-global logger to the wrapped zap logger at InfoLevel. It also has a predefined 'standard' Logger accessible through helper functions Print[f|ln], Fatal[f|ln], and Panic[f|ln], which are easier to use than creating a Logger manually.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockNumber

func BlockNumber(n int64) zap.Field

BlockNumber constructs a "block_number" field with the given block number.

func CallbackURL

func CallbackURL(url string) zapcore.Field

CallbackURL constructs a "callback_url" field with given url.

func ClaimID

func ClaimID(id int64) zapcore.Field

ClaimID constructs a "claim_id" field with the given ID.

func CorrelationID

func CorrelationID(ID string) zapcore.Field

CorrelationID constructs a "correlation_id field with the given id.

func DealID

func DealID(id int64) zapcore.Field

DealID constructs a "deal_id" field with the given ID.

func Err

func Err(err error) zapcore.Field

Err constructs a "error" field with the error text.

func Error

func Error(msg string, fields ...zapcore.Field)

Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func Fatal

func Fatal(args ...interface{})

Fatal is equivalent to Print() followed by a call to os.Exit(1).

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf is equivalent to Printf() followed by a call to os.Exit(1).

func Fatalln

func Fatalln(args ...interface{})

Fatalln is equivalent to Println() followed by a call to os.Exit(1).

func FieldFloat64

func FieldFloat64(field string, val float64) zapcore.Field

FieldFloat64 creates a new zapcore field

func FieldFloatInt64

func FieldFloatInt64(field string, val int64) zapcore.Field

FieldFloatInt64 creates a new zapcore field

func FieldsFrom

func FieldsFrom(m map[string]interface{}) (s []zapcore.Field)

FieldsFrom returns fields from a map[string]interface{}.

func HTTPHeader

func HTTPHeader(h http.Header) zap.Field

HTTPHeader constructs a "http_header" field with the given header.

func HTTPRequest

func HTTPRequest(req interface{}) zapcore.Field

HTTPRequest constructs a "http_request" field with given req.

func HTTPResponse

func HTTPResponse(resp interface{}) zapcore.Field

HTTPResponse constructs a "http_response" field with given resp.

func Info

func Info(msg string, fields ...zapcore.Field)

Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func MerchantID

func MerchantID(id int64) zapcore.Field

MerchantID constructs a "merchant_id" field with given ID.

func NewDevelopment

func NewDevelopment() *zap.Logger

NewDevelopment creates logger for development

func NewProduction

func NewProduction() *zap.Logger

NewProduction creates logger for production

func Panic

func Panic(args ...interface{})

Panic is equivalent to Print() followed by a call to panic().

func Panicf

func Panicf(template string, args ...interface{})

Panicf is equivalent to Printf() followed by a call to panic().

func Panicln

func Panicln(args ...interface{})

Panicln is equivalent to Println() followed by a call to panic().

func PhoneCode

func PhoneCode(code string) zapcore.Field

PhoneCode constructs a "phone_code" field with the given phone code.

func PhoneNumber

func PhoneNumber(number string) zapcore.Field

PhoneNumber constructs a "phone_number" field with the given phone number.

func Print

func Print(args ...interface{})

Print calls log.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.

func Printf

func Printf(template string, args ...interface{})

Printf calls log.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.

func Println

func Println(args ...interface{})

Println calls log.Output to print to the logger. Arguments are handled in the manner of fmt.Println.

func ReplaceGlobals

func ReplaceGlobals(l *zap.Logger)

ReplaceGlobals replaces the global loggers

func RequestMethod

func RequestMethod(m string) zap.Field

RequestMethod constructs a "request_method" field with the given method.

func RequestURL

func RequestURL(url url.URL) zap.Field

RequestURL constructs a "request_url" field with the given url

func StatusCode

func StatusCode(s int) zap.Field

StatusCode constructs a "status_code" field with the given status code.

func StdLogger

func StdLogger() (l *log.Logger)

StdLogger returns a *log.Logger which writes to the underlying logger at InfoLevel.

func Sync

func Sync() error

Sync flushes any buffered log entries. Applications should take care to call Sync before exiting.

func UserHash

func UserHash(hash string) zapcore.Field

UserHash constructs a "user_hash" field with the given hash.

func UserID

func UserID(id int64) zapcore.Field

UserID constructs a "user_id" field with the given ID.

func UserUUID

func UserUUID(uuid string) zapcore.Field

UserUUID constructs a "user_uuid" field with the given hash.

func Warn

func Warn(msg string, fields ...zapcore.Field)

Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

Types

type Logger

type Logger zap.Logger

Logger extends zap.Logger

func With

func With(fields ...zapcore.Field) *Logger

With creates a child logger and adds structured context to it. Fields added to the child don't affect the parent, and vice versa.

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...zapcore.Field)

Error logs a message at errorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...zapcore.Field)

Info logs a message at infoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...zapcore.Field)

Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func (*Logger) With

func (l *Logger) With(fields ...zapcore.Field) *Logger

With returns new logger with new fields

func (*Logger) WithFieldFloat64

func (l *Logger) WithFieldFloat64(field string, val float64) *Logger

WithFieldFloat64 creates a new zapcore field

func (*Logger) WithFieldInt

func (l *Logger) WithFieldInt(field string, val int64) *Logger

WithFieldInt creates a new zapcore field

func (*Logger) WithOptions

func (l *Logger) WithOptions(opts ...zap.Option) *Logger

WithOptions creates a child logger with options.

Jump to

Keyboard shortcuts

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