log

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

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

Go to latest
Published: Nov 1, 2017 License: MIT Imports: 14 Imported by: 1

README

log

Go logging library wrapped zap

Build Status

Installation

go get -u github.com/FeiniuBus/log

Normal logger

package main

import (
    "fmt"

    "github.com/FeiniuBus/log"
)

func main() {
    logger, err := log.New(false)
    if err != nil {
        fmt.Println(err.Error())
        return
    }
    defer logger.Sync()

    logger.With("url", "http://www.baidu.com").Warn("failed to fetch URL")
}

Logstash

Currently only support through the udp packet to logstash to send data

package main

import (
    "fmt"

    "github.com/FeiniuBus/log"
)

func main() {
    logger, err := log.NewLogstash(false, "host", port)
    if err != nil {
        fmt.Println(err.Error())
        return
    }
    defer logger.Sync()

    logger.With("url", "http://www.baidu.com").Warn("failed to fetch URL")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallerEncoder

func CallerEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder)

func NewSyslogEncoder

func NewSyslogEncoder(cfg SyslogEncoderConfig) zapcore.Encoder

Types

type Framing

type Framing int
const (
	NonTransparentFraming Framing = iota
	OctetCountingFraming
	DefaultFraming = NonTransparentFraming
)

type Logger

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

func New

func New(debugLevel bool) (*Logger, error)

func NewLogstash

func NewLogstash(debugLevel bool, host string, port int) (*Logger, error)

func NewLogstashWithTimeout

func NewLogstashWithTimeout(debugLevel bool, host string, port int, timeout int) (*Logger, error)

func NewSyslog

func NewSyslog(debugLevel bool, app string) (*Logger, error)

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

func (*Logger) Debugln

func (l *Logger) Debugln(v ...interface{})

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

func (*Logger) Errorln

func (l *Logger) Errorln(v ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(v ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...interface{})

func (*Logger) Fatalln

func (l *Logger) Fatalln(v ...interface{})

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

func (*Logger) Infoln

func (l *Logger) Infoln(v ...interface{})

func (*Logger) Panic

func (l *Logger) Panic(v ...interface{})

func (*Logger) Panicf

func (l *Logger) Panicf(format string, args ...interface{})

func (*Logger) Panicln

func (l *Logger) Panicln(v ...interface{})

func (*Logger) Print

func (l *Logger) Print(v ...interface{})

func (*Logger) Printf

func (l *Logger) Printf(format string, args ...interface{})

func (*Logger) Println

func (l *Logger) Println(v ...interface{})

func (*Logger) Sync

func (l *Logger) Sync() error

func (*Logger) Warn

func (l *Logger) Warn(v ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

func (*Logger) Warnln

func (l *Logger) Warnln(v ...interface{})

func (*Logger) With

func (l *Logger) With(key string, value interface{}) *Logger

type SyslogEncoderConfig

type SyslogEncoderConfig struct {
	zapcore.EncoderConfig

	Framing  Framing
	Facility syslog.Priority
	PID      int
	Hostname string
	App      string
}

type SyslogSyncer

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

func NewSyslogSyncer

func NewSyslogSyncer() (*SyslogSyncer, error)

func (*SyslogSyncer) Sync

func (s *SyslogSyncer) Sync() error

func (*SyslogSyncer) Write

func (s *SyslogSyncer) Write(p []byte) (n int, err error)

type UDPSyncer

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

func NewUDPSyncer

func NewUDPSyncer(host string, port int, timeout int) (*UDPSyncer, error)

func (*UDPSyncer) Sync

func (s *UDPSyncer) Sync() error

func (*UDPSyncer) Write

func (s *UDPSyncer) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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