log

package
v0.0.0-...-9f41b84 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2020 License: MIT, Apache-2.0 Imports: 7 Imported by: 0

README

Kira

Logger for kira framework

Getting Started


Getting Started

TODO

Documentation

Overview

Package log implements a simple logging package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultFormatter - default log formatter.
	DefaultFormatter = new(DefaultLogFormatter)
	// StdLog - default log
	StdLog = New(os.Stderr, DefaultFormatter, Fields{})
)
View Source
var LevelStrings = map[string]Level{
	"debug": DebugLevel,
	"info":  InfoLevel,
	"warn":  WarnLevel,
	"error": ErrorLevel,
	"fatal": FatalLevel,
	"panic": PanicLevel,
}

LevelStrings - to return level type by level name

View Source
var Strings = [...]string{
	DebugLevel: "DEBUG",
	InfoLevel:  "INFO",
	WarnLevel:  "WARN",
	ErrorLevel: "ERROR",
	FatalLevel: "FATAL",
	PanicLevel: "PANIC",
}

Strings mapping.

Functions

func Debug

func Debug(v ...interface{})

Debug calls log to print to the standard logger.

func Debugf

func Debugf(f string, v ...interface{})

Debugf calls log to print to the standard logger.

func Error

func Error(v ...interface{})

Error calls log to print to the standard logger.

func Errorf

func Errorf(f string, v ...interface{})

Errorf calls log to print to the standard logger.

func Fatal

func Fatal(v ...interface{})

Fatal calls log to print to the standard logger.

func Fatalf

func Fatalf(f string, v ...interface{})

Fatalf calls log to print to the standard logger.

func Info

func Info(v ...interface{})

Info calls log to print to the standard logger.

func Infof

func Infof(f string, v ...interface{})

Infof calls log to print to the standard logger.

func Panic

func Panic(v ...interface{})

Panic calls log to print to the standard logger.

func Panicf

func Panicf(f string, v ...interface{})

Panicf calls log to print to the standard logger.

func Warn

func Warn(v ...interface{})

Warn calls log to print to the standard logger.

func Warnf

func Warnf(f string, v ...interface{})

Warnf calls log to print to the standard logger.

Types

type DefaultLogFormatter

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

DefaultLogFormatter - default log formatter

func NewDefaultFormatter

func NewDefaultFormatter() *DefaultLogFormatter

NewDefaultFormatter ...

func (*DefaultLogFormatter) Format

func (d *DefaultLogFormatter) Format(log *Logger, l Level, msg interface{}, t time.Time) error

Format - it's format the output log

type Fields

type Fields map[string]interface{}

func (Fields) Get

func (f Fields) Get(name string) interface{}

Get field value by name.

type Formatter

type Formatter interface {
	Format(log *Logger, level Level, msg interface{}, time time.Time) error
}

Formatter interface

type JSONFormatter

type JSONFormatter struct {
	Level   string      `json:"level,omitempty"`
	Time    string      `json:"time,omitempty"`
	Message interface{} `json:"message,omitempty"`
	Fields  Fields      `json:"fields,omitempty"`
}

JSONFormatter to format the log into json format.

type JSONLogFormatter

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

JSONLogFormatter - default log formatter

func NewJSONFormatter

func NewJSONFormatter() *JSONLogFormatter

NewJSONFormatter ...

func (*JSONLogFormatter) Format

func (d *JSONLogFormatter) Format(log *Logger, l Level, msg interface{}, t time.Time) error

Format - it's format the output log

type Level

type Level int

Level of severity.

const (
	// DebugLevel - Detailed debug information.
	DebugLevel Level = iota
	// InfoLevel - Interesting events. Examples: User logs in, SQL logs.
	InfoLevel
	// WarnLevel - Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
	WarnLevel
	// ErrorLevel - Runtime errors that do not require immediate action but should typically be logged and monitored.
	ErrorLevel
	// FatalLevel - Logs and then calls `os.Exit(1)`.
	FatalLevel
	// PanicLevel - highest level of severity
	PanicLevel
)

func (Level) String

func (l Level) String() string

type Logger

type Logger struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

Logger - kira logger.

func New

func New(w io.Writer, f Formatter, fields Fields) *Logger

New creates a new Logger.

func (*Logger) Debug

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

Debug calls log to print to the logger.

func (*Logger) Debugf

func (l *Logger) Debugf(f string, v ...interface{})

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

func (*Logger) Error

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

Error calls log to print to the logger.

func (*Logger) Errorf

func (l *Logger) Errorf(f string, v ...interface{})

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

func (*Logger) Fatal

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

Fatal calls log to print to the logger.

func (*Logger) Fatalf

func (l *Logger) Fatalf(f string, v ...interface{})

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

func (*Logger) Info

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

Info calls log to print to the logger.

func (*Logger) Infof

func (l *Logger) Infof(f string, v ...interface{})

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

func (*Logger) Panic

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

Panic calls log to print to the logger.

func (*Logger) Panicf

func (l *Logger) Panicf(f string, v ...interface{})

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

func (*Logger) SetFormatter

func (l *Logger) SetFormatter(f Formatter)

SetFormatter sets the Formatter for the logger.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel sets the level severity for the logger.

func (*Logger) SetWriter

func (l *Logger) SetWriter(w io.Writer)

SetWriter sets the level severity for the logger.

func (*Logger) Warn

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

Warn calls log to print to the logger.

func (*Logger) Warnf

func (l *Logger) Warnf(f string, v ...interface{})

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

func (*Logger) WithField

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

Jump to

Keyboard shortcuts

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