log

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: LGPL-3.0 Imports: 11 Imported by: 0

README

log

Simple and efficient micro log library that supports features such as condition, color, and file split

example

package main

import (
	"github.com/refitself/rslog"
)

func initLog() {
	log.SetDepth(4)
	log.SetFlags(log.LstdFlags)
	log.SetHighlighting(false)
	log.SetLevel(log.LOG_LEVEL_ALL)
}

func main() {
	initLog()

	log.Info("test Info")
	log.Infof("test Infof: %s", "hello log")

	log.Debug("test Debug")
	log.Debugf("test Debugf: %s", "hello log")

	log.Warning("test Warning")
	log.Warningf("test Warningf: %s", "hello log")

	log.Error("test Error")
	log.Errorf("test Errorf: %s", "hello log")
}

screenshot

alt

Documentation

Overview

Simple and efficient micro log library that supports features such as condition, color, and file split

high level log wrapper, so it can output different log based on level

Index

Constants

View Source
const (
	Ldate         = log.Ldate
	Llongfile     = log.Llongfile
	Lmicroseconds = log.Lmicroseconds
	Lshortfile    = log.Lshortfile
	LstdFlags     = log.LstdFlags
	Ltime         = log.Ltime
)
View Source
const (
	LOG_FATAL   = LogType(0x1)
	LOG_ERROR   = LogType(0x2)
	LOG_WARNING = LogType(0x4)
	LOG_INFO    = LogType(0x8)
	LOG_DEBUG   = LogType(0x10)
)
View Source
const (
	LOG_LEVEL_NONE  = LogLevel(0x0)
	LOG_LEVEL_FATAL = LOG_LEVEL_NONE | LogLevel(LOG_FATAL)
	LOG_LEVEL_ERROR = LOG_LEVEL_FATAL | LogLevel(LOG_ERROR)
	LOG_LEVEL_WARN  = LOG_LEVEL_ERROR | LogLevel(LOG_WARNING)
	LOG_LEVEL_INFO  = LOG_LEVEL_WARN | LogLevel(LOG_INFO)
	LOG_LEVEL_DEBUG = LOG_LEVEL_INFO | LogLevel(LOG_DEBUG)
	LOG_LEVEL_ALL   = LOG_LEVEL_DEBUG
)
View Source
const FORMAT_TIME_DAY string = "20060102"
View Source
const FORMAT_TIME_HOUR string = "2006010215"

Variables

This section is empty.

Functions

func Clone

func Clone() *logger

func CrashLog

func CrashLog(file string)

func Debug

func Debug(v ...interface{})

func Debugf

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

func Enter

func Enter(count int)

func Error

func Error(v ...interface{})

func Errorf

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

func Fatal

func Fatal(v ...interface{})

func Fatalf

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

func GetDirFileInfo

func GetDirFileInfo(depth int) string

func GetLvlColorStr

func GetLvlColorStr(t LogType, msg string) (strLevel, strColor string)

func GetOutPutInfo

func GetOutPutInfo(strDirFile, strLevel, strColor string) string

func GetRegistLog

func GetRegistLog(key string) *logger

get the regist logger by name

func Info

func Info(v ...interface{})

func Infof

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

func LogLevelToString

func LogLevelToString(level LogLevel) string

func LogPrint

func LogPrint(t LogType, v ...interface{})

func LogPrintf

func LogPrintf(t LogType, format string, v ...interface{})

func LogTypeToString

func LogTypeToString(t LogType) (string, string)

func Logger

func Logger() *log.Logger

func New

func New() *logger

func Newlogger

func Newlogger(w io.Writer, prefix string) *logger

func RegistLog

func RegistLog(key string, ptrLog *logger)

support regist logger by name

func SetColorByLogType

func SetColorByLogType(t LogType, colorFunc func(string, ...interface{}) string)

func SetDepth

func SetDepth(depth int)

func SetFlags

func SetFlags(flags int)

func SetHighlighting

func SetHighlighting(highlighting bool)

func SetLevel

func SetLevel(level LogLevel)

func SetLevelByString

func SetLevelByString(level string)

func SetOutput

func SetOutput(out io.Writer)

func SetOutputByMultiWriter

func SetOutputByMultiWriter(path string, writers ...io.Writer) error

func SetOutputByName

func SetOutputByName(path string) error

func SetRotateByDay

func SetRotateByDay()

func SetRotateByHour

func SetRotateByHour()

func Warn

func Warn(v ...interface{})

func Warnf

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

func Warning

func Warning(v ...interface{})

func Warningf

func Warningf(format string, v ...interface{})

Types

type LogLevel

type LogLevel int

func GetLogLevel

func GetLogLevel() LogLevel

func StringToLogLevel

func StringToLogLevel(level string) LogLevel

type LogType

type LogType int

type MLog

type MLog struct {
	Module string
}

func (*MLog) Debug

func (p *MLog) Debug(datas ...interface{})

func (*MLog) Debugf

func (p *MLog) Debugf(format string, datas ...interface{})

func (*MLog) Error

func (p *MLog) Error(datas ...interface{})

func (*MLog) Errorf

func (p *MLog) Errorf(format string, datas ...interface{})

func (*MLog) Info

func (p *MLog) Info(datas ...interface{})

func (*MLog) Infof

func (p *MLog) Infof(format string, datas ...interface{})

func (*MLog) Warning

func (p *MLog) Warning(datas ...interface{})

func (*MLog) Warningf

func (p *MLog) Warningf(format string, datas ...interface{})

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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