logger

package module
v0.0.0-...-5255fa5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Created from https://github.com/nkmr-jp/go-logger-scaffold

Created from https://github.com/nkmr-jp/go-logger-scaffold

Created from https://github.com/nkmr-jp/go-logger-scaffold

Created from https://github.com/nkmr-jp/go-logger-scaffold

Created from https://github.com/nkmr-jp/go-logger-scaffold

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, fields ...zap.Field)

Debug is Wrapper of Zap's Debug. Outputs a short log to the console. Detailed json log output to log file.

func Debugf

func Debugf(msg string, err error, fields ...zap.Field)

Debugf is Outputs a Debug log with formatted error.

func Dump

func Dump(i interface{})

Dump is Wrapper of spew.Dump()

func Error

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

func Errorf

func Errorf(msg string, err error, fields ...zap.Field)

func Fatal

func Fatal(msg string, fields ...zap.Field)

func Fatalf

func Fatalf(msg string, err error, fields ...zap.Field)

func GetVersion deprecated

func GetVersion(versionType VersionType) *string

GetVersionFromGit use the git revision or tag as a version. When using tag, recommend semantic versioning. See https://semver.org/

Deprecated: it will be removed in the next major version upgrade.

func Info

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

func Infof

func Infof(msg string, err error, fields ...zap.Field)

func InitLogger

func InitLogger() *zap.Logger

Initialize the Logger. Outputs short logs to the console and Write structured and detailed json logs to the log file.

func Print

func Print(i interface{}) (n int, err error)

Print is Wrapper of pp.Print()

func Println

func Println(i interface{}) (n int, err error)

Println is Wrapper of pp.Println()

func SetConsoleField

func SetConsoleField(fieldKey ...string)

SetConsoleField Set the fields to be displayed in the console.

func SetConsoleType

func SetConsoleType(option ConsoleType)

func SetLogFile

func SetLogFile(file string)

SetLogFile set log file path ex. "./log/app_%Y-%m-%d.log"

func SetLogLevel

func SetLogLevel(option zapcore.Level)

func SetLogLevelByString

func SetLogLevelByString(levelStr string)

SetLogLevelByString is set log level. levelStr can use (DEBUG,INFO,WARN,ERROR,FATAL).

func SetOutputType

func SetOutputType(option OutputType)

func SetOutputTypeByString

func SetOutputTypeByString(outputTypeStr string)

SetOutputTypeByString outputTypeStr can use (SimpleConsoleAndFile, ConsoleAndFile, Console, File).

func SetPurgeTime

func SetPurgeTime(duration time.Duration)

func SetRepositoryCallerEncoder

func SetRepositoryCallerEncoder(urlFormat, revisionOrTag, srcRootDir string)

SetRepositoryCallerEncoder build and set CallerEncoder that build a link to the Repository of the caller's source code.

func SetRotationTime

func SetRotationTime(duration time.Duration)

func SetVersion

func SetVersion(revisionOrTag string)

SetVersion set version. note: `revisionOrTag` should be a git revision or a tag. ex. `e86b9a7` or `v1.0.0`.

func Sync

func Sync()

Sync wrapper of Zap's Sync.

func SyncWhenStop

func SyncWhenStop()

SyncWhenStop flush log buffer. when interrupt or terminated.

func Warn

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

func Warnf

func Warnf(msg string, err error, fields ...zap.Field)

Types

type ConsoleType

type ConsoleType int
const (
	ConsoleTypeAll ConsoleType = iota
	ConsoleTypeError
	ConsoleTypeNone
)

type OutputType

type OutputType int
const (
	// OutputTypeShortConsoleAndFile output simple console log and detail file log (default)
	OutputTypeShortConsoleAndFile OutputType = iota
	// OutputTypeConsoleAndFile output detail console log and file log
	OutputTypeConsoleAndFile
	// OutputTypeConsole output detail console log
	OutputTypeConsole
	// OutputTypeFile output detail file log
	OutputTypeFile
)

func (OutputType) String

func (o OutputType) String() string

type VersionType deprecated

type VersionType int

Deprecated: it will be removed in the next major version upgrade.

const (
	// Deprecated: it will be removed in the next major version upgrade.
	VersionTypeRevision VersionType = iota
	// Deprecated: it will be removed in the next major version upgrade.
	VersionTypeTag
)

type Wrapper

type Wrapper struct {
	Fields []zap.Field
}

func NewWrapper

func NewWrapper(fields ...zap.Field) *Wrapper

NewWrapper can additional fields. ex. Use this when you want to add a common value in the scope of a context, such as an API request.

func (*Wrapper) Debug

func (w *Wrapper) Debug(msg string, fields ...zap.Field)

func (*Wrapper) Debugf

func (w *Wrapper) Debugf(msg string, err error, fields ...zap.Field)

func (*Wrapper) Error

func (w *Wrapper) Error(msg string, fields ...zap.Field)

func (*Wrapper) Errorf

func (w *Wrapper) Errorf(msg string, err error, fields ...zap.Field)

func (*Wrapper) Fatal

func (w *Wrapper) Fatal(msg string, fields ...zap.Field)

func (*Wrapper) Fatalf

func (w *Wrapper) Fatalf(msg string, err error, fields ...zap.Field)

func (*Wrapper) Info

func (w *Wrapper) Info(msg string, fields ...zap.Field)

func (*Wrapper) Infof

func (w *Wrapper) Infof(msg string, err error, fields ...zap.Field)

func (*Wrapper) Warn

func (w *Wrapper) Warn(msg string, fields ...zap.Field)

func (*Wrapper) Warnf

func (w *Wrapper) Warnf(msg string, err error, fields ...zap.Field)

Jump to

Keyboard shortcuts

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