Categorygithub.com/luopengift/log
modulepackage
0.0.0-20190418080018-fdc6f849ef5d
Repository: https://github.com/luopengift/log.git
Documentation: pkg.go.dev

# README

log

useage example

package main

import (
	"os"
	"github.com/luopengift/log"
)

func main() {
	log.Debug("%s", "Hello Debug") //默认用法
	log.Info("%s", "Hello Info") //默认用法
	log.Warn("%s", "Hello Warn") //默认用法

	file := log.NewFile("filename")
	file.SetMaxBytes(100)
	mylogs := log.NewLog("file", file)
	mylogs.SetFormatter(log.NewTextFormat("MESSAGE", log.ModeColor))
	mylogs.SetLevel(log.DEBUG)
	mylogs.Info("%s", "This is a log test")

	std := log.NewLog("std", os.Stdout)
	std.SetFormatter(log.NewTextFormat("TIME LEVEL MODULE FILE:LINE MESSAGE", log.ModeColor))
	std.Warn("THIS IS WARN TEST")

	log.AddLogger(mylogs)
	log.GetLogger("file").Info("%s", "This is a logger test")
	log.GetLogger("file").Warn("This is a warn test")
	log.GetLogger("file").Error("This is a error test")

}

# Packages

No description provided by the author

# Functions

AddLogger add a Log to Logger.
ConsoleWithBlue write message to stderr with blue color.
ConsoleWithGreen write message to stderr with red color.
ConsoleWithMagenta write message to stderr with magenta color.
ConsoleWithRed write message to stderr with red color.
ConsoleWithYellow write message to stderr with yellow color.
Debugf calls default output to write the log as level debug.
DelLogger delete a named Log.
Dump return data dump and format bytes.
Errorf calls default output to write the log as level error.
Fatalf calls default output to write the log as level fatal.
FuncName get function name.
GetDefaultLogger get default Log.
GetLogger get Log with name, if not set then returns default Log.
Infof calls default output to write the log as level info.
NameWithTime formats string by time.
NewConsoleLog default log print into stderr.
NewFile create a FileWrite with implements FileWriter interface.
NewLog init a log with default config.
NewTextFormat defines TextFormat.
Output output.
OutputWithFile write to file, It truncates file before writing.
Panic calls default output to write the log as level panic.
ResetDefaultLogger set default Log with __ROOT__.
SetDefaultLogger set default Log with named Log.
SetLevel set default level.
SetLogger update Log.
SetOutput sets default log output.
SetTextFormat sets default log message format.
SetTimeFormat sets default time format, if TIME is enabled.
Stack get stack bytes.
Trace calls default output to write the log as level trace.
Warnf calls default output to write the log as level warn.

# Constants

DEBUG level debug.
DEFAULTFORMAT default log message format.
DEBUG level debug.
DEBUG level debug.
DEBUG level debug.
异步.
ModeColor color mode.
同步.
DEBUG level debug.
DEBUG level debug.
DEBUG level debug.

# Variables

LevelColor Level color.
LevelMap level map.
Logger manage mutli log handler.

# Structs

Console simple consile log.
FileWrite implements FileWriter interface.
JSONFormat implements Formatter interface.
KvFormat implements Formatter interface.
Log handler.
NullFormat implements Formatter interface.
Record defines a log message event.
TextFormat implements Formatter interface.

# Interfaces

FileWriter implements io.Writer interface,.
Formatter interface.